aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-05-29 19:00:35 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2009-05-29 19:00:35 +0200
commita0987204c590c4ae170268eb4e17c07925bb456c (patch)
tree40dc69a2e7fb164daa1ce5100f5aa441129080e1 /gcc/config
parent725fd454ae7e5a40356d5b27660b77d1bb6c55e9 (diff)
downloadgcc-a0987204c590c4ae170268eb4e17c07925bb456c.zip
gcc-a0987204c590c4ae170268eb4e17c07925bb456c.tar.gz
gcc-a0987204c590c4ae170268eb4e17c07925bb456c.tar.bz2
i386.c (ix86_decompose_address): Avoid useless 0 displacement.
* config/i386/i386.c (ix86_decompose_address): Avoid useless 0 displacement. Add 0 displacement if base is %[er]bp or %r13. From-SVN: r147982
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/i386/i386.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 26bb300..8a98334 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -8900,6 +8900,10 @@ ix86_decompose_address (rtx addr, struct ix86_address *out)
base_reg = base && GET_CODE (base) == SUBREG ? SUBREG_REG (base) : base;
index_reg = index && GET_CODE (index) == SUBREG ? SUBREG_REG (index) : index;
+ /* Avoid useless 0 displacement. */
+ if (disp == const0_rtx && (base || index))
+ disp = NULL_RTX;
+
/* Allow arg pointer and stack pointer as index if there is not scaling. */
if (base_reg && index_reg && scale == 1
&& (index_reg == arg_pointer_rtx
@@ -8911,10 +8915,16 @@ ix86_decompose_address (rtx addr, struct ix86_address *out)
tmp = base_reg, base_reg = index_reg, index_reg = tmp;
}
- /* Special case: %ebp cannot be encoded as a base without a displacement. */
- if ((base_reg == hard_frame_pointer_rtx
- || base_reg == frame_pointer_rtx
- || base_reg == arg_pointer_rtx) && !disp)
+ /* Special case: %ebp cannot be encoded as a base without a displacement.
+ Similarly %r13. */
+ if (!disp
+ && base_reg
+ && (base_reg == hard_frame_pointer_rtx
+ || base_reg == frame_pointer_rtx
+ || base_reg == arg_pointer_rtx
+ || (REG_P (base_reg)
+ && (REGNO (base_reg) == HARD_FRAME_POINTER_REGNUM
+ || REGNO (base_reg) == R13_REG))))
disp = const0_rtx;
/* Special case: on K6, [%esi] makes the instruction vector decoded.
@@ -8928,7 +8938,7 @@ ix86_decompose_address (rtx addr, struct ix86_address *out)
disp = const0_rtx;
/* Special case: encode reg+reg instead of reg*2. */
- if (!base && index && scale && scale == 2)
+ if (!base && index && scale == 2)
base = index, base_reg = index_reg, scale = 1;
/* Special case: scaling cannot be encoded without base or displacement. */