-
Notifications
You must be signed in to change notification settings - Fork 16.5k
Description
| Bugzilla Link | 48390 |
| Resolution | FIXED |
| Resolved on | Dec 14, 2020 14:14 |
| Version | trunk |
| OS | All |
| Blocks | #47144 |
| CC | @DMG862,@LebedevRI,@RKSimon,@nikic,@rotateright,@tstellar |
| Fixed by commit(s) | f16320b e6f2a79 934376d 8511a8d |
Extended Description
$ cat >bad.ll <<EOL
define i32 @src(i32 %x1, i32 %x2) {
%x14 = add i32 %x1, %x2
%x6 = icmp ugt i32 %x14, %x2
%x9 = select i1 %x6, i32 %x14, i32 -1
ret i32 %x9
}
EOL
$ opt bad.ll --instcombine -S
; ModuleID = 'bad.ll'
source_filename = "bad.ll"
define i32 @src(i32 %x1, i32 %x2) {
%1 = call i32 @llvm.uadd.sat.i32(i32 %x2, i32 %x1)
ret i32 %1
}
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare i32 @llvm.uadd.sat.i32(i32, i32) #0
attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }
Alive output:
define i32 @src(i32 %x1, i32 %x2) {
%0:
%x14 = add i32 %x1, %x2
%x6 = icmp ugt i32 %x14, %x2
%x9 = select i1 %x6, i32 %x14, i32 4294967295
ret i32 %x9
}
=>
define i32 @tgt(i32 %x1, i32 %x2) {
%0:
%1 = uadd_sat i32 %x2, %x1
ret i32 %1
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
i32 %x1 = #x00000000 (0)
i32 %x2 = #x04000000 (67108864)
Source:
i32 %x14 = #x04000000 (67108864)
i1 %x6 = #x0 (0)
i32 %x9 = #xffffffff (4294967295, -1)
Target:
i32 %1 = #x04000000 (67108864)
Source value: #xffffffff (4294967295, -1)
Target value: #x04000000 (67108864)