aboutsummaryrefslogtreecommitdiff
path: root/gcc/postreload.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-01-23 20:08:22 +0100
committerJakub Jelinek <jakub@redhat.com>2020-01-23 20:08:22 +0100
commit32667e04c7153d97d09d81c1af073d400f0c719a (patch)
tree4ced83b6cceb8099b652aaad1cc3763029314ccb /gcc/postreload.c
parentc91072247eb066ec9c6cd0b0f949c7dae691e46c (diff)
downloadgcc-32667e04c7153d97d09d81c1af073d400f0c719a.zip
gcc-32667e04c7153d97d09d81c1af073d400f0c719a.tar.gz
gcc-32667e04c7153d97d09d81c1af073d400f0c719a.tar.bz2
postreload: Fix up postreload combine [PR93402]
The following testcase is miscompiled, because the postreload pass changes: -(insn 14 13 23 2 (parallel [ - (set (reg:DI 1 dx [94]) - (plus:DI (reg:DI 1 dx [95]) - (reg:DI 5 di [92]))) - (clobber (reg:CC 17 flags)) - ]) "pr93402.c":8:30 186 {*adddi_1} - (expr_list:REG_EQUAL (plus:DI (reg:DI 5 di [92]) - (const_int 111111111111 [0x19debd01c7])) - (nil))) -(insn 23 14 25 2 (set (reg:SI 0 ax) +(insn 23 13 25 2 (set (reg:SI 0 ax) (const_int 0 [0])) "pr93402.c":10:1 67 {*movsi_internal} (nil)) (insn 25 23 26 2 (use (reg:SI 0 ax)) "pr93402.c":10:1 -1 (nil)) -(insn 26 25 35 2 (use (reg:DI 1 dx)) "pr93402.c":10:1 -1 +(insn 26 25 35 2 (use (plus:DI (reg:DI 1 dx [95]) + (reg:DI 5 di [92]))) "pr93402.c":10:1 -1 (nil)) A USE insn is not a normal insn and verify_changes called from apply_change_group is happy about any changes into it. The following patch avoids this optimization if we were to change the USE operand (this routine only changes a reg into (plus reg reg2)). 2020-01-23 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/93402 * postreload.c (reload_combine_recognize_pattern): Don't try to adjust USE insns. * gcc.c-torture/execute/pr93402.c: New test.
Diffstat (limited to 'gcc/postreload.c')
-rw-r--r--gcc/postreload.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/postreload.c b/gcc/postreload.c
index b068326..7cd5c7f 100644
--- a/gcc/postreload.c
+++ b/gcc/postreload.c
@@ -1078,6 +1078,10 @@ reload_combine_recognize_pattern (rtx_insn *insn)
struct reg_use *use = reg_state[regno].reg_use + i;
if (GET_MODE (*use->usep) != mode)
return false;
+ /* Don't try to adjust (use (REGX)). */
+ if (GET_CODE (PATTERN (use->insn)) == USE
+ && &XEXP (PATTERN (use->insn), 0) == use->usep)
+ return false;
}
/* Look for (set (REGX) (CONST_INT))