S/390: Fix flogr RTX.
commit33f3393ab5cc809f2636cc3ce86b3032177c91b8
authorAndreas Krebbel <krebbel@linux.ibm.com>
Tue, 20 Nov 2018 16:19:54 +0000 (20 16:19 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Tue, 20 Nov 2018 16:19:54 +0000 (20 16:19 +0000)
tree844a5c7e059a1d38f8d2473cdc66764f66d73c76
parent84bfc7328990c247d74c6f6fde4320d11d4403db
S/390: Fix flogr RTX.

The flogr instruction uses a 64 bit register pair target operand.  In
the RTX we model this as a write to a TImode register.  Unfortunately
the RTX's being assigned to the two parts of the target operand were
swapped.  This is no problem if in the end the flogr instruction will
be emitted since the instruction still does what the clzdi expander
expects.  However, a problem arises when the RTX is used to optimize
CLZ for a constant input operand.  Even then it matters only if the
expression couldn't be folded on tree level already.

In the testcase this happened thanks to loop unrolling on RTL level.
The iteration variable is used as an argument to the clz
builtin. Due to the loop unrolling it becomes a constant and after
folding the broken RTX leads to a wrong assumption.

gcc/ChangeLog:

2018-11-20  Andreas Krebbel  <krebbel@linux.ibm.com>

* config/s390/s390.md ("clztidi2"): Swap the RTX's written to the
DImode parts of the target operand.

gcc/testsuite/ChangeLog:

2018-11-20  Andreas Krebbel  <krebbel@linux.ibm.com>

* gcc.target/s390/flogr-1.c: New test.

From-SVN: r266321
gcc/ChangeLog
gcc/config/s390/s390.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/flogr-1.c [new file with mode: 0644]