aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2004-12-13 23:49:28 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2004-12-13 23:49:28 +0000
commit5ac20c1a831f603d5e46e3e2938f0bbf6c8b0423 (patch)
tree610abc1c82d439c98e13f70c11d153d2004220e4 /gcc
parent04482133da7cc90eb44c16e1abe6223e2014fc1e (diff)
downloadgcc-5ac20c1a831f603d5e46e3e2938f0bbf6c8b0423.zip
gcc-5ac20c1a831f603d5e46e3e2938f0bbf6c8b0423.tar.gz
gcc-5ac20c1a831f603d5e46e3e2938f0bbf6c8b0423.tar.bz2
re PR rtl-optimization/18928 (ice on valid code with -O2 -fPIC)
PR rtl-optimization/18928 * simplify_rtx.c (plus_minus_operand_p): New function to encode the test for suitable operands for calls to simplify_plus_minus. Only allow (CONST (PLUS x y)) if both x and y are CONSTANT_P. (simplify_binary_operation): Use plus_minus_operand_p. * gcc.dg/pr18928-1.c: New test case. From-SVN: r92109
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/simplify-rtx.c29
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr18928-1.c20
4 files changed, 50 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e12edaf..52699a0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-13 Roger Sayle <roger@eyesopen.com>
+
+ PR rtl-optimization/18928
+ * simplify_rtx.c (plus_minus_operand_p): New function to encode
+ the test for suitable operands for calls to simplify_plus_minus.
+ Only allow (CONST (PLUS x y)) if both x and y are CONSTANT_P.
+ (simplify_binary_operation): Use plus_minus_operand_p.
+
2004-12-13 Alexandre Oliva <aoliva@redhat.com>
PR tree-opt/16951
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 2ac5661..3685bbf 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -50,6 +50,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
((((HOST_WIDE_INT) low) < 0) ? ((HOST_WIDE_INT) -1) : ((HOST_WIDE_INT) 0))
static rtx neg_const_int (enum machine_mode, rtx);
+static bool plus_minus_operand_p (rtx);
static int simplify_plus_minus_op_data_cmp (const void *, const void *);
static rtx simplify_plus_minus (enum rtx_code, enum machine_mode, rtx,
rtx, int);
@@ -1567,12 +1568,8 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
and subtle programs can break if operations are associated. */
if (INTEGRAL_MODE_P (mode)
- && (GET_CODE (op0) == PLUS || GET_CODE (op0) == MINUS
- || GET_CODE (op1) == PLUS || GET_CODE (op1) == MINUS
- || (GET_CODE (op0) == CONST
- && GET_CODE (XEXP (op0, 0)) == PLUS)
- || (GET_CODE (op1) == CONST
- && GET_CODE (XEXP (op1, 0)) == PLUS))
+ && (plus_minus_operand_p (op0)
+ || plus_minus_operand_p (op1))
&& (tem = simplify_plus_minus (code, mode, op0, op1, 0)) != 0)
return tem;
@@ -1724,12 +1721,8 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
and subtle programs can break if operations are associated. */
if (INTEGRAL_MODE_P (mode)
- && (GET_CODE (op0) == PLUS || GET_CODE (op0) == MINUS
- || GET_CODE (op1) == PLUS || GET_CODE (op1) == MINUS
- || (GET_CODE (op0) == CONST
- && GET_CODE (XEXP (op0, 0)) == PLUS)
- || (GET_CODE (op1) == CONST
- && GET_CODE (XEXP (op1, 0)) == PLUS))
+ && (plus_minus_operand_p (op0)
+ || plus_minus_operand_p (op1))
&& (tem = simplify_plus_minus (code, mode, op0, op1, 0)) != 0)
return tem;
@@ -2677,6 +2670,18 @@ simplify_plus_minus (enum rtx_code code, enum machine_mode mode, rtx op0,
return result;
}
+/* Check whether an operand is suitable for calling simplify_plus_minus. */
+static bool
+plus_minus_operand_p (rtx x)
+{
+ return GET_CODE (x) == PLUS
+ || GET_CODE (x) == MINUS
+ || (GET_CODE (x) == CONST
+ && GET_CODE (XEXP (x, 0)) == PLUS
+ && CONSTANT_P (XEXP (XEXP (x, 0), 0))
+ && CONSTANT_P (XEXP (XEXP (x, 0), 1)));
+}
+
/* Like simplify_binary_operation except used for relational operators.
MODE is the mode of the result. If MODE is VOIDmode, both operands must
not also be VOIDmode.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 647411e..636869b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-13 Roger Sayle <roger@eyesopen.com>
+
+ PR rtl-optimization/18928
+ * gcc.dg/pr18928-1.c: New test case.
+
2004-12-13 Alexandre Oliva <aoliva@redhat.com>
PR tree-opt/16951
diff --git a/gcc/testsuite/gcc.dg/pr18928-1.c b/gcc/testsuite/gcc.dg/pr18928-1.c
new file mode 100644
index 0000000..3a0107d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr18928-1.c
@@ -0,0 +1,20 @@
+/* PR rtl-optimization/18928 */
+/* { dg-do compile { target i?86-*-linux* } } */
+/* { dg-options "-O2 -fPIC" } */
+
+const char *toHex( unsigned short u )
+{
+ static char hexVal[5];
+ int i = 3;
+ while ( i >= 0 ) {
+ unsigned short hex = (u & 0x000f);
+ if ( hex < 0x0a )
+ hexVal[i] = '0'+hex;
+ else
+ hexVal[i] = 'A'+(hex-0x0a);
+ i--;
+ }
+ hexVal[4] = '\0';
+ return hexVal;
+}
+