[Bug rtl-optimization/48688] New: [x64]: shift/or instead of lea
piotr.wyderski at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 19 17:58:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48688
Summary: [x64]: shift/or instead of lea
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: piotr.wyderski@gmail.com
There is a missing optimization in expressions such as:
unsigned v = ...
r = (v << k) | m
where k and m are constants. GCC generates:
shl\sal $k, %rN
or $m, %rN
If the expression is replaced with:
r = (v << k) + m
GCC correctly folds it into a single lea:
lea m(,%rN, k), %rM
If k is small (on x86/x64 k = 1, 2, 4, 8) and m < (1 << k) then
both expressions are equivalent, but GCC does not notice that fact.
More information about the Gcc-bugs
mailing list