[llvm] r269757 - [InstCombine] Don't crash when trying to take an element of a ConstantExpr.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Tue May 17 05:08:55 PDT 2016
Author: d0k
Date: Tue May 17 07:08:55 2016
New Revision: 269757
URL: http://llvm.org/viewvc/llvm-project?rev=269757&view=rev
Log:
[InstCombine] Don't crash when trying to take an element of a ConstantExpr.
Fixes PR27786.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/icmp-vec.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=269757&r1=269756&r2=269757&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue May 17 07:08:55 2016
@@ -3132,6 +3132,9 @@ static ICmpInst *canonicalizeCmpWithCons
unsigned NumElts = Op1Type->getVectorNumElements();
for (unsigned i = 0; i != NumElts; ++i) {
Constant *Elt = Op1C->getAggregateElement(i);
+ if (!Elt)
+ return nullptr;
+
if (isa<UndefValue>(Elt))
continue;
// Bail out if we can't determine if this constant is min/max or if we
Modified: llvm/trunk/test/Transforms/InstCombine/icmp-vec.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-vec.ll?rev=269757&r1=269756&r2=269757&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp-vec.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp-vec.ll Tue May 17 07:08:55 2016
@@ -181,3 +181,13 @@ define <2 x i1> @PR27756_2(<2 x i8> %a)
ret <2 x i1> %cmp
}
+ at someglobal = global i32 0
+
+define <2 x i1> @PR27786(<2 x i8> %a) {
+; CHECK-LABEL: @PR27786(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sle <2 x i8> %a, bitcast (i16 ptrtoint (i32* @someglobal to i16) to <2 x i8>)
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %cmp = icmp sle <2 x i8> %a, bitcast (i16 ptrtoint (i32* @someglobal to i16) to <2 x i8>)
+ ret <2 x i1> %cmp
+}
More information about the llvm-commits
mailing list