[llvm] r273521 - [SCCP] Don't assume all Constants are ConstantInt
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 22 17:14:30 PDT 2016
Author: majnemer
Date: Wed Jun 22 19:14:29 2016
New Revision: 273521
URL: http://llvm.org/viewvc/llvm-project?rev=273521&view=rev
Log:
[SCCP] Don't assume all Constants are ConstantInt
This fixes PR28269.
Modified:
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
llvm/trunk/test/Transforms/SCCP/undef-resolve.ll
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=273521&r1=273520&r2=273521&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Jun 22 19:14:29 2016
@@ -1419,10 +1419,10 @@ bool SCCPSolver::ResolvedUndefsIn(Functi
// Shifting by the bitwidth or more is undefined.
if (Op1LV.isConstant()) {
- auto *ShiftAmt = Op1LV.getConstantInt();
- if (ShiftAmt->getLimitedValue() >=
- ShiftAmt->getType()->getScalarSizeInBits())
- break;
+ if (auto *ShiftAmt = Op1LV.getConstantInt())
+ if (ShiftAmt->getLimitedValue() >=
+ ShiftAmt->getType()->getScalarSizeInBits())
+ break;
}
// undef >>a X -> all ones
@@ -1436,10 +1436,10 @@ bool SCCPSolver::ResolvedUndefsIn(Functi
// Shifting by the bitwidth or more is undefined.
if (Op1LV.isConstant()) {
- auto *ShiftAmt = Op1LV.getConstantInt();
- if (ShiftAmt->getLimitedValue() >=
- ShiftAmt->getType()->getScalarSizeInBits())
- break;
+ if (auto *ShiftAmt = Op1LV.getConstantInt())
+ if (ShiftAmt->getLimitedValue() >=
+ ShiftAmt->getType()->getScalarSizeInBits())
+ break;
}
// undef << X -> 0
Modified: llvm/trunk/test/Transforms/SCCP/undef-resolve.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/undef-resolve.ll?rev=273521&r1=273520&r2=273521&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SCCP/undef-resolve.ll (original)
+++ llvm/trunk/test/Transforms/SCCP/undef-resolve.ll Wed Jun 22 19:14:29 2016
@@ -170,3 +170,13 @@ entry:
; CHECK-LABEL: @test10(
; CHECK: ret i64 undef
}
+
+ at GV = external global i32
+
+define i32 @test11(i1 %tobool) {
+entry:
+ %shr4 = ashr i32 undef, zext (i1 icmp eq (i32* bitcast (i32 (i1)* @test11 to i32*), i32* @GV) to i32)
+ ret i32 %shr4
+; CHECK-LABEL: @test11(
+; CHECK: ret i32 -1
+}
More information about the llvm-commits
mailing list