On Tue, Sep 02, 2025 at 10:36:52AM +0200, Richard Biener wrote:
> The recent change to vect_synth_mult_by_constant missed to handle
> the synth_shift_p case for alg_shift, so we still changed c * 4
> to c + c + c + c.

The reason for not handling alg_shift was that it expands (perhaps multiple
times) the accumulator rather than op.
Though, if alg[0] sets accumulator to op, then it does that, accumulator
is op.

I guess the question is, what exactly is problematic wrt the multiple uses,
I understand
  _1 = op + op;
  _2 = _1 + op;
  _3 = _2 + op;
is wrong, but what about
  _1 = op;
  _2 = _1 + _1;
  _3 = _2 + _2;
?
The reduction is then used just once (unless something optimizes it) and
only the temporaries are perhaps used multiple times.
If this is ok, perhaps instead of giving up we could simply force
op into a new SSA_NAME and use that in the code instead of the original
op.
If it is not and we can't use any temporaries multiple times, then perhaps
the current code is incorrect in more ways.

        Jakub

Reply via email to