mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[InstCombine] remove unneeded one-use checks for icmp fold
This fold and several others were added in: rL125734 ...with no explanation for the one-use checks other than the code comments about register pressure. Given that this is IR canonicalization, we shouldn't be worried about register pressure though; the backend should be able to adjust for that as needed. There are similar checks as noted with the TODO comments. I'm hoping to remove those restrictions too, but if any of these does cause a regression, it should be easier to correct by making small, individual commits. This is part of solving PR43310 the theoretically right way: https://bugs.llvm.org/show_bug.cgi?id=43310 ...ie, if we don't cripple basic transforms, then we won't need to add special-case code to detect larger patterns. llvm-svn: 371940
This commit is contained in:
parent
b3a2780d32
commit
e6fabd1382
@ -3695,6 +3695,7 @@ Instruction *InstCombiner::foldICmpBinOp(ICmpInst &I) {
|
||||
C == Op0 ? D : C);
|
||||
|
||||
// icmp (X+Y), (X+Z) -> icmp Y, Z for equalities or if there is no overflow.
|
||||
// TODO: The one-use checks should not be necessary.
|
||||
if (A && C && (A == C || A == D || B == C || B == D) && NoOp0WrapProblem &&
|
||||
NoOp1WrapProblem &&
|
||||
// Try not to increase register pressure.
|
||||
@ -3842,11 +3843,11 @@ Instruction *InstCombiner::foldICmpBinOp(ICmpInst &I) {
|
||||
return new ICmpInst(Pred, C, D);
|
||||
|
||||
// icmp (Y-X), (Z-X) -> icmp Y, Z for equalities or if there is no overflow.
|
||||
if (B && D && B == D && NoOp0WrapProblem && NoOp1WrapProblem &&
|
||||
// Try not to increase register pressure.
|
||||
BO0->hasOneUse() && BO1->hasOneUse())
|
||||
if (B && D && B == D && NoOp0WrapProblem && NoOp1WrapProblem)
|
||||
return new ICmpInst(Pred, A, C);
|
||||
|
||||
// icmp (X-Y), (X-Z) -> icmp Z, Y for equalities or if there is no overflow.
|
||||
// TODO: The one-use checks should not be necessary.
|
||||
if (A && C && A == C && NoOp0WrapProblem && NoOp1WrapProblem &&
|
||||
// Try not to increase register pressure.
|
||||
BO0->hasOneUse() && BO1->hasOneUse())
|
||||
|
@ -562,7 +562,7 @@ define i1 @test27_extra_uses(i32 %x, i32 %y, i32 %z) {
|
||||
; CHECK-NEXT: call void @foo(i32 [[LHS]])
|
||||
; CHECK-NEXT: [[RHS:%.*]] = sub nsw i32 [[Y:%.*]], [[Z]]
|
||||
; CHECK-NEXT: call void @foo(i32 [[RHS]])
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[LHS]], [[RHS]]
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[X]], [[Y]]
|
||||
; CHECK-NEXT: ret i1 [[C]]
|
||||
;
|
||||
%lhs = sub nsw i32 %x, %z
|
||||
@ -591,7 +591,7 @@ define i1 @test28_extra_uses(i32 %x, i32 %y, i32 %z) {
|
||||
; CHECK-NEXT: call void @foo(i32 [[LHS]])
|
||||
; CHECK-NEXT: [[RHS:%.*]] = sub nuw i32 [[Y:%.*]], [[Z]]
|
||||
; CHECK-NEXT: call void @foo(i32 [[RHS]])
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[LHS]], [[RHS]]
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[X]], [[Y]]
|
||||
; CHECK-NEXT: ret i1 [[C]]
|
||||
;
|
||||
%lhs = sub nuw i32 %x, %z
|
||||
|
Loading…
x
Reference in New Issue
Block a user