Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit c6b1a7e

Browse files
author
Chad Rosier
committed
[IndVarSimplify] Partially revert r217953 to see if this fixes the bots.
Specifically, disable widening of unsigned compare instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217962 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0a277ea commit c6b1a7e

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

lib/Transforms/Scalar/IndVarSimplify.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,10 @@ bool WidenIV::WidenLoopCompare(NarrowIVDefUse DU) {
936936
if (!Cmp)
937937
return false;
938938

939+
bool IsSigned = CmpInst::isSigned(Cmp->getPredicate());
940+
if (!IsSigned)
941+
return false;
942+
939943
Value *Op = Cmp->getOperand(Cmp->getOperand(0) == DU.NarrowDef ? 1 : 0);
940944
unsigned CastWidth = SE->getTypeSizeInBits(Op->getType());
941945
unsigned IVWidth = SE->getTypeSizeInBits(WideType);
@@ -947,7 +951,6 @@ bool WidenIV::WidenLoopCompare(NarrowIVDefUse DU) {
947951

948952
// Widen the other operand of the compare, if necessary.
949953
if (CastWidth < IVWidth) {
950-
bool IsSigned = CmpInst::isSigned(Cmp->getPredicate());
951954
Value *ExtOp = getExtend(Op, WideType, IsSigned, Cmp);
952955
DU.NarrowUse->replaceUsesOfWith(Op, ExtOp);
953956
}

test/Transforms/IndVarSimplify/widen-loop-comp.ll

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -136,31 +136,3 @@ for.body:
136136
for.end:
137137
ret i32 %sum.0
138138
}
139-
140-
; CHECK-LABEL: @test4
141-
; CHECK: zext i32 %b
142-
; CHECK: for.cond:
143-
; CHECK: phi i64
144-
; CHECK: icmp ule i64
145-
146-
define i32 @test4(i32* %a, i32 %b) {
147-
entry:
148-
br label %for.cond
149-
150-
for.cond:
151-
%sum.0 = phi i32 [ 0, %entry ], [ %add, %for.body ]
152-
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
153-
%cmp = icmp ule i32 %i.0, %b
154-
br i1 %cmp, label %for.body, label %for.end
155-
156-
for.body:
157-
%idxprom = sext i32 %i.0 to i64
158-
%arrayidx = getelementptr inbounds i32* %a, i64 %idxprom
159-
%0 = load i32* %arrayidx, align 4
160-
%add = add nsw i32 %sum.0, %0
161-
%inc = add nsw i32 %i.0, 1
162-
br label %for.cond
163-
164-
for.end:
165-
ret i32 %sum.0
166-
}

0 commit comments

Comments
 (0)