From d1fbf48566ae0ff14ea2b935cbf3cbbba40a6d28 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 23 Jun 2016 00:14:29 +0000 Subject: [PATCH] [SCCP] Don't assume all Constants are ConstantInt This fixes PR28269. llvm-svn: 273521 --- llvm/lib/Transforms/Scalar/SCCP.cpp | 16 ++++++++-------- llvm/test/Transforms/SCCP/undef-resolve.ll | 10 ++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 83f087f487ba..91e625b7aac8 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1419,10 +1419,10 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { // 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(Function &F) { // 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 diff --git a/llvm/test/Transforms/SCCP/undef-resolve.ll b/llvm/test/Transforms/SCCP/undef-resolve.ll index 2b40183c2cc5..fcfe3f573ea2 100644 --- a/llvm/test/Transforms/SCCP/undef-resolve.ll +++ b/llvm/test/Transforms/SCCP/undef-resolve.ll @@ -170,3 +170,13 @@ entry: ; CHECK-LABEL: @test10( ; CHECK: ret i64 undef } + +@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 +}