-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| Bugzilla Link | 37636 |
| Version | trunk |
| OS | Windows NT |
| Reporter | LLVM Bugzilla Contributor |
| CC | @RKSimon,@rotateright |
Extended Description
Instcombine can sometimes produce a worse code when dealing with values annotated by ranges than if there was no range. Apparently it tries to replace sdiv with bit magic and it breaks some other pattern recognition.
Tests:
define i1 @good(i32* %A) {
%A.val = load i32, i32* %A, align 8
%B = sdiv i32 %A.val, 2
%C = icmp sge i32 0, %B
ret i1 %C
}
define i1 @bad(i32* %A) {
%A.val = load i32, i32* %A, align 8, !range !0
%B = sdiv i32 %A.val, 2
%C = icmp sge i32 0, %B
ret i1 %C
}
!0 = !{i32 0, i32 2147483647}
Run opt -instcombine -S
The result is:
define i1 @good(i32* %A) {
%A.val = load i32, i32* %A, align 8
%C = icmp slt i32 %A.val, 2
ret i1 %C
}
define i1 @bad(i32* %A) {
%A.val = load i32, i32* %A, align 8, !range !0
%B.mask = and i32 %A.val, 2147483646
%C = icmp eq i32 %B.mask, 0
ret i1 %C
}
!0 = !{i32 0, i32 2147483647}