This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR optimization/8555 (was Re: GCC-3.2.2 pre-release (third iteration))
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 5 Feb 2003 00:31:28 +0100
- Subject: [PATCH] Fix PR optimization/8555 (was Re: GCC-3.2.2 pre-release (third iteration))
- References: <200302042105.WAA86533@numa6.igpm.rwth-aachen.de> <m3smv3equp.fsf@uniton.integrable-solutions.net>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Feb 04, 2003 at 09:24:46PM +0100, Gabriel Dos Reis wrote:
> Volker Reichelt <reichelt@igpm.rwth-aachen.de> writes:
>
> | Hi Gaby,
> |
> | I know it's a little late now, but I just stumbled over two PR's
> | (PR 8555 and PR 8766) that are regressions *on* the 3.2 branch and have
> | not been fixed yet.
>
> According to the audit trails, PR 8555 was introduced in 3.1 by a
> patch of Jakub's;
Well, I merely added an abort where the code would be likely miscompiled
(or just by pure luck work, as in PR 8555).
Anyway, the following patch seems to fix it.
If for some reason gcc doesn't optimize x = cond ? y : y; into x = y
before splitting, the splitter will do that.
On the testcase below, actually gcc 3.1 would compile it correctly,
because there was x = x < x ? x : x; and the horribly looking:
movss %xmm0, %xmm1
cmpless %xmm0, %xmm1
andps %xmm1, %xmm0
andnps %xmm0, %xmm1
orps %xmm1, %xmm0
is equivalent to clobbering %xmm1 and nothing else.
With the patch above, these 5 unneeded insns are gone.
Ok to commit (trunk, 3.3, 3.2)?
2003-02-04 Jakub Jelinek <jakub@redhat.com>
PR optimization/8555
* config/i386/i386.md (sse_mov?fcc split): Handle op2 == op3 case
instead of aborting.
* gcc.dg/20030204-1.c: New test.
--- gcc/config/i386/i386.md.jj 2003-01-27 16:23:36.000000000 -0500
+++ gcc/config/i386/i386.md 2003-02-04 17:48:21.000000000 -0500
@@ -16768,10 +16768,12 @@
(set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0)
(subreg:TI (match_dup 7) 0)))]
{
- /* If op2 == op3, op3 will be clobbered before it is used.
- This should be optimized out though. */
+ /* If op2 == op3, op3 would be clobbered before it is used. */
if (operands_match_p (operands[2], operands[3]))
- abort ();
+ {
+ emit_move_insn (operands[0], operands[2]);
+ DONE;
+ }
PUT_MODE (operands[1], GET_MODE (operands[0]));
if (operands_match_p (operands[0], operands[4]))
operands[6] = operands[4], operands[7] = operands[2];
--- gcc/testsuite/gcc.dg/20030204-1.c.jj 2003-02-04 18:16:12.000000000 -0500
+++ gcc/testsuite/gcc.dg/20030204-1.c 2003-02-04 18:17:25.000000000 -0500
@@ -0,0 +1,16 @@
+/* PR optimization/8555 */
+/* { dg-do compile } */
+/* { dg-options "-O -ffast-math -funroll-loops" } */
+/* { dg-options "-march=pentium3 -O -ffast-math -funroll-loops" { target i?86-*-* } } */
+
+float foo (float *a, int i)
+{
+ int j;
+ float x = a[j = i - 1], y;
+
+ for (j = i; --j >= 0; )
+ if ((y = a[j]) > x)
+ x = y;
+
+ return x;
+}
Jakub