summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenlin Li <renlin.li@arm.com>2015-07-15 15:13:36 +0000
committerRenlin Li <renlin@gcc.gnu.org>2015-07-15 15:13:36 +0000
commit9a3e57325a094edf4ce9acf9ecb05d0bb09186ff (patch)
treeacebe8e5665412395f8fce762006e6b9515c7870
parent6789218b36157b4fc56977195ca56b08643185d8 (diff)
downloadgcc-9a3e57325a094edf4ce9acf9ecb05d0bb09186ff.tar.gz
[PATCH]Fix PR66556.
[PATCH]Fix PR66556. Don't drop side-effect in simplify_const_relational_operation function. gcc/ Backport from mainline. 2015-07-13 Renlin Li <renlin.li@arm.com> PR rtl/66556 * simplify-rtx.c (simplify_const_relational_operation): Add side_effects_p checks. gcc/testsuite/ Backport from mainline. 2015-07-13 Renlin Li <renlin.li@arm.com> PR rtl/66556 * gcc.c-torture/execute/pr66556.c: New. From-SVN: r225835
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/simplify-rtx.c7
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr66556.c52
4 files changed, 73 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7534e33f3e8..5582ec1fd7f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2015-07-15 Renlin Li <renlin.li@arm.com>
+
+ Backport from mainline.
+ 2015-07-13 Renlin Li <renlin.li@arm.com>
+
+ PR rtl/66556
+ * simplify-rtx.c (simplify_const_relational_operation): Add
+ side_effects_p checks.
+
2015-07-15 Thomas Schwinge <thomas@codesourcery.com>
Backport trunk r225560:
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 5d1749829bd..cdad71fa3f7 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -4928,7 +4928,8 @@ simplify_const_relational_operation (enum rtx_code code,
/* Optimize comparisons with upper and lower bounds. */
if (HWI_COMPUTABLE_MODE_P (mode)
- && CONST_INT_P (trueop1))
+ && CONST_INT_P (trueop1)
+ && !side_effects_p (trueop0))
{
int sign;
unsigned HOST_WIDE_INT nonzero = nonzero_bits (trueop0, mode);
@@ -5041,7 +5042,7 @@ simplify_const_relational_operation (enum rtx_code code,
}
/* Optimize integer comparisons with zero. */
- if (trueop1 == const0_rtx)
+ if (trueop1 == const0_rtx && !side_effects_p (trueop0))
{
/* Some addresses are known to be nonzero. We don't know
their sign, but equality comparisons are known. */
@@ -5092,7 +5093,7 @@ simplify_const_relational_operation (enum rtx_code code,
}
/* Optimize comparison of ABS with zero. */
- if (trueop1 == CONST0_RTX (mode)
+ if (trueop1 == CONST0_RTX (mode) && !side_effects_p (trueop0)
&& (GET_CODE (trueop0) == ABS
|| (GET_CODE (trueop0) == FLOAT_EXTEND
&& GET_CODE (XEXP (trueop0, 0)) == ABS)))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 55c140b645c..daf4501bf91 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2015-07-15 Renlin Li <renlin.li@arm.com>
+
+ Backport from mainline.
+ 2015-07-13 Renlin Li <renlin.li@arm.com>
+
+ PR rtl/66556
+ * gcc.c-torture/execute/pr66556.c: New.
+
2015-07-15 Thomas Schwinge <thomas@codesourcery.com>
Backport trunk r224028:
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr66556.c b/gcc/testsuite/gcc.c-torture/execute/pr66556.c
new file mode 100644
index 00000000000..f7acf1c03b0
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr66556.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+struct {
+ unsigned f2;
+ unsigned f3 : 15;
+ unsigned f5 : 3;
+ short f6;
+} b = {0x7f8000, 6, 5, 0}, g = {8, 0, 5, 0};
+
+short d, l;
+int a, c, h = 8;
+volatile char e[237] = {4};
+short *f = &d;
+short i[5] = {3};
+char j;
+int *k = &c;
+
+int
+fn1 (unsigned p1) { return -p1; }
+
+void
+fn2 (char p1)
+{
+ a = p1;
+ e[0];
+}
+
+short
+fn3 ()
+{
+ *k = 4;
+ return *f;
+}
+
+int
+main ()
+{
+
+ unsigned m;
+ short *n = &i[4];
+
+ m = fn1 ((h && j) <= b.f5);
+ l = m > g.f3;
+ *n = 3;
+ fn2 (b.f2 >> 15);
+ if ((a & 0xff) != 0xff)
+ abort ();
+
+ return 0;
+}