]> gcc.gnu.org Git - gcc.git/commit
i386: Fix up @xorsign<mode>3_1 [PR102224]
authorJakub Jelinek <jakub@redhat.com>
Wed, 8 Sep 2021 09:25:31 +0000 (11:25 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 10 May 2022 08:14:27 +0000 (10:14 +0200)
commitc7b00fbc469bc9c0a486b48bc349dba13881241e
tree0ff4489bd89ab5651d3b8caeb3eb3d5411a4c6bf
parent059115826b61c6fb737fc6082a7ce5d4c725c503
i386: Fix up @xorsign<mode>3_1 [PR102224]

As the testcase shows, we miscompile @xorsign<mode>3_1 if both input
operands are in the same register, because the splitter overwrites op1
before with op1 & mask before using op0.

For dest = xorsign op0, op0 we can actually simplify it from
dest = (op0 & mask) ^ op0 to dest = op0 & ~mask (aka abs).

The expander change is an optimization improvement, if we at expansion
time know it is xorsign op0, op0, we can emit abs right away and get better
code through that.

The @xorsign<mode>3_1 is a fix for the case where xorsign wouldn't be known
to have same operands during expansion, but during RTL optimizations they
would appear.  We need to use earlyclobber, we require dest and op1 to be
the same but op0 must be different because we overwrite
op1 first.

2021-09-08  Jakub Jelinek  <jakub@redhat.com>

PR target/102224
* config/i386/i386.md (xorsign<mode>3): If operands[1] is equal to
operands[2], emit abs<mode>2 instead.
(@xorsign<mode>3_1): Add early-clobber for output operand.

* gcc.dg/pr102224.c: New test.
* gcc.target/i386/avx-pr102224.c: New test.

(cherry picked from commit a7b626d98a9a821ffb33466818d6aa86cac1d6fd)
gcc/config/i386/i386.md
gcc/testsuite/gcc.dg/pr102224.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-pr102224.c [new file with mode: 0644]
This page took 0.064634 seconds and 6 git commands to generate.