Commit 3e322b3f by Jiong Wang

[AArch64][1/2] Fix offset glitch in load reg pair pattern

on aarch64, we are using load register pair post-writeback instruction in
epilogue.

for example, for the following instruction:

ldp, x0, x1, [sp], #16

what it's doing is:

x0 <- MEM(sp + 0)
x1 <- MEM(sp + 8)
sp < sp + 16

while there is a glitch in our loadwb_pair* pattern, the restore of the
first reg should always be with offset zero.

(set (match_operand:GPI 2 "register_operand" "=r")
-          (mem:GPI (plus:P (match_dup 1)
-                   (match_dup 4))))
+          (mem:GPI (match_dup 1)))

gcc/
  * config/aarch64/aarch64.md (loadwb_pair<GPI:mode>_<P:mode>): Fix offset.
  (loadwb_pair<GPI:mode>_<P:mode>): Likewise.
  * config/aarch64/aarch64.c (aarch64_gen_loadwb_pair): Likewise.

From-SVN: r213485
parent fb01ed38
...@@ -2006,10 +2006,10 @@ aarch64_gen_loadwb_pair (enum machine_mode mode, rtx base, rtx reg, rtx reg2, ...@@ -2006,10 +2006,10 @@ aarch64_gen_loadwb_pair (enum machine_mode mode, rtx base, rtx reg, rtx reg2,
{ {
case DImode: case DImode:
return gen_loadwb_pairdi_di (base, base, reg, reg2, GEN_INT (adjustment), return gen_loadwb_pairdi_di (base, base, reg, reg2, GEN_INT (adjustment),
GEN_INT (adjustment + UNITS_PER_WORD)); GEN_INT (UNITS_PER_WORD));
case DFmode: case DFmode:
return gen_loadwb_pairdf_di (base, base, reg, reg2, GEN_INT (adjustment), return gen_loadwb_pairdf_di (base, base, reg, reg2, GEN_INT (adjustment),
GEN_INT (adjustment + UNITS_PER_WORD)); GEN_INT (UNITS_PER_WORD));
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
......
...@@ -1016,20 +1016,19 @@ ...@@ -1016,20 +1016,19 @@
[(set_attr "type" "neon_store1_2reg<q>")] [(set_attr "type" "neon_store1_2reg<q>")]
) )
;; Load pair with writeback. This is primarily used in function epilogues ;; Load pair with post-index writeback. This is primarily used in function
;; when restoring [fp,lr] ;; epilogues.
(define_insn "loadwb_pair<GPI:mode>_<P:mode>" (define_insn "loadwb_pair<GPI:mode>_<P:mode>"
[(parallel [(parallel
[(set (match_operand:P 0 "register_operand" "=k") [(set (match_operand:P 0 "register_operand" "=k")
(plus:P (match_operand:P 1 "register_operand" "0") (plus:P (match_operand:P 1 "register_operand" "0")
(match_operand:P 4 "const_int_operand" "n"))) (match_operand:P 4 "const_int_operand" "n")))
(set (match_operand:GPI 2 "register_operand" "=r") (set (match_operand:GPI 2 "register_operand" "=r")
(mem:GPI (plus:P (match_dup 1) (mem:GPI (match_dup 1)))
(match_dup 4))))
(set (match_operand:GPI 3 "register_operand" "=r") (set (match_operand:GPI 3 "register_operand" "=r")
(mem:GPI (plus:P (match_dup 1) (mem:GPI (plus:P (match_dup 1)
(match_operand:P 5 "const_int_operand" "n"))))])] (match_operand:P 5 "const_int_operand" "n"))))])]
"INTVAL (operands[5]) == INTVAL (operands[4]) + GET_MODE_SIZE (<GPI:MODE>mode)" "INTVAL (operands[5]) == GET_MODE_SIZE (<GPI:MODE>mode)"
"ldp\\t%<w>2, %<w>3, [%1], %4" "ldp\\t%<w>2, %<w>3, [%1], %4"
[(set_attr "type" "load2")] [(set_attr "type" "load2")]
) )
...@@ -1040,18 +1039,17 @@ ...@@ -1040,18 +1039,17 @@
(plus:P (match_operand:P 1 "register_operand" "0") (plus:P (match_operand:P 1 "register_operand" "0")
(match_operand:P 4 "const_int_operand" "n"))) (match_operand:P 4 "const_int_operand" "n")))
(set (match_operand:GPF 2 "register_operand" "=w") (set (match_operand:GPF 2 "register_operand" "=w")
(mem:GPF (plus:P (match_dup 1) (mem:GPF (match_dup 1)))
(match_dup 4))))
(set (match_operand:GPF 3 "register_operand" "=w") (set (match_operand:GPF 3 "register_operand" "=w")
(mem:GPF (plus:P (match_dup 1) (mem:GPF (plus:P (match_dup 1)
(match_operand:P 5 "const_int_operand" "n"))))])] (match_operand:P 5 "const_int_operand" "n"))))])]
"INTVAL (operands[5]) == INTVAL (operands[4]) + GET_MODE_SIZE (<GPF:MODE>mode)" "INTVAL (operands[5]) == GET_MODE_SIZE (<GPF:MODE>mode)"
"ldp\\t%<w>2, %<w>3, [%1], %4" "ldp\\t%<w>2, %<w>3, [%1], %4"
[(set_attr "type" "neon_load1_2reg")] [(set_attr "type" "neon_load1_2reg")]
) )
;; Store pair with writeback. This is primarily used in function prologues ;; Store pair with pre-index writeback. This is primarily used in function
;; when saving [fp,lr] ;; prologues.
(define_insn "storewb_pair<GPI:mode>_<P:mode>" (define_insn "storewb_pair<GPI:mode>_<P:mode>"
[(parallel [(parallel
[(set (match_operand:P 0 "register_operand" "=&k") [(set (match_operand:P 0 "register_operand" "=&k")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment