diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-03-05 05:30:10 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-03-05 05:30:10 +0000 |
commit | d8ec06aea7d20f410649f4eb6a7b2b0038763dc2 (patch) | |
tree | de4b34ff716b008178e64a4f61f2f16beb5e517d | |
parent | 2d1d2e55836943e7c1b7210b5f158e5ae6ffac9e (diff) | |
download | gcc-d8ec06aea7d20f410649f4eb6a7b2b0038763dc2.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234001 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/postreload.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr69941.c | 30 |
4 files changed, 53 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 09a2714c06a..d5fd0d390b3 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 66f691b88d9..61c1ce8028e 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 3fb4fe1b6bc..d412efdd057 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 00000000000..f15d41a819f --- /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; +} |