[llvm] r276345 - [InstSimplify] don't crash handling a pointer or aggregate type
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 14:56:01 PDT 2016
Author: spatel
Date: Thu Jul 21 16:56:00 2016
New Revision: 276345
URL: http://llvm.org/viewvc/llvm-project?rev=276345&view=rev
Log:
[InstSimplify] don't crash handling a pointer or aggregate type
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/select.ll
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=276345&r1=276344&r2=276345&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Jul 21 16:56:00 2016
@@ -3412,6 +3412,9 @@ static Value *simplifySelectWithFakeICmp
Value *FalseVal,
bool TrueWhenUnset) {
unsigned BitWidth = TrueVal->getType()->getScalarSizeInBits();
+ if (!BitWidth)
+ return nullptr;
+
APInt MinSignedValue;
Value *X;
if (match(CmpLHS, m_Trunc(m_Value(X))) && (X == TrueVal || X == FalseVal)) {
Modified: llvm/trunk/test/Transforms/InstSimplify/select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/select.ll?rev=276345&r1=276344&r2=276345&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/select.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/select.ll Thu Jul 21 16:56:00 2016
@@ -389,3 +389,16 @@ define i64 @select_icmp_x_and_8_ne_0_y64
ret i64 %and1.y
}
+; Don't crash on a pointer or aggregate type.
+
+define i32* @select_icmp_pointers(i32* %x, i32* %y) {
+; CHECK-LABEL: @select_icmp_pointers(
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32* %x, null
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32* %x, i32* %y
+; CHECK-NEXT: ret i32* [[SEL]]
+;
+ %cmp = icmp slt i32* %x, null
+ %sel = select i1 %cmp, i32* %x, i32* %y
+ ret i32* %sel
+}
+
More information about the llvm-commits
mailing list