-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillallvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passes
Description
| Bugzilla Link | 36240 |
| Version | trunk |
| OS | All |
| CC | @majnemer,@RKSimon |
Extended Description
define i1 @cmpdiv(i32 %x) {
%d = sdiv i32 1, %x
%c = icmp slt i32 %d, 0
ret i1 %c
}
$ opt -instcombine cmpsignbit.ll -S
define i1 @cmpdiv(i32 %x) {
%1 = add i32 %x, 1
%2 = icmp ult i32 %1, 3
%c1 = icmp slt i32 %x, 0
%c = and i1 %2, %c1
ret i1 %c
That's a weird way to write:
%c = icmp eq i32 %x, -1
Note that we don't do anything with this case:
define i1 @cmpdiv400(i32 %x) {
%d = sdiv i32 400, %x
%c = icmp slt i32 %d, 0
ret i1 %c
}
But we could turn this into a range check:
Name: sdiv400
%d = sdiv i32 400, %x
%c = icmp slt i32 %d, 0
=>
%c1 = icmp sge i32 %x, -400
%c2 = icmp slt i32 %x, 0
%c = and i1 %c1, %c2
https://rise4fun.com/Alive/cDM
...so whatever is trying to improve the 1st case could probably use generalizing and fixing.
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillallvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passes