On 6/27/25 12:30 PM, Andrew Pinski wrote:


On Fri, Jun 27, 2025, 11:06 AM Raphael Moreira Zinsly <rzin...@ventanamicro.com <mailto:rzin...@ventanamicro.com>> wrote:

    Hi all,

    For targets that have expensive shifts this may not get a better
    sequence right now, specially for AVR and MSP430 according to
    our tests.
    Before I start looking for a fix on those targets I want to know
    if someone has any advise or other concerns with this transformation.


There is lshift_cheap_p to see if left shit is cheap but there is not one for right shift. Now doing `-(a<0)` is cheap but the secondary shift is the expensive in those cases. But maybe there is a decent way of selecting the a? CST0:CST1 right before expand might be a good idea.
I think we want to turn it into straightline code as early as possible *if* we can do so without regressing other targets and meet the gimple cost criteria. The latter is more complex in this case because we're dealing with conditional branches, so just counting expression evaluations isn't necessarily sufficient here.

There's a whole mess of cases where we can take advantage of splatting the sign bit across a GPR. Selecting across constants is a start, but not the end of the line. Consider a < 0 ? b : 0; That's just

t = a >> BITS_PER_WORD-1
res = t & b;


jeff

Reply via email to