[llvm-commits] [llvm] r131919 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/lsr-overflow.ll
Dan Gohman
gohman at apple.com
Mon May 23 14:07:39 PDT 2011
Author: djg
Date: Mon May 23 16:07:39 2011
New Revision: 131919
URL: http://llvm.org/viewvc/llvm-project?rev=131919&view=rev
Log:
When checking for signed multiplication overflow, watch out for INT_MIN and -1.
This fixes PR9845.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/trunk/test/CodeGen/X86/lsr-overflow.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=131919&r1=131918&r2=131919&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon May 23 16:07:39 2011
@@ -2522,6 +2522,8 @@
// Check that multiplying with the unfolded offset doesn't overflow.
if (F.UnfoldedOffset != 0) {
+ if (F.UnfoldedOffset == INT64_MIN && Factor == -1)
+ continue;
F.UnfoldedOffset = (uint64_t)F.UnfoldedOffset * Factor;
if (F.UnfoldedOffset / Factor != Base.UnfoldedOffset)
continue;
Modified: llvm/trunk/test/CodeGen/X86/lsr-overflow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-overflow.ll?rev=131919&r1=131918&r2=131919&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/lsr-overflow.ll (original)
+++ llvm/trunk/test/CodeGen/X86/lsr-overflow.ll Mon May 23 16:07:39 2011
@@ -25,3 +25,21 @@
%cmp = icmp eq i64 %indvar, 9223372036854775807
ret i1 %cmp
}
+
+define void @func_37() noreturn nounwind readonly {
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.inc8, %entry
+ %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.inc8 ]
+ %sub.i = add i64 undef, %indvar
+ %cmp.i = icmp eq i64 %sub.i, -9223372036854775808
+ br i1 undef, label %for.inc8, label %for.cond4
+
+for.cond4: ; preds = %for.cond4, %for.body
+ br label %for.cond4
+
+for.inc8: ; preds = %for.body
+ %indvar.next = add i64 %indvar, 1
+ br label %for.body
+}
More information about the llvm-commits
mailing list