This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RTL alias analysis
- From: Steven Bosscher <steven dot bosscher at gmail dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Jan Hubicka <jh at suse dot cz>, Mark Mitchell <mark at codesourcery dot com>, gcc at gcc dot gnu dot org
- Date: Sun, 1 Jan 2006 18:21:48 +0100
- Subject: RTL alias analysis
- References: <200512292242.17272.stevenb@suse.de> <200512292353.31258.stevenb@suse.de> <20051229225838.GE11833@kam.mff.cuni.cz> <200512300015.09257.stevenb@suse.de>
Hi rth,
The stack space sharing you added to cfgexpand.c breaks RTL alias
analysis.
For example, the attached test case breaks for pentiumpro at -O2.
The problem apparently is that the second store to c is moved up
before before the load.
This looks like a serious problem to me...
Many thanks to Honza for crafting this test case.
Gr.
Steven
extern void abort (void) __attribute__((noreturn));
union setconflict
{
short a[20];
int b[10];
};
int
main ()
{
int sum = 0;
{
union setconflict a;
short *c;
c = a.a;
asm ("": "=r" (c):"0" (c));
*c = 0;
asm ("": "=r" (c):"0" (c));
sum += *c;
}
{
union setconflict a;
int *c;
c = a.b;
asm ("": "=r" (c):"0" (c));
*c = 1;
asm ("": "=r" (c):"0" (c));
sum += *c;
}
printf ("%d\n",sum);
if (sum != 1)
abort();
return 0;
}
.file "t.c"
# GNU C version 4.2.0 20060101 (experimental) (x86_64-unknown-linux-gnu)
# compiled by GNU C version 4.0.2 20050901 (prerelease) (SUSE Linux).
# GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
# options passed: -iprefix -isystem -m32 -march=pentiumpro -auxbase -O2
# -fdump-tree-vars -fomit-frame-pointer -fverbose-asm
# options enabled: -falign-loops -fargument-alias -fbranch-count-reg
# -fcaller-saves -fcommon -fcprop-registers -fcrossjumping
# -fcse-follow-jumps -fcse-skip-blocks -fdefer-pop
# -fdelete-null-pointer-checks -fearly-inlining
# -feliminate-unused-debug-types -fexpensive-optimizations -ffunction-cse
# -fgcse -fgcse-lm -fguess-branch-probability -fident -fif-conversion
# -fif-conversion2 -finline-functions-called-once -fipa-pure-const
# -fipa-reference -fipa-type-escape -fivopts -fkeep-static-consts
# -fleading-underscore -floop-optimize -floop-optimize2 -fmath-errno
# -fmerge-constants -fomit-frame-pointer -foptimize-register-move
# -foptimize-sibling-calls -fpcc-struct-return -fpeephole -fpeephole2
# -fregmove -freorder-blocks -freorder-functions -frerun-cse-after-loop
# -frerun-loop-opt -fsched-interblock -fsched-spec
# -fsched-stalled-insns-dep -fschedule-insns2 -fshow-column
# -fsplit-ivs-in-unroller -fstrength-reduce -fstrict-aliasing
# -fthread-jumps -ftrapping-math -ftree-ccp -ftree-ch -ftree-copy-prop
# -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre
# -ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize -ftree-lrs
# -ftree-pre -ftree-salias -ftree-sink -ftree-sra -ftree-store-ccp
# -ftree-store-copy-prop -ftree-ter -ftree-vect-loop-version -ftree-vrp
# -funit-at-a-time -fverbose-asm -fzero-initialized-in-bss -m32 -m80387
# -m96bit-long-double -maccumulate-outgoing-args -malign-stringops
# -mfancy-math-387 -mfp-ret-in-387 -mieee-fp -mno-red-zone -mpush-args
# -mtls-direct-seg-refs
# Compiler executable checksum: 6d90f1c30ff8027bc6976ab2dbfe2320
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d\n"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
leal 4(%esp), %ecx #,
andl $-16, %esp #,
pushl -4(%ecx) #
subl $76, %esp #,
leal 28(%esp), %eax #, tmp64
movl %ecx, 68(%esp) #,
movl %eax, %edx # tmp64, c
movl %ebx, 72(%esp) #,
movw $0, (%edx) #,* c
movl $1, (%eax) #,* c
movswl (%edx),%ebx #* c, sum
movl (%eax), %edx #* c,
movl $.LC0, (%esp) #,
addl %edx, %ebx #, sum
movl %ebx, 4(%esp) # sum,
call printf #
decl %ebx # sum
jne .L6 #,
movl 68(%esp), %ecx #,
xorl %eax, %eax # <result>
movl 72(%esp), %ebx #,
addl $76, %esp #,
leal -4(%ecx), %esp #,
ret
.L6:
call abort #
.size main, .-main
.ident "GCC: (GNU) 4.2.0 20060101 (experimental)"
.section .note.GNU-stack,"",@progbits