[llvm-branch-commits] [llvm-branch] r226193 - Merging r226075:
Hans Wennborg
hans at hanshq.net
Thu Jan 15 11:16:54 PST 2015
Author: hans
Date: Thu Jan 15 13:16:54 2015
New Revision: 226193
URL: http://llvm.org/viewvc/llvm-project?rev=226193&view=rev
Log:
Merging r226075:
------------------------------------------------------------------------
r226075 | sanjoy | 2015-01-14 17:46:09 -0800 (Wed, 14 Jan 2015) | 10 lines
Fix PR22222
The bug was introduced in r225282. r225282 assumed that sub X, Y is
the same as add X, -Y. This is not correct if we are going to upgrade
the sub to sub nuw. This change fixes the issue by making the
optimization ignore sub instructions.
Differential Revision: http://reviews.llvm.org/D6979
------------------------------------------------------------------------
Added:
llvm/branches/release_36/test/Transforms/IndVarSimplify/pr22222.ll
- copied unchanged from r226075, llvm/trunk/test/Transforms/IndVarSimplify/pr22222.ll
Modified:
llvm/branches/release_36/ (props changed)
llvm/branches/release_36/lib/Transforms/Utils/SimplifyIndVar.cpp
llvm/branches/release_36/test/Transforms/IndVarSimplify/strengthen-overflow.ll
Propchange: llvm/branches/release_36/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 15 13:16:54 2015
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,226023,226029,226044,226046,226048,226058
+/llvm/trunk:155241,226023,226029,226044,226046,226048,226058,226075
Modified: llvm/branches/release_36/lib/Transforms/Utils/SimplifyIndVar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/Transforms/Utils/SimplifyIndVar.cpp?rev=226193&r1=226192&r2=226193&view=diff
==============================================================================
--- llvm/branches/release_36/lib/Transforms/Utils/SimplifyIndVar.cpp (original)
+++ llvm/branches/release_36/lib/Transforms/Utils/SimplifyIndVar.cpp Thu Jan 15 13:16:54 2015
@@ -278,9 +278,8 @@ bool SimplifyIndvar::strengthenOverflowi
Value *IVOperand) {
// Currently we only handle instructions of the form "add <indvar> <value>"
- // and "sub <indvar> <value>".
unsigned Op = BO->getOpcode();
- if (!(Op == Instruction::Add || Op == Instruction::Sub))
+ if (Op != Instruction::Add)
return false;
// If BO is already both nuw and nsw then there is nothing left to do
@@ -304,15 +303,6 @@ bool SimplifyIndvar::strengthenOverflowi
if (OtherOpSCEV == SE->getCouldNotCompute())
return false;
- if (Op == Instruction::Sub) {
- // If the subtraction is of the form "sub <indvar>, <op>", then pretend it
- // is "add <indvar>, -<op>" and continue, else bail out.
- if (OtherOperandIdx != 1)
- return false;
-
- OtherOpSCEV = SE->getNegativeSCEV(OtherOpSCEV);
- }
-
const SCEV *IVOpSCEV = SE->getSCEV(IVOperand);
const SCEV *ZeroSCEV = SE->getConstant(IVOpSCEV->getType(), 0);
Modified: llvm/branches/release_36/test/Transforms/IndVarSimplify/strengthen-overflow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/test/Transforms/IndVarSimplify/strengthen-overflow.ll?rev=226193&r1=226192&r2=226193&view=diff
==============================================================================
--- llvm/branches/release_36/test/Transforms/IndVarSimplify/strengthen-overflow.ll (original)
+++ llvm/branches/release_36/test/Transforms/IndVarSimplify/strengthen-overflow.ll Thu Jan 15 13:16:54 2015
@@ -52,58 +52,6 @@ define i32 @test.signed.add.1(i32* %arra
ret i32 42
}
-define i32 @test.signed.sub.0(i32* %array, i32 %length, i32 %init) {
-; CHECK-LABEL: @test.signed.sub.0
- entry:
- %upper = icmp sgt i32 %init, %length
- br i1 %upper, label %loop, label %exit
-
- loop:
-; CHECK-LABEL: loop
- %civ = phi i32 [ %init, %entry ], [ %civ.inc, %latch ]
- %civ.inc = sub i32 %civ, 1
-; CHECK: %civ.inc = sub nsw i32 %civ, 1
- %cmp = icmp slt i32 %civ.inc, %length
- br i1 %cmp, label %latch, label %break
-
- latch:
- store i32 0, i32* %array
- %check = icmp sgt i32 %civ.inc, %length
- br i1 %check, label %loop, label %break
-
- break:
- ret i32 %civ.inc
-
- exit:
- ret i32 42
-}
-
-define i32 @test.signed.sub.1(i32* %array, i32 %length, i32 %init) {
-; CHECK-LABEL: @test.signed.sub.1
- entry:
- %upper = icmp sgt i32 %init, %length
- br i1 %upper, label %loop, label %exit
-
- loop:
-; CHECK-LABEL: loop
- %civ = phi i32 [ %init, %entry ], [ %civ.inc, %latch ]
- %civ.inc = sub i32 %civ, 1
-; CHECK: %civ.inc = sub i32 %civ, 1
- %cmp = icmp slt i32 %civ.inc, %length
- br i1 %cmp, label %latch, label %break
-
- latch:
- store i32 0, i32* %array
- %check = icmp sge i32 %civ.inc, %length
- br i1 %check, label %loop, label %break
-
- break:
- ret i32 %civ.inc
-
- exit:
- ret i32 42
-}
-
define i32 @test.unsigned.add.0(i32* %array, i32 %length, i32 %init) {
; CHECK-LABEL: @test.unsigned.add.0
entry:
@@ -144,60 +92,6 @@ define i32 @test.unsigned.add.1(i32* %ar
%cmp = icmp slt i32 %civ.inc, %length
br i1 %cmp, label %latch, label %break
- latch:
- store i32 0, i32* %array
- %check = icmp ult i32 %civ.inc, %length
- br i1 %check, label %loop, label %break
-
- break:
- ret i32 %civ.inc
-
- exit:
- ret i32 42
-}
-
-define i32 @test.unsigned.sub.0(i32* %array, i32* %length_ptr, i32 %init) {
-; CHECK-LABEL: @test.unsigned.sub.0
- entry:
- %length = load i32* %length_ptr, !range !0
- %upper = icmp ult i32 %init, %length
- br i1 %upper, label %loop, label %exit
-
- loop:
-; CHECK-LABEL: loop
- %civ = phi i32 [ %init, %entry ], [ %civ.inc, %latch ]
- %civ.inc = sub i32 %civ, 2
-; CHECK: %civ.inc = sub nuw i32 %civ, 2
- %cmp = icmp slt i32 %civ.inc, %length
- br i1 %cmp, label %latch, label %break
-
- latch:
- store i32 0, i32* %array
- %check = icmp ult i32 %civ.inc, %length
- br i1 %check, label %loop, label %break
-
- break:
- ret i32 %civ.inc
-
- exit:
- ret i32 42
-}
-
-define i32 @test.unsigned.sub.1(i32* %array, i32* %length_ptr, i32 %init) {
-; CHECK-LABEL: @test.unsigned.sub.1
- entry:
- %length = load i32* %length_ptr, !range !1
- %upper = icmp ult i32 %init, %length
- br i1 %upper, label %loop, label %exit
-
- loop:
-; CHECK-LABEL: loop
- %civ = phi i32 [ %init, %entry ], [ %civ.inc, %latch ]
- %civ.inc = sub i32 %civ, 2
-; CHECK: %civ.inc = sub i32 %civ, 2
- %cmp = icmp slt i32 %civ.inc, %length
- br i1 %cmp, label %latch, label %break
-
latch:
store i32 0, i32* %array
%check = icmp ult i32 %civ.inc, %length
More information about the llvm-branch-commits
mailing list