https://bugs.llvm.org/show_bug.cgi?id=36240
Bug ID: 36240
Summary: [InstCombine] icmp with sdiv operand transformed
strangely
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: spatel+l...@rotateright.com
CC: llvm-bugs@lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs