On 11/11/20 3:55 AM, Jakub Jelinek via Gcc-patches wrote:
> On Wed, Nov 11, 2020 at 11:43:34AM +0100, Philipp Tomsich wrote:
>> The patch addresses this by disallowing that rule, if an exact power-of-2 is
>> seen as C1.  The reason why I would prefer to have this canonicalised the
>> same way the (X & C1) * C2 is canonicalised, is that cleaning this up during
>> combine is more difficult on some architectures that require multiple insns
>> to represent the shifted constant (i.e. C1 << C2).
> It is bad to have many exceptions for the canonicalization
> and it is unclear why exactly these were chosen, and it doesn't really deal
> with say:
> (x & 0xabcdef12ULL) << 13
> being less expensive on some targets than
> (x << 13) & (0xabcdef12ULL << 13).
> (x & 0x7ffff) << 3 vs. (x << 3) & 0x3ffff8 on the other side is a wash on
> many targets.
> As I said, it is better to decide which one is better before or during
> expansion based on target costs, sure, combine can't catch everything.

I think Jakub is hitting a key point here.  Gimple should canonicalize
on what is simpler from a gimple standpoint, not what is better for some
set of targets.   Target dependencies like this shouldn't be introduced
until expansion time.


Jeff


Reply via email to