On 5/19/2026 10:55 AM, Richard Biener wrote:
2^n-1 is interesting because there's a highly generic way to synthesize that 
sequence.  It's just two shifts.  So long as you have a barrel shifter, that's 
going to be pretty efficient. Arbitrary constants aren't as clear cut as you 
have to worry about whether or not the nonzero constant can be encoded by the 
target.

Granted we're in gimple, so one could make an argument that these are low level 
issues that aren't applicable.

The way I've generally encouraged folks to think about these transformations is 
to look at both gimple and RTL simplification.  I think in this case we were 
initially looking at the RTL side of things, then concluded the idea was sound 
for gimple without too much consideration for whether or not it ought to be 
generalized to more constants in gimple.
Ok, we’re not making such distinction elsewhere in GIMPLE and if it’s supposed 
to be a canpnicalization then it’s odd to do it only for special constants.  
And if it’s a target specific thing it belongs to RTL expansion or RTL ifvct.  
IMHO.
Yea, seems like the right general direction.  We've got some work to do in the expanders to more sensibly handle conditional moves on targets that don't have conditional move capabilities.   Raphael, Andrew and I have all poked around that problem without finding a great resolution.   There's a closely related problem in this space that we 're representing many conditional move idioms as multiply sequences.

Anyway, I think this probably all argues that we should see if we can handle the general case without regressions and if so, move it forward.  Otherwise we likely need to defer this until we fix the conditional move expansion issues.

Jeff

Reply via email to