summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-03-03 18:59:33 +0000
committerSanjay Patel <spatel@rotateright.com>2019-03-03 18:59:33 +0000
commit2a70703770a3bac2cbe3757922ac06381c3687ff (patch)
tree83acbd357232e39a7198dc0f7efed996cdcb8888
parentd341a94261ad17380ff57d8d1a32e9d9d690edb8 (diff)
downloadbcm5719-llvm-2a70703770a3bac2cbe3757922ac06381c3687ff.tar.gz
bcm5719-llvm-2a70703770a3bac2cbe3757922ac06381c3687ff.zip
[ValueTracking] do not try to peek through bitcasts in computeKnownBitsFromAssume()
There are no tests for this case, and I'm not sure how it could ever work, so I'm just removing this option from the matcher. This should fix PR40940: https://bugs.llvm.org/show_bug.cgi?id=40940 llvm-svn: 355292
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp4
-rw-r--r--llvm/test/Transforms/InstCombine/assume.ll18
2 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index b4473f857e2..64250f6360e 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -617,9 +617,7 @@ static void computeKnownBitsFromAssume(const Value *V, KnownBits &Known,
continue;
Value *A, *B;
- auto m_V = m_CombineOr(m_Specific(V),
- m_CombineOr(m_PtrToInt(m_Specific(V)),
- m_BitCast(m_Specific(V))));
+ auto m_V = m_CombineOr(m_Specific(V), m_PtrToInt(m_Specific(V)));
CmpInst::Predicate Pred;
uint64_t C;
diff --git a/llvm/test/Transforms/InstCombine/assume.ll b/llvm/test/Transforms/InstCombine/assume.ll
index f861741db26..ec345b253fb 100644
--- a/llvm/test/Transforms/InstCombine/assume.ll
+++ b/llvm/test/Transforms/InstCombine/assume.ll
@@ -320,6 +320,24 @@ define void @debug_interference(i8 %x) {
ret void
}
+; This would crash.
+; Does it ever make sense to peek through a bitcast of the icmp operand?
+
+define i32 @PR40940(<4 x i8> %x) {
+; CHECK-LABEL: @PR40940(
+; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> <i32 1, i32 1, i32 2, i32 3>
+; CHECK-NEXT: [[T2:%.*]] = bitcast <4 x i8> [[SHUF]] to i32
+; CHECK-NEXT: [[T3:%.*]] = icmp ult i32 [[T2]], 65536
+; CHECK-NEXT: call void @llvm.assume(i1 [[T3]])
+; CHECK-NEXT: ret i32 [[T2]]
+;
+ %shuf = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 1, i32 1, i32 2, i32 3>
+ %t2 = bitcast <4 x i8> %shuf to i32
+ %t3 = icmp ult i32 %t2, 65536
+ call void @llvm.assume(i1 %t3)
+ ret i32 %t2
+}
+
declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.dbg.cu = !{!0}
OpenPOWER on IntegriCloud