This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][4.0] Fix PR23326
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: pinskia at gcc dot gnu dot org
- Date: Fri, 12 Aug 2005 12:56:11 +0200 (CEST)
- Subject: [PATCH][4.0] Fix PR23326
Joint work fixed a forwprop bug where we happened to transform
!x != y into x == 0 (!)
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for branch? (Andrew, would you care comitting it, as I'm
off for vacancy the next week)
Thanks,
Richard.
2005-08-12 Richard Guenther <rguenther@suse.de>
Andrew Pinski <pinskia@gcc.gnu.org>
Serge Belyshev <belyshev@depni.sinp.msu.ru>
PR tree-optimization/23326
* tree-ssa-forwprop.c (substitute_single_use_vars): Only
do transformation if valid.
* g++.dg/tree-ssa/pr23326.C: New testcase.
Index: tree-ssa-forwprop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-forwprop.c,v
retrieving revision 2.11
diff -c -3 -p -r2.11 tree-ssa-forwprop.c
*** tree-ssa-forwprop.c 17 Feb 2005 22:41:32 -0000 2.11
--- tree-ssa-forwprop.c 12 Aug 2005 09:54:11 -0000
*************** substitute_single_use_vars (varray_type
*** 425,430 ****
--- 425,436 ----
/* TEST_VAR was set from a TRUTH_NOT_EXPR or a NOP_EXPR. */
if (def_rhs_code == TRUTH_NOT_EXPR)
invert = true;
+
+ /* If we don't have <NE_EXPR/EQ_EXPR x INT_CST>, then we cannot
+ optimize this case. */
+ if ((cond_code == NE_EXPR || cond_code == EQ_EXPR)
+ && TREE_CODE (TREE_OPERAND (cond, 1)) != INTEGER_CST)
+ continue;
if (cond_code == SSA_NAME
|| (cond_code == NE_EXPR
/* { dg-do run } */
/* { dg-options "-O2" } */
extern "C" void abort (void);
int j;
void foo (bool x, bool y)
{
if (!x)
j = 0;
if (!x == y)
j = 1;
}
int main (void)
{
foo (1, 1);
if (j)
abort ();
return 0;
}