On 2023/06/04 12:06, Jeff Law wrote:

On 6/3/23 17:03, Andrew Pinski via Gcc-patches wrote:
On Sat, Jun 3, 2023 at 3:53 PM Takayuki 'January June' Suwa via
Gcc-patches <[email protected]> wrote:

This patch optimizes both the boolean evaluation of and the branching of
EQ/NE against INT_MIN (-2147483648), by taking advantage of the specifi-
cation the ABS machine instruction on Xtensa returns INT_MIN iff INT_MIN,
otherwise non-negative value.

I wonder if this should be a generic expand improvement here.
You would definitely need to expand both ways and see if one is cost
more than the other.

There's probably some targets where this would be beneficial. Especially those 
with branch-on-bit capabilities.


Apologies for the late reply, as I was hesitant to comment because I don't
know of any way to make this optimization general (maybe add it to gcc/
match.pd?).

IMHO this optimization would make sense if there was an instruction to
calculate the absolute value of an integer register, and it wasn't possible
to directly compare the register with an immediate INT_MIN value, or if
assigning INT_MIN to a register was expensive.
And of course, it would also be required that the absolute value of INT_MIN
be INT_MIN without raising any exceptions (the Xtensa ISA's specification
makes it clear that this is true).

=====
[email protected]

Reply via email to