@@ -12107,6 +12107,15 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
|| !ix86_legitimate_constant_p (Pmode, disp)))
/* Displacement is not constant. */
return false;
+ else if (TARGET_X32
+ && !base
+ && !index
+ && CONST_INT_P (disp)
+ && INTVAL (disp) < 0)
+ /* Since constant address in x32 is signed extended to 64bit,
+ negative displacement without base nor index is out of
+ range. */
+ return false;
else if (TARGET_64BIT
&& !x86_64_immediate_operand (disp, VOIDmode))
/* Displacement is out of range. */
new file mode 100644
@@ -0,0 +1,17 @@
+/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && { ! { ia32 } } } } } */
+/* { dg-options "-O2 -mx32" } */
+
+void test1() {
+ int* apic_tpr_addr = (int *)0xfee00080;
+ *apic_tpr_addr += 4;
+}
+void test2() {
+ volatile int* apic_tpr_addr = (int *)0xfee00080;
+ *apic_tpr_addr = 0;
+}
+void test3() {
+ volatile int* apic_tpr_addr = (int *)0x7fffffff;
+ *apic_tpr_addr = 0;
+}
+
+/* { dg-final { scan-assembler-not "-18874240" } } */