|
|
| Bugzilla Link |
8862 |
| Resolution |
FIXED |
| Resolved on |
Feb 09, 2011 23:39 |
| Version |
trunk |
| OS |
All |
| Blocks |
llvm/llvm-bugzilla-archive#8882 llvm/llvm-bugzilla-archive#8942 |
| CC |
@lattner,@sunfishcode |
Extended Description
Instcombine should compile this identity function to return X:
define i32 @test(i32 %X) {
%A = sdiv exact i32 %X, 4
%B = mul i32 %A, 4
ret i32 %B
}
instead we get:
define i32 @test(i32 %X) {
%A1 = and i32 %X, -4
ret i32 %A1
}
This is because it simplifies the sdiv into an ashr instruction, which loses information. This sort of thing comes up when handling array/pointer difference stuff.
To fix this, SDISel whould lower sdiv exact into ashr, instcombine should handle sdiv's as aggressively as ashr's, and then we should stop canonicalizing ashr to sdiv in instcombine.
Extended Description
Instcombine should compile this identity function to return X:
define i32 @test(i32 %X) {
%A = sdiv exact i32 %X, 4
%B = mul i32 %A, 4
ret i32 %B
}
instead we get:
define i32 @test(i32 %X) {
%A1 = and i32 %X, -4
ret i32 %A1
}
This is because it simplifies the sdiv into an ashr instruction, which loses information. This sort of thing comes up when handling array/pointer difference stuff.
To fix this, SDISel whould lower sdiv exact into ashr, instcombine should handle sdiv's as aggressively as ashr's, and then we should stop canonicalizing ashr to sdiv in instcombine.