Open Quuxplusone opened 6 years ago
Bugzilla Link | PR38280 |
Status | NEW |
Importance | P enhancement |
Reported by | Fabian Giesen (fabian.giesen@epicgames.com) |
Reported on | 2018-07-23 14:15:50 -0700 |
Last modified on | 2019-10-05 01:50:20 -0700 |
Version | 6.0 |
Hardware | PC Windows NT |
CC | david.bolvansky@gmail.com, david.green@arm.com, florian_hahn@apple.com, hfinkel@anl.gov, lebedev.ri@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | PR40878 |
See also |
On a perhaps related note, the very simple example
(https://godbolt.org/g/MToVLm):
unsigned func(unsigned count)
{
while (count >= 32)
count -= 32;
return count;
}
Currently produces something like (thanks to indvarsimplify):
define i32 @test(i32 %size) {
entry:
%0 = xor i32 %size, -1
%1 = icmp ugt i32 %0, -32
%umax = select i1 %1, i32 %0, i32 -32
%2 = add i32 %umax, %size
%3 = add i32 %2, 32
%4 = and i32 %3, -32
%5 = sub i32 %size, %4
ret i32 %5
}
Which is really just:
https://rise4fun.com/Alive/lKL
define i32 @test(i32 %size) {
%0 = and i32 %size, 31
ret i32 %0
}
Maybe instcombine could fold it to just AND?