On Thu, 9 May 2013, Jakub Jelinek wrote:

Hi!

The bit_rotate: code in fold-const.c handles only a subset of rotates,
and e.g. with C++ FE when sizeof isn't folded early fold_binary often
even isn't called with something that could recognize the rotate pattern,
even if bit_rotate: has been extended.  Furthermore, not all the rotate
patterns need to be written in a single statement.

So, this patch adds a rotate pattern recognizer into forwprop, and handles
several different patterns, the comment above the function shows which ones.

Nice :-)

Not in the patch, but defcodefor_name has this suspicious code:
          arg21 = gimple_assign_rhs2 (def);
          arg31 = gimple_assign_rhs2 (def);
good thing arg31 is ignored...

For the patterns with T2, I guess other optimizations will show the two (T2)X as the same SSA variable Z. I wonder if we could optimize instead:

((T) (Z << CNT1)) OP ((T) (Z >> CNT2))

to:

(T) Z r<< CNT1

and if by chance Z was (T2) X, the 2 casts would collapse in the next round. That might be a bit more generic (probably not very noticable), and the pattern a bit shorter.

--
Marc Glisse

Reply via email to