Bug 43722 - ICE when passing NEON registers using const refrences
Summary: ICE when passing NEON registers using const refrences
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-04-12 03:10 UTC by Liran Nuna
Modified: 2015-06-24 23:35 UTC (History)
4 users (show)

See Also:
Host: x86_64-linux-gnu
Target: arm-linux-gnueabi
Build: x86_64-linux-gnu
Known to work:
Known to fail: 4.4.3
Last reconfirmed: 2010-04-15 09:39:24


Attachments
reduced test case in plain C (151 bytes, text/plain)
2010-04-12 20:35 UTC, Mikael Pettersson
Details
proposed 4.4 fix for PR43722 (918 bytes, patch)
2010-04-12 21:38 UTC, Mikael Pettersson
Details | Diff
proposed 4.3 fix for PR43722 (917 bytes, patch)
2010-04-15 13:37 UTC, Mikael Pettersson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Liran Nuna 2010-04-12 03:10:17 UTC
Giving GCC 4.4.3 the following code with the arguments "-O1 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp": 

############################################################

#include <stdio.h>
#include <arm_neon.h>

void printv_f32(const float32x4_t &v)
{
	printf("%f\n", vgetq_lane_f32(v, 0));
}

int main()
{
	float32x4_t v = {0.0, 1.0f, 2.0f, 3.0f};

	printv_f32(v);
	
	return 0;
}

############################################################

Results into an ICE:

/home/liranuna/Projects/mathlib_md/source/main.cpp: In function 'int main()':
/home/liranuna/Projects/mathlib_md/source/main.cpp:21: error: insn does not satisfy its constraints:
(insn 25 5 7 2 /home/liranuna/Projects/mathlib_md/source/main.cpp:11 (set (mem/c/i:V4SF (pre_dec:SI (reg/f:SI 0 r0 [134])) [0 v+0 S16 A64])
        (reg:V4SF 95 d16)) 710 {*neon_movv4sf} (expr_list:REG_INC (reg/f:SI 0 r0 [134])
        (nil)))
/home/liranuna/Projects/mathlib_md/source/main.cpp:21: internal compiler error: in reload_cse_simplify_operands, at postreload.c:396
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Liran Nuna 2010-04-12 03:24:10 UTC
I would like to add that changing

    void printv_f32(const float32x4_t &v)

into:

    void printv_f32(float32x4_t v)

makes the problem go away, but the generated code is suboptimal.
Comment 2 Mikael Pettersson 2010-04-12 08:48:26 UTC
The equivalent C version of this test case ICEs with 4.4.4 but works with 4.3.5 and 4.5.0-RC-20100406.
Comment 3 Mikael Pettersson 2010-04-12 10:31:35 UTC
gcc-4.5-20090514 (r147545): ICE
gcc-4.5-20090521 (r147778): no ICE

Continuing to investigate.
Comment 4 Mikael Pettersson 2010-04-12 14:18:05 UTC
Appears to have been "fixed" for 4.5 by r147566, see
<http://gcc.gnu.org/ml/gcc-patches/2009-05/msg00812.html>. But that patch doesn't change any ARM code so the issue may be still be latent in 4.5 unless some other patch fixed it properly.
Comment 5 Mikael Pettersson 2010-04-12 20:35:05 UTC
Created attachment 20372 [details]
reduced test case in plain C

Reduced test case.  This one ICEs both 4.4 and 4.3 but not 4.5.

Using the reduced test case a new bisection of trunk identified r147577 as the fix for this bug.  r147577 added support for PRE_DEC in NEON memory operands, which makes sense given the pre_dec in the insn that gcc complains about.

r147577 applies easily to 4.4 and eliminates the ICE.  I'll start a full bootstrap and regression test on this combo in a few minutes.
Comment 6 Mikael Pettersson 2010-04-12 21:38:29 UTC
Created attachment 20373 [details]
proposed 4.4 fix for PR43722

Turns out r147577 contains a few redundant changes wrt this bug.  The attached patch backports just those bits needed to fix the bug.
Comment 7 Liran Nuna 2010-04-13 07:43:32 UTC
Mikael's patch seems to do that trick as well as producing very nice assembly.
Comment 8 Ramana Radhakrishnan 2010-04-15 09:39:24 UTC
Could you submit the patch to gcc-patches@ ? If you need some help in testing this patch let me know and I can do it for you.
Comment 9 Mikael Pettersson 2010-04-15 13:37:56 UTC
Created attachment 20388 [details]
proposed 4.3 fix for PR43722
Comment 10 Mikael Pettersson 2010-04-15 13:40:58 UTC
The proposed 4.4 patch has been posted here:
http://gcc.gnu.org/ml/gcc-patches/2010-04/msg00885.html

Both the 4.4 and 4.3 patches have been bootstrapped and regtested on armv5tel, but due to lack of NEON HW no NEON runtime tests have been done.
Comment 11 Ramana Radhakrishnan 2015-06-24 23:35:21 UTC
Fixed in 4.5.0