diff options
Diffstat (limited to 'dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-0009-ispc-10_0_fix_for_1788.patch')
-rw-r--r-- | dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-0009-ispc-10_0_fix_for_1788.patch | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-0009-ispc-10_0_fix_for_1788.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-0009-ispc-10_0_fix_for_1788.patch deleted file mode 100644 index 72877d83..00000000 --- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-0009-ispc-10_0_fix_for_1788.patch +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | From d266087e8dba9e8fd4984e1cb85c20376e2c8ea3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Naveen Saini <naveen.kumar.saini@intel.com> | ||
3 | Date: Fri, 27 Aug 2021 11:56:01 +0800 | ||
4 | Subject: [PATCH 2/2] This patch is a fix for #1788. | ||
5 | |||
6 | It is a port of the following llvm 11.0 commit: https://reviews.llvm.org/D81698 | ||
7 | This also needed part of another llvm 11.0 commit: https://reviews.llvm.org/D72975 | ||
8 | |||
9 | Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/aeb50448019ce1b1002f3781f9647d486320d83c] | ||
10 | |||
11 | Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com> | ||
12 | --- | ||
13 | llvm/include/llvm/IR/PatternMatch.h | 22 ++++++++++++--- | ||
14 | .../InstCombine/InstructionCombining.cpp | 27 +++++++++++++++++-- | ||
15 | 2 files changed, 44 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h | ||
18 | index 6621fc9f819c..fb7ad93519f6 100644 | ||
19 | --- a/llvm/include/llvm/IR/PatternMatch.h | ||
20 | +++ b/llvm/include/llvm/IR/PatternMatch.h | ||
21 | @@ -152,8 +152,10 @@ inline match_combine_and<LTy, RTy> m_CombineAnd(const LTy &L, const RTy &R) { | ||
22 | |||
23 | struct apint_match { | ||
24 | const APInt *&Res; | ||
25 | + bool AllowUndef; | ||
26 | |||
27 | - apint_match(const APInt *&R) : Res(R) {} | ||
28 | + apint_match(const APInt *&Res, bool AllowUndef) | ||
29 | + : Res(Res), AllowUndef(AllowUndef) {} | ||
30 | |||
31 | template <typename ITy> bool match(ITy *V) { | ||
32 | if (auto *CI = dyn_cast<ConstantInt>(V)) { | ||
33 | @@ -162,7 +164,8 @@ struct apint_match { | ||
34 | } | ||
35 | if (V->getType()->isVectorTy()) | ||
36 | if (const auto *C = dyn_cast<Constant>(V)) | ||
37 | - if (auto *CI = dyn_cast_or_null<ConstantInt>(C->getSplatValue())) { | ||
38 | + if (auto *CI = dyn_cast_or_null<ConstantInt>( | ||
39 | + C->getSplatValue(AllowUndef))) { | ||
40 | Res = &CI->getValue(); | ||
41 | return true; | ||
42 | } | ||
43 | @@ -192,7 +195,20 @@ struct apfloat_match { | ||
44 | |||
45 | /// Match a ConstantInt or splatted ConstantVector, binding the | ||
46 | /// specified pointer to the contained APInt. | ||
47 | -inline apint_match m_APInt(const APInt *&Res) { return Res; } | ||
48 | +inline apint_match m_APInt(const APInt *&Res) { | ||
49 | + // Forbid undefs by default to maintain previous behavior. | ||
50 | + return apint_match(Res, /* AllowUndef */ false); | ||
51 | +} | ||
52 | + | ||
53 | +/// Match APInt while allowing undefs in splat vector constants. | ||
54 | +inline apint_match m_APIntAllowUndef(const APInt *&Res) { | ||
55 | + return apint_match(Res, /* AllowUndef */ true); | ||
56 | +} | ||
57 | + | ||
58 | +/// Match APInt while forbidding undefs in splat vector constants. | ||
59 | +inline apint_match m_APIntForbidUndef(const APInt *&Res) { | ||
60 | + return apint_match(Res, /* AllowUndef */ false); | ||
61 | +} | ||
62 | |||
63 | /// Match a ConstantFP or splatted ConstantVector, binding the | ||
64 | /// specified pointer to the contained APFloat. | ||
65 | diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | ||
66 | index bf32996d96e2..40a246b9d7a7 100644 | ||
67 | --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | ||
68 | +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | ||
69 | @@ -925,8 +925,31 @@ Instruction *InstCombiner::FoldOpIntoSelect(Instruction &Op, SelectInst *SI) { | ||
70 | if (auto *CI = dyn_cast<CmpInst>(SI->getCondition())) { | ||
71 | if (CI->hasOneUse()) { | ||
72 | Value *Op0 = CI->getOperand(0), *Op1 = CI->getOperand(1); | ||
73 | - if ((SI->getOperand(1) == Op0 && SI->getOperand(2) == Op1) || | ||
74 | - (SI->getOperand(2) == Op0 && SI->getOperand(1) == Op1)) | ||
75 | + | ||
76 | + // FIXME: This is a hack to avoid infinite looping with min/max patterns. | ||
77 | + // We have to ensure that vector constants that only differ with | ||
78 | + // undef elements are treated as equivalent. | ||
79 | + auto areLooselyEqual = [](Value *A, Value *B) { | ||
80 | + if (A == B) | ||
81 | + return true; | ||
82 | + | ||
83 | + // Test for vector constants. | ||
84 | + Constant *ConstA, *ConstB; | ||
85 | + if (!match(A, m_Constant(ConstA)) || !match(B, m_Constant(ConstB))) | ||
86 | + return false; | ||
87 | + | ||
88 | + // TODO: Deal with FP constants? | ||
89 | + if (!A->getType()->isIntOrIntVectorTy() || A->getType() != B->getType()) | ||
90 | + return false; | ||
91 | + | ||
92 | + // Compare for equality including undefs as equal. | ||
93 | + auto *Cmp = ConstantExpr::getCompare(ICmpInst::ICMP_EQ, ConstA, ConstB); | ||
94 | + const APInt *C; | ||
95 | + return match(Cmp, m_APIntAllowUndef(C)) && C->isOneValue(); | ||
96 | + }; | ||
97 | + | ||
98 | + if ((areLooselyEqual(TV, Op0) && areLooselyEqual(FV, Op1)) || | ||
99 | + (areLooselyEqual(FV, Op0) && areLooselyEqual(TV, Op1))) | ||
100 | return nullptr; | ||
101 | } | ||
102 | } | ||
103 | -- | ||
104 | 2.17.1 | ||
105 | |||