aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Schmidt <bernds@redhat.com>2016-03-04 22:30:10 -0700
committerJeff Law <law@gcc.gnu.org>2016-03-04 22:30:10 -0700
commit201d49e91faff2a580e7e3efdf2458e5fe5a5bf9 (patch)
treede4b34ff716b008178e64a4f61f2f16beb5e517d
parent29b9828fa425602f306d28b7ede79b4b0ac2e6f7 (diff)
downloadgcc-201d49e91faff2a580e7e3efdf2458e5fe5a5bf9.zip
gcc-201d49e91faff2a580e7e3efdf2458e5fe5a5bf9.tar.gz
gcc-201d49e91faff2a580e7e3efdf2458e5fe5a5bf9.tar.bz2
re PR rtl-optimization/69941 (bogus zero_extend transformation in postreload on aarch64)
PR rtl-optimization/69941 * postreload.c (reload_combine_recognize_pattern): Ensure all uses of the reg share its mode. PR rtl-optimization/69941 * gcc.dg/torture/pr69941.c: New test. From-SVN: r234001
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/postreload.c18
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr69941.c30
4 files changed, 53 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 09a2714..d5fd0d3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-03-04 Bernd Schmidt <bschmidt@redhat.com>
+
+ PR rtl-optimization/69941
+ * postreload.c (reload_combine_recognize_pattern): Ensure all uses of
+ the reg share its mode.
+
2016-03-04 Jeff Law <law@redhat.com>
PR tree-optimization/69196
diff --git a/gcc/postreload.c b/gcc/postreload.c
index 66f691b..61c1ce8 100644
--- a/gcc/postreload.c
+++ b/gcc/postreload.c
@@ -1057,7 +1057,6 @@ static bool
reload_combine_recognize_pattern (rtx_insn *insn)
{
rtx set, reg, src;
- unsigned int regno;
set = single_set (insn);
if (set == NULL_RTX)
@@ -1068,7 +1067,20 @@ reload_combine_recognize_pattern (rtx_insn *insn)
if (!REG_P (reg) || REG_NREGS (reg) != 1)
return false;
- regno = REGNO (reg);
+ unsigned int regno = REGNO (reg);
+ machine_mode mode = GET_MODE (reg);
+
+ if (reg_state[regno].use_index < 0
+ || reg_state[regno].use_index >= RELOAD_COMBINE_MAX_USES)
+ return false;
+
+ for (int i = reg_state[regno].use_index;
+ i < RELOAD_COMBINE_MAX_USES; i++)
+ {
+ struct reg_use *use = reg_state[regno].reg_use + i;
+ if (GET_MODE (*use->usep) != mode)
+ return false;
+ }
/* Look for (set (REGX) (CONST_INT))
(set (REGX) (PLUS (REGX) (REGY)))
@@ -1090,8 +1102,6 @@ reload_combine_recognize_pattern (rtx_insn *insn)
&& REG_P (XEXP (src, 1))
&& rtx_equal_p (XEXP (src, 0), reg)
&& !rtx_equal_p (XEXP (src, 1), reg)
- && reg_state[regno].use_index >= 0
- && reg_state[regno].use_index < RELOAD_COMBINE_MAX_USES
&& last_label_ruid < reg_state[regno].use_ruid)
{
rtx base = XEXP (src, 1);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3fb4fe1..d412efd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2016-03-04 Bernd Schmidt <bschmidt@redhat.com>
+ PR rtl-optimization/69941
+ * gcc.dg/torture/pr69941.c: New test.
+
PR c/69824
* gcc.dg/pr69824.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr69941.c b/gcc/testsuite/gcc.dg/torture/pr69941.c
new file mode 100644
index 0000000..f15d41a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr69941.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+int a = 0;
+int b = 0;
+int c = 0;
+int e = 0;
+int f = 0;
+int *g = &e;
+
+int fn1() { return b ? a : b; }
+
+int main() {
+ int h = fn1() <= 0x8000000000000000ULL; // h = 1;
+
+ int k = f; // k = 0;
+
+ long i = h ? k : k / h; // i = 0;
+
+ long l = (unsigned short)(i - 0x1800); // l = 0xe800
+
+ i = l ? l : c; // i = 0xe800;
+
+ *g = i; // *g = 0xe800; e = 0xe800;
+
+ unsigned char result = e >> 9; // result = 0x74;
+
+ if ((int)result != 0x74)
+ __builtin_abort ();
+ return 0;
+}