RFR: 8281518: New optimization: convert "(x|y)-(x^y)" into "x&y" [v2]

John Rose john.r.rose at oracle.com
Fri Feb 11 01:05:04 UTC 2022


On 9 Feb 2022, at 8:38, Quan Anh Mai wrote:

>> For clarification, my idea is to look at GCC and clang's codebases to 
>> see if there is a more general way to achieve every transformation 
>> elegantly instead of naively matching every combination, which may 
>> mitigate the cost for each additional transformation.
>

Yes, that thought occurred to me as well.  It seems like we are on the 
verge of seeing dozens of identities like the currently proposed one, 
each with its own wad of hand-maintained optimizer code.  On balance it 
will make the optimizer harder to maintain.  That would be OK if it got 
us significant performance benefit, but surely it doesn’t.

What *would* get us benefit in a cost-effective way would be to take 
this optimization and several previous ones (and future ones) and 
refactor them into a single comprehensive analysis based on truth 
tables, which would normalize bitwise expressions up to some particular 
complexity (say, up to three input variables and up to depth 2, with 
variety of operators).  This is a minor research project, but (I think) 
a worthy one.

— John


More information about the hotspot-compiler-dev mailing list