Sometimes, GCC may synthesize an address like [index * 1 + displacement]. This
commit rewrites that into [base + displacement], to eliminate the requirement
of an SIB byte (which is always the case, as RSP isn't a valid index), and to
allow a small displacement to be encoded in one byte.
gcc/ChangeLog:
* config/i386/i386.cc (ix86_decompose_address): Add a special case where
there's no base, there's an index, and the scale is 1.
gcc/testsuite/ChangeLog:
* gcc.target/i386/rewrite-sib-without-base.c: New test.
Signed-off-by: LIU Hao <lh_mouse@126.com>
std::swap (base_reg, index_reg);
}
+ /* Special case: rewrite index*1+disp into base+disp. */
+ if (!base && index && scale == 1)
+ base = index, base_reg = index_reg, index = index_reg = NULL_RTX;
+
/* Special case: %ebp cannot be encoded as a base without a displacement.
Similarly %r13. */
if (!disp && base_reg
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -masm=att" } */
+/* { dg-final { scan-assembler-not "\\(,%" } } */
+
+_Complex a;
+_Complex int b;
+void c(void) { a = *(_Complex char *)__builtin_memset(&a, 1, 2) / b; }