https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80131

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
On Tue, 21 Mar 2017, segher at gcc dot gnu.org wrote:

> If we have  d = a << (b - c);  and  a << b  does not truncate in the
> original mode, write it as  d := (a << b) >> c;  instead (and then
> see if it is actually cheaper, as combine always does).

If b is not 31 (for shifts of 32-bit values), a << (b - c) may be valid 
for some negative values of c, where (a << b) >> c isn't valid for 
negative c (as C code, so doing such an optimization in such a case would 
depend on the semantics of the machine instructions available and 
associated RTL).

Reply via email to