Hi all,

This patch series aims to improve the use of conditional negate and conditional
invert instructions when if-converting code of the form:
x := test ? -a : a; or x := test ? ~a : a;
I'd like to generate something like:
x := a; if (test) x := -x; where the latter if-statement can be implemented
with a conditional negate instruction like CSNEG in aarch64 (or using 
conditional
execution in the arm backend).
For that I'd like to introcude two new optabs: negcc and notcc which correspond
to a conditional negate and a conditional bitwise-not operation respectively.
The first patch in the series adds the optabs and uses them in a new RTL
if-conversion function that performs the above transformation.

The second and third patches implement the new optabs for the aarch64 and arm
targets accordingly. They also contain the tests that show the places where
this code triggers.

This series has been bootstrapped and tested on arm, aarch64 and x86_64.
The new functionality is supposed to trigger only on arm and aarch64 for now,
though I hope implementing the new optabs for any target that supports
these kinds of instructions should not be too hard.

The code generation on arm and aarch64 looks objectively better where it
triggers i.e. more usage of the CSNEG and CSINV aarch64 instructions rather
with no bad side-effects. On arm this also seems to benefit from performing
this kind of if-conversion early on rather than waiting for the late
conditional execution pass to have a go.

Ok for trunk?

Thanks,
Kyrill

Reply via email to