Bug 59826 - ICE caused by mishandling PLD rtx on ARM cortex-m4 target
Summary: ICE caused by mishandling PLD rtx on ARM cortex-m4 target
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-15 12:16 UTC by Terry Guo
Modified: 2014-01-17 05:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
case to reproduce the ICE (256 bytes, text/x-csrc)
2014-01-15 12:16 UTC, Terry Guo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Terry Guo 2014-01-15 12:16:34 UTC
Created attachment 31840 [details]
case to reproduce the ICE

When use upstream 4.8 gcc to compile attached case with command:
"arm-none-eabi-gcc -mthumb -fprefetch-loop-arrays crash.c -O2 -S -mcpu=cortex-m4", we will get ICE:

crash.c: In function 'genxScrubText':
crash.c:32:1: internal compiler error: in reg_overlap_mentioned_p, at rtlanal.c:1469
 }
 ^

The option -fprefetch-loop-arrays causes gcc to generate rtx for ARM PLD instruction like:

(insn 99 100 105 10 (prefetch (plus:SI (reg/v/f:SI 3 r3 [orig:143 last ] [143])
            (const_int 34 [0x22]))
        (const_int 0 [0])
        (const_int 3 [0x3])) 343 {prefetch}
     (nil))

When check data dependencies between this rtx and others, gcc mishandles it as a normal SET rtx and thus end up with ICE.

Trunk gcc hasn't such issue due to code improvement at http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00533.html.
Comment 1 Terry Guo 2014-01-16 04:10:11 UTC
As discussed in http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00875.html, the root cause should be incorrect insn type of preload instruction. 4.8 assigns alu type attribute to preload insn which causes other optimization passes think it can cause data dependence between alu->load/store. The trunk gcc with patch http://gcc.gnu.org/ml/gcc-patches/2013-09/msg00322.html, correctly assign load1 insn type to preload instruction, which avoids the check of data dependence between alu->load/store, thereby no such issue. So the best way to fix this issue in 4.8 is to back port the patch to assign the proper insn type attribute.
Comment 2 Terry Guo 2014-01-17 05:49:57 UTC
Forgot to mention PR number in my commit. This issue is fixed by http://gcc.gnu.org/ml/gcc-cvs/2014-01/msg00436.html.