From af421d9cf0a6cbc585e42af653a01619457ecc01 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 4 Jul 2011 23:04:54 +0200 Subject: [PATCH] re PR rtl-optimization/49619 (ICE in simplify_subreg, at simplify-rtx.c:5362) PR rtl-optimization/49619 * combine.c (combine_simplify_rtx): In PLUS -> IOR simplification pass VOIDmode as op0_mode to recursive call, and return temp even when different from tor, just if it is not IOR of the original PLUS arguments. * gcc.dg/pr49619.c: New test. From-SVN: r175825 --- gcc/ChangeLog | 6 ++++++ gcc/combine.c | 9 +++++++-- gcc/simplify-rtx.c | 4 ++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr49619.c | 13 +++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr49619.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 509efb8cea0..2c592b2671b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2011-07-04 Jakub Jelinek + PR rtl-optimization/49619 + * combine.c (combine_simplify_rtx): In PLUS -> IOR simplification + pass VOIDmode as op0_mode to recursive call, and return temp even + when different from tor, just if it is not IOR of the original + PLUS arguments. + PR rtl-optimization/49472 * simplify-rtx.c (simplify_unary_operation_1) : When negating MULT, negate the second operand instead of first. diff --git a/gcc/combine.c b/gcc/combine.c index 56fb44eaf42..ba35f280fcd 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -5681,12 +5681,17 @@ combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int in_dest, { /* Try to simplify the expression further. */ rtx tor = simplify_gen_binary (IOR, mode, XEXP (x, 0), XEXP (x, 1)); - temp = combine_simplify_rtx (tor, mode, in_dest, 0); + temp = combine_simplify_rtx (tor, VOIDmode, in_dest, 0); /* If we could, great. If not, do not go ahead with the IOR replacement, since PLUS appears in many special purpose address arithmetic instructions. */ - if (GET_CODE (temp) != CLOBBER && temp != tor) + if (GET_CODE (temp) != CLOBBER + && (GET_CODE (temp) != IOR + || ((XEXP (temp, 0) != XEXP (x, 0) + || XEXP (temp, 1) != XEXP (x, 1)) + && (XEXP (temp, 0) != XEXP (x, 1) + || XEXP (temp, 1) != XEXP (x, 0))))) return temp; } break; diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index bcd55b27fbc..5894f74257b 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1,7 +1,7 @@ /* RTL simplification functions for GNU compiler. Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, + 2011 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02c926afe94..fc7336a9d4d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-07-04 Jakub Jelinek + PR rtl-optimization/49619 + * gcc.dg/pr49619.c: New test. + PR rtl-optimization/49472 * gfortran.dg/pr49472.f90: New test. diff --git a/gcc/testsuite/gcc.dg/pr49619.c b/gcc/testsuite/gcc.dg/pr49619.c new file mode 100644 index 00000000000..d0a72a6edd1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr49619.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/49619 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-fre" } */ + +extern int a, b; + +void +foo (int x) +{ + a = 2; + b = 0; + b = (a && ((a = 1, 0 >= b) || (short) (x + (b & x)))); +} -- 2.30.2