Created attachment 32973 [details] Proposed patch To reproduce the issue do: 1) Configure gcc for arm as traget and x86 as host. $ ./configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=arm-v7a15v5r2-linux-gnueabi --prefix=/home/mzakirov/proj/gcc_arm_ref/arm-v7a15v5r2 --with-sysroot=/your_arm/sys-root 2) make -j6 3) make install 4) Compile following: $ cat ex.c int dummy(int a); char a; void mmm (void) { char dyn[ dummy(3) ]; a = (char)&dyn[0]; } $ gcc -O3 ex.c -o ex.o ex.c: In function ‘mmm’: ex.c:8:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] a = (char)&dyn[0]; ^ ex.c:9:1: internal compiler error: in check_rtl, at lra.c:1919 } ^ 0x8689e5 check_rtl /home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/lra.c:1919 0x86bde5 lra(_IO_FILE*) /home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/lra.c:2309 0x82b02e do_reload /home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/ira.c:5325 0x82b02e execute /home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/ira.c:5486 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. Analysis showed that the problem in instruction like: (insn 26 12 18 2 (set (reg:QI 2 r2) (reg:QI 13 sp)) ex.c:8 205 {*arm_movqi_insn} (nil)) gcc cse propogates sp register to (char/short) cast from a pointer (32 bit value) and reload phase fails because gcc do not founds applicable template for loading a byte or word from sp. Adding correct template to arm.md fixes the issue. See attached patch. Note: that issue appeared while translating linux kernel for arm.
Confirmed for trunk, 4.9 and 4.8. Marat, please send the patch to gcc-patches@gcc.gnu.org with an appropriate ChangeLog entry and the included testcase for review.
Also ICEs on 4.7.4, I guess that's been this way for a while
FWIW On 4.7.4 without LRA the ICE is: ice.c:9:1: error: insn does not satisfy its constraints: (insn 25 12 19 2 (set (reg:QI 2 r2) (reg:QI 13 sp)) ice.c:8 193 {*arm_movqi_insn} (nil)) But 4.7 is no loner maintained, so that's more of a trivia at this point
Author: mzakirov Date: Fri Jul 11 09:02:39 2014 New Revision: 212450 URL: https://gcc.gnu.org/viewcvs?rev=212450&root=gcc&view=rev Log: gcc/ 2014-07-11 Marat Zakirov <m.zakirov@samsung.com> PR target/61561 * config/arm/arm.md (*movhi_insn_arch4): Handle stack pointer. (*movhi_bytes): Likewise. (*arm_movqi_insn): Likewise. gcc/testsuite/ 2014-07-11 Marat Zakirov <m.zakirov@samsung.com> PR target/61561 * gcc.dg/pr61561.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr61561.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/arm/arm.md trunk/gcc/testsuite/ChangeLog
fixed