https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122769
--- Comment #9 from Jeffrey A. Law <law at gcc dot gnu.org> ---
The right solution is proper support for conditional zero idioms in ifcvt.cc.
I've hinted we have that here but that I'm terribly unhappy with the state of
that code, but could make it available for folks to take a stab at cleaning up.
This is originally from VRULL and I've got Phillip's OK to contribute, so we
can certainly beat on it if we feel it's salvagable.
So if we have a conditonal ior, xor, shift, rotate, add, subtract, etc we can
use czero to conditionally zero an operand, then do an unconditional ior, xor,
whatever. For this test we get:
slti a0,a0,0
czero.eqz a0,a3,a0
xor a0,a1,a0
These will usually (always?) be more efficient than the generalized
condititional move sequences, so we placed this routine before the generalized
conditional move support in ifcvt.cc.
I could even see extracting out the certain things that are fairly clean and
leaving behind things like extension and subreg support.
Anyway, bits attached.