http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55093
--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> 2012-10-29 02:31:44 UTC --- (In reply to comment #6) > I am testing this patch: > > diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c > index 2222d80..cbfbe7a 100644 > --- a/gcc/lra-eliminations.c > +++ b/gcc/lra-eliminations.c > @@ -272,7 +272,7 @@ get_elimination (rtx reg) > if ((hard_regno = REGNO (reg)) < 0 || hard_regno >= FIRST_PSEUDO_REGISTER) > return NULL; > if ((ep = elimination_map[hard_regno]) != NULL) > - return ep->from_rtx != reg ? NULL : ep; > + return ep->from != hard_regno ? NULL : ep; > if ((offset = self_elim_offsets[hard_regno]) == 0) > return NULL; > /* This is an iteration to restore offsets just after HARD_REGNO It doesn't solve all problems. I got Starting program: /export/build/gnu/gcc-x32-mx32-native-long/build-x86_64-linux/gcc/cc1 -fpreprocessed /tmp/bad.i -march=corei7-avx -mcx16 -msahf -mno-movbe -maes -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=generic -quiet -dumpbase bad.i -msse2 -mx32 -auxbase-strip O3-pr41881.s -O2 -O3 -version -fno-diagnostics-show-caret -ftree-vectorize -fno-vect-cost-model -fno-common -fdump-tree-vect-details -fno-ipa-cp-clone -o O3-pr41881.s GNU C (GCC) version 4.8.0 20121029 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20121029 (experimental), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C (GCC) version 4.8.0 20121029 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20121029 (experimental), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 8b8bc795ba054ad7d30608d02345517d Program received signal SIGSEGV, Segmentation fault. 0x0073eddb in dump_gimple_bb_header (outf=outf@entry=0x136dab0, bb=bb@entry=0xf6943380, indent=indent@entry=0, flags=flags@entry=469762568) at /export/gnu/import/git/gcc-misc/gcc/gimple-pretty-print.c:2097 2097 memset (s_indent, ' ', (size_t) indent); (gdb) p/x $rsp $6 = 0xffffffffffffc8b0 (gdb) When -maddress-mode=long is used to compile x32 GCC, Pmode is DImode and ptr_mode is SImode. LRA fails to properly handle ptr_mode != Pmode: 0x0073edb6 <+278>: lea -0x1(%rbx),%eax 0x0073edb9 <+281>: mov %ebx,%edx 0x0073edbb <+283>: mov $0x20,%esi 0x0073edc0 <+288>: add $0x2e,%rax 0x0073edc4 <+292>: shr $0x4,%rax 0x0073edc8 <+296>: shl $0x4,%rax 0x0073edcc <+300>: sub %rax,%rsp 0x0073edcf <+303>: lea 0x1f(%rsp),%r8 0x0073edd4 <+308>: and $0xffffffe0,%r8d 0x0073edd8 <+312>: mov %r8,%rdi => 0x0073eddb <+315>: callq 0x4a5970 <memset@plt>