[llvm] r200210 - Fix crasher introduced in r200203 and caught by a libc++ buildbot. Don't assume that getMulExpr returns a SCEVMulExpr, it may have simplified it to something else!
Nick Lewycky
nicholas at mxc.ca
Mon Jan 27 02:47:45 PST 2014
Author: nicholas
Date: Mon Jan 27 04:47:44 2014
New Revision: 200210
URL: http://llvm.org/viewvc/llvm-project?rev=200210&view=rev
Log:
Fix crasher introduced in r200203 and caught by a libc++ buildbot. Don't assume that getMulExpr returns a SCEVMulExpr, it may have simplified it to something else!
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/test/Analysis/ScalarEvolution/fold.ll
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=200210&r1=200209&r2=200210&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jan 27 04:47:44 2014
@@ -2292,7 +2292,9 @@ const SCEV *ScalarEvolution::getUDivExac
Operands.append(Mul->op_begin() + 1, Mul->op_end());
LHS = getMulExpr(Operands);
RHS = RHSCst;
- Mul = cast<SCEVMulExpr>(LHS);
+ Mul = dyn_cast<SCEVMulExpr>(LHS);
+ if (!Mul)
+ return getUDivExactExpr(LHS, RHS);
}
}
}
Modified: llvm/trunk/test/Analysis/ScalarEvolution/fold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/fold.ll?rev=200210&r1=200209&r2=200210&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/fold.ll (original)
+++ llvm/trunk/test/Analysis/ScalarEvolution/fold.ll Mon Jan 27 04:47:44 2014
@@ -77,3 +77,12 @@ define void @test5(i32 %i) {
; CHECK: --> (-2147483648 * (%i /u -2147483648))
ret void
}
+
+define void @test6(i8 %x) {
+; CHECK-LABEL: @test6
+ %A = zext i8 %x to i16
+ %B = shl nuw i16 %A, 8
+ %C = and i16 %B, -2048
+; CHECK: --> (2048 * ((zext i8 %x to i16) /u 8))
+ ret void
+}
More information about the llvm-commits
mailing list