mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-22 10:16:43 +00:00
ScalarEvolution: do not set nuw when creating exprs of form <expr> + <all-ones>.
The nuw constraint will not be satisfied unless <expr> == 0. This bug has been around since r102234 (in 2010!), but was uncovered by r251052, which introduced more aggressive optimization of nuw scev expressions. Differential Revision: http://reviews.llvm.org/D14850 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253627 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
77072b3170
commit
5178bc957a
@ -7045,16 +7045,14 @@ bool ScalarEvolution::SimplifyICmpOperands(ICmpInst::Predicate &Pred,
|
|||||||
Pred = ICmpInst::ICMP_ULT;
|
Pred = ICmpInst::ICMP_ULT;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
} else if (!getUnsignedRange(LHS).getUnsignedMin().isMinValue()) {
|
} else if (!getUnsignedRange(LHS).getUnsignedMin().isMinValue()) {
|
||||||
LHS = getAddExpr(getConstant(RHS->getType(), (uint64_t)-1, true), LHS,
|
LHS = getAddExpr(getConstant(RHS->getType(), (uint64_t)-1, true), LHS);
|
||||||
SCEV::FlagNUW);
|
|
||||||
Pred = ICmpInst::ICMP_ULT;
|
Pred = ICmpInst::ICMP_ULT;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ICmpInst::ICMP_UGE:
|
case ICmpInst::ICMP_UGE:
|
||||||
if (!getUnsignedRange(RHS).getUnsignedMin().isMinValue()) {
|
if (!getUnsignedRange(RHS).getUnsignedMin().isMinValue()) {
|
||||||
RHS = getAddExpr(getConstant(RHS->getType(), (uint64_t)-1, true), RHS,
|
RHS = getAddExpr(getConstant(RHS->getType(), (uint64_t)-1, true), RHS);
|
||||||
SCEV::FlagNUW);
|
|
||||||
Pred = ICmpInst::ICMP_UGT;
|
Pred = ICmpInst::ICMP_UGT;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
} else if (!getUnsignedRange(LHS).getUnsignedMax().isMaxValue()) {
|
} else if (!getUnsignedRange(LHS).getUnsignedMax().isMaxValue()) {
|
||||||
|
49
test/Transforms/IndVarSimplify/zext-nuw.ll
Normal file
49
test/Transforms/IndVarSimplify/zext-nuw.ll
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
; RUN: opt -indvars -S %s | FileCheck %s
|
||||||
|
|
||||||
|
%struct.A = type { i8 }
|
||||||
|
|
||||||
|
@c = global %struct.A* null
|
||||||
|
@d = global i32 4
|
||||||
|
|
||||||
|
define void @_Z3fn1v() {
|
||||||
|
%x2 = load i32, i32* @d
|
||||||
|
%x3 = icmp slt i32 %x2, 1
|
||||||
|
%x4 = select i1 %x3, i32 1, i32 %x2
|
||||||
|
%x5 = load %struct.A*, %struct.A** @c
|
||||||
|
%j.sroa.0.0..sroa_idx = getelementptr %struct.A, %struct.A* %x5, i64 0, i32 0
|
||||||
|
%j.sroa.0.0.copyload = load i8, i8* %j.sroa.0.0..sroa_idx
|
||||||
|
br label %.preheader4.lr.ph
|
||||||
|
|
||||||
|
.preheader4.lr.ph: ; preds = %0
|
||||||
|
; CHECK-NOT: add i64 {{.*}}, 4294967296
|
||||||
|
br label %.preheader4
|
||||||
|
|
||||||
|
.preheader4: ; preds = %x22, %.preheader4.lr.ph
|
||||||
|
%k.09 = phi i8* [ undef, %.preheader4.lr.ph ], [ %x25, %x22 ]
|
||||||
|
%x8 = icmp ult i32 0, 4
|
||||||
|
br i1 %x8, label %.preheader.lr.ph, label %x22
|
||||||
|
|
||||||
|
.preheader.lr.ph: ; preds = %.preheader4
|
||||||
|
br label %.preheader
|
||||||
|
|
||||||
|
.preheader: ; preds = %x17, %.preheader.lr.ph
|
||||||
|
%k.17 = phi i8* [ %k.09, %.preheader.lr.ph ], [ %x19, %x17 ]
|
||||||
|
%v.06 = phi i32 [ 0, %.preheader.lr.ph ], [ %x20, %x17 ]
|
||||||
|
br label %x17
|
||||||
|
|
||||||
|
x17: ; preds = %.preheader
|
||||||
|
%x18 = sext i8 %j.sroa.0.0.copyload to i64
|
||||||
|
%x19 = getelementptr i8, i8* %k.17, i64 %x18
|
||||||
|
%x20 = add i32 %v.06, 1
|
||||||
|
%x21 = icmp ult i32 %x20, %x4
|
||||||
|
br i1 %x21, label %.preheader, label %._crit_edge.8
|
||||||
|
|
||||||
|
._crit_edge.8: ; preds = %x17
|
||||||
|
%split = phi i8* [ %x19, %x17 ]
|
||||||
|
br label %x22
|
||||||
|
|
||||||
|
x22: ; preds = %._crit_edge.8, %.preheader4
|
||||||
|
%k.1.lcssa = phi i8* [ %split, %._crit_edge.8 ], [ %k.09, %.preheader4 ]
|
||||||
|
%x25 = getelementptr i8, i8* %k.1.lcssa
|
||||||
|
br label %.preheader4
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user