diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index e41a1ad..7b9c5c7 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -1614,7 +1614,8 @@ bool WidenIV::widenLoopCompare(WidenIV::NarrowIVDefUse DU) { // (A) == icmp slt i32 sext(%narrow), sext(%val) // == icmp slt i32 zext(%narrow), sext(%val) bool IsSigned = getExtendKind(DU.NarrowDef) == ExtendKind::Sign; - if (!(DU.NeverNegative || IsSigned == Cmp->isSigned())) + bool CmpPreferredSign = Cmp->hasSameSign() ? IsSigned : Cmp->isSigned(); + if (!DU.NeverNegative && IsSigned != CmpPreferredSign) return false; Value *Op = Cmp->getOperand(Cmp->getOperand(0) == DU.NarrowDef ? 1 : 0); @@ -1627,7 +1628,7 @@ bool WidenIV::widenLoopCompare(WidenIV::NarrowIVDefUse DU) { // Widen the other operand of the compare, if necessary. if (CastWidth < IVWidth) { - Value *ExtOp = createExtendInst(Op, WideType, Cmp->isSigned(), Cmp); + Value *ExtOp = createExtendInst(Op, WideType, CmpPreferredSign, Cmp); DU.NarrowUse->replaceUsesOfWith(Op, ExtOp); } return true; |