1
# DP: backport of trunk r204224
2
# DP: fixes ICE during building boost 1.54
4
# DP: PR rtl-optimization/58369
5
# DP: * reload1.c (compute_reload_subreg_offset): New function.
6
# DP: (choose_reload_regs): Use it to pass endian-correct
7
# DP: offset to subreg_regno_offset.
9
--- a/src/gcc/reload1.c
10
+++ b/src/gcc/reload1.c
11
@@ -6362,6 +6362,37 @@ replaced_subreg (rtx x)
15
+/* Compute the offset to pass to subreg_regno_offset, for a pseudo of
16
+ mode OUTERMODE that is available in a hard reg of mode INNERMODE.
17
+ SUBREG is non-NULL if the pseudo is a subreg whose reg is a pseudo,
18
+ otherwise it is NULL. */
21
+compute_reload_subreg_offset (enum machine_mode outermode,
23
+ enum machine_mode innermode)
26
+ enum machine_mode middlemode;
29
+ return subreg_lowpart_offset (outermode, innermode);
31
+ outer_offset = SUBREG_BYTE (subreg);
32
+ middlemode = GET_MODE (SUBREG_REG (subreg));
34
+ /* If SUBREG is paradoxical then return the normal lowpart offset
35
+ for OUTERMODE and INNERMODE. Our caller has already checked
36
+ that OUTERMODE fits in INNERMODE. */
37
+ if (outer_offset == 0
38
+ && GET_MODE_SIZE (outermode) > GET_MODE_SIZE (middlemode))
39
+ return subreg_lowpart_offset (outermode, innermode);
41
+ /* SUBREG is normal, but may not be lowpart; return OUTER_OFFSET
42
+ plus the normal lowpart offset for MIDDLEMODE and INNERMODE. */
43
+ return outer_offset + subreg_lowpart_offset (middlemode, innermode);
46
/* Assign hard reg targets for the pseudo-registers we must reload
47
into hard regs for this insn.
48
Also output the instructions to copy them in and out of the hard regs.
49
@@ -6499,6 +6530,7 @@ choose_reload_regs (struct insn_chain *c
52
enum machine_mode mode = VOIDmode;
53
+ rtx subreg = NULL_RTX;
57
@@ -6519,7 +6551,10 @@ choose_reload_regs (struct insn_chain *c
58
if (regno < FIRST_PSEUDO_REGISTER)
59
regno = subreg_regno (rld[r].in_reg);
61
- byte = SUBREG_BYTE (rld[r].in_reg);
63
+ subreg = rld[r].in_reg;
64
+ byte = SUBREG_BYTE (subreg);
66
mode = GET_MODE (rld[r].in_reg);
69
@@ -6557,6 +6592,9 @@ choose_reload_regs (struct insn_chain *c
70
rtx last_reg = reg_last_reload_reg[regno];
73
+ byte = compute_reload_subreg_offset (mode,
75
+ GET_MODE (last_reg));
76
i += subreg_regno_offset (i, GET_MODE (last_reg), byte, mode);
77
last_class = REGNO_REG_CLASS (i);