-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| Bugzilla Link | 50425 |
| Version | trunk |
| OS | Linux |
| CC | @LebedevRI,@RKSimon,@rotateright |
Extended Description
I recently encountered a case where instcombine transform
icmp (A-B), (C-B) -> icmp A, C
affects simplifycfg ability to fold if-then into a select.
Here is test case:
; begin
target triple = "x86_64-unknown-linux-gnu"
define dso_local void @foo(i32* %p1, i32* %p2, i32 %g, i32 %gh) {
entry:
%i2 = load i32, i32* %p1, align 4
%sub17 = sub nsw i32 %i2, %gh
store i32 %sub17, i32* %p1, align 4
%i3 = load i32, i32* %p2, align 4
%i20 = add nsw i32 %i3, %g
%sub21 = sub nsw i32 %i20, %gh
%cmp24 = icmp slt i32 %sub17, %sub21
br i1 %cmp24, label %if.then25, label %if.end28
if.then25:
store i32 %sub21, i32* %p1, align 4
br label %if.end28
if.end28:
br label %end
end:
ret void
}
; end
To reproduce compare
opt -S -instcombine -simplifycfg test.ll
versus
opt -S -simplifycfg test.ll
At first glance it may appear as if instcombine sinking creates an issue for simplifycfg
but even with -instcombine-code-sinking=false option simplifycfg does not fold if-then: