Commit 7e7e28c7 by Alexandre Oliva Committed by Alexandre Oliva

re PR rtl-optimization/30643 (CSE pessimization)

gcc/ChangeLog:
PR rtl-optimization/30643
* cse.c (cse_insn): Recompute dest_hash after insert_regs for
(fold_rtx): Recurse, like before 2006-11-03.
gcc/testsuite/ChangeLog:
PR rtl-optimization/30643
* gcc.dg/pr30643.c: New.

From-SVN: r122760
parent a009aafe
2007-03-09 Alexandre Oliva <aoliva@redhat.com>
PR rtl-optimization/30643
* cse.c (cse_insn): Recompute dest_hash after insert_regs for
(fold_rtx): Recurse, like before 2006-11-03.
2007-03-09 DJ Delorie <dj@redhat.com> 2007-03-09 DJ Delorie <dj@redhat.com>
* config/m32c/t-m32c (m32c-pragma.o): Add TM_H dependency to m32c-pragma.o * config/m32c/t-m32c (m32c-pragma.o): Add TM_H dependency to m32c-pragma.o
......
/* Common subexpression elimination for GNU compiler. /* Common subexpression elimination for GNU compiler.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998
1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -3045,11 +3046,37 @@ fold_rtx (rtx x, rtx insn) ...@@ -3045,11 +3046,37 @@ fold_rtx (rtx x, rtx insn)
{ {
rtx folded_arg = XEXP (x, i), const_arg; rtx folded_arg = XEXP (x, i), const_arg;
enum machine_mode mode_arg = GET_MODE (folded_arg); enum machine_mode mode_arg = GET_MODE (folded_arg);
switch (GET_CODE (folded_arg))
{
case MEM:
case REG:
case SUBREG:
const_arg = equiv_constant (folded_arg);
break;
case CONST:
case CONST_INT:
case SYMBOL_REF:
case LABEL_REF:
case CONST_DOUBLE:
case CONST_VECTOR:
const_arg = folded_arg;
break;
#ifdef HAVE_cc0 #ifdef HAVE_cc0
if (CC0_P (folded_arg)) case CC0:
folded_arg = prev_insn_cc0, mode_arg = prev_insn_cc0_mode; folded_arg = prev_insn_cc0;
mode_arg = prev_insn_cc0_mode;
const_arg = equiv_constant (folded_arg);
break;
#endif #endif
const_arg = equiv_constant (folded_arg);
default:
folded_arg = fold_rtx (folded_arg, insn);
const_arg = equiv_constant (folded_arg);
break;
}
/* For the first three operands, see if the operand /* For the first three operands, see if the operand
is constant or equivalent to a constant. */ is constant or equivalent to a constant. */
...@@ -5254,8 +5281,11 @@ cse_insn (rtx insn, rtx libcall_insn) ...@@ -5254,8 +5281,11 @@ cse_insn (rtx insn, rtx libcall_insn)
{ {
if (insert_regs (x, NULL, 0)) if (insert_regs (x, NULL, 0))
{ {
rtx dest = SET_DEST (sets[i].rtl);
rehash_using_reg (x); rehash_using_reg (x);
hash = HASH (x, mode); hash = HASH (x, mode);
sets[i].dest_hash = HASH (dest, GET_MODE (dest));
} }
elt = insert (x, NULL, hash, mode); elt = insert (x, NULL, hash, mode);
} }
......
2007-03-09 Alexandre Oliva <aoliva@redhat.com>
PR rtl-optimization/30643
* gcc.dg/pr30643.c: New.
2007-03-09 Chao-ying Fu <fu@mips.com> 2007-03-09 Chao-ying Fu <fu@mips.com>
* gcc.target/mips/mips32-dspr2-type.c: New test. * gcc.target/mips/mips32-dspr2-type.c: New test.
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-final { scan-assembler-not "undefined" } } */
/* Make sure we optimize all calls away. */
extern void undefined (void);
struct s { int a, b; };
void bar (struct s *ps, int *p, int *__restrict__ rp, int *__restrict__ rq)
{
ps->a = 0;
ps->b = 1;
if (ps->a != 0)
undefined ();
p[0] = 0;
p[1] = 1;
if (p[0] != 0)
undefined ();
rp[0] = 0;
rq[0] = 1;
if (rp[0] != 0)
undefined ();
}
int main (void) {
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment