Open Quuxplusone opened 12 years ago
Bugzilla Link | PR14173 |
Status | NEW |
Importance | P enhancement |
Reported by | Duncan Sands (baldrick@free.fr) |
Reported on | 2012-10-25 03:26:42 -0700 |
Last modified on | 2012-10-26 02:51:39 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | geek4civic@gmail.com, llvm-bugs@lists.llvm.org, pawel@32bitmicro.com, rafael@espindo.la |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Currently I'm leaning towards the following solution: instcombine pulls
expressions feeding a GEP offset through any sign extensions, as long as
it doesn't increase the number of sign extensions. This assumes that
multiplying in a pointer-sized integer (eg i64) is just as efficient as
multiplying in a smaller sized integer (eg i32). Is this true?
For example:
%m = mul nsw i32 %x, %y
%e = sext i32 %m to i64
GEP..., i64 %e
In this case pulling the mul through the sign extension would give
%xe = sext i32 %x to i64
%ye = sext i32 %y to i64
%m = mul nsw i64 %xe, %ye
GEP..., i64 %m
increasing the number of sign extensions, so wouldn't be done.
On the other hand consider
%m = mul nsw i32 %x, 42
%e = sext i32 %m to i64
GEP..., i64 %e
In this case pulling the mul through the sign extension would give
%xe = sext i32 %x to i64
%m = mul nsw i64 %xe, 42
GEP..., i64 %m
with no additional sign extensions, so would be considered good to go.