http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46804
Summary: [4.5/4.6 Regression] gfortran.dg/char_cshift_2.f90
FAILs with -fregmove
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Created attachment 22632
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22632
auto-reduced testcase
Output:
$ /mnt/svn/gcc-trunk/binary-167453-lto-fortran-checking-yes-rtl-df/bin/gfortran
-O -fPIC -fexpensive-optimizations -fgcse -foptimize-register-move -fpeel-loops
-fno-tree-loop-optimize pr46804.f90
$ ./a.out
Aborted
In the assembly, the problem is apparent (intel syntax):
...
mov r12d, DWORD PTR A.4.1573[rip+3] # tmp310, A.4
mov DWORD PTR 16[rsp+r8*4], r12d # shift3, tmp310
...
32bit (unaligned) value is loaded instead of sign-extend byte as is done
without -fregmove:
...
movsx r11d, BYTE PTR A.4.1573[rip+3] # tmp310, A.4
mov DWORD PTR 16[rsp+r8*4], r11d # shift3, tmp310
...
so shift3 contains invalid data
The problem seems to first appear in the 182r.regmove dump:
$ diff pr46804.f90.180r.ce2 pr46804.f90.182r.regmove
...
2009,2010c1409,1410
< (sign_extend:SI (reg:QI 236))) pr46804.f90:17 132 {extendqisi2}
< (expr_list:REG_DEAD (reg:QI 236)
---
> (reg:SI 236)) pr46804.f90:17 64 {*movsi_internal}
> (expr_list:REG_DEAD (reg:SI 236)
...
Output:
r167453 - fail
r158095 - fail
4.5 r166509 - fail
4.4 r166509 - OK