Bug 82848 - [8 Regression] ICE in expand_expr_real_2, at expr.c:8715
Summary: [8 Regression] ICE in expand_expr_real_2, at expr.c:8715
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-05 17:28 UTC by Martin Liška
Modified: 2017-11-25 11:12 UTC (History)
3 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: ppc64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-11-05 00:00:00


Attachments
gcc8-pr82848.patch (725 bytes, patch)
2017-11-23 09:43 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2017-11-05 17:28:10 UTC
Following ICEs:

$ ppc64-linux-gnu-gcc /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c
during RTL pass: expand
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c: In function ‘foo’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c:12:16: internal compiler error: in expand_expr_real_2, at expr.c:8715
   vector float b = __builtin_vec_madd (b, a, (vector float) { C, C, C, C });
                ^
0x82d5d9 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier)
	.././../gcc/expr.c:8715
0x6ffa69 expand_gimple_stmt_1
	.././../gcc/cfgexpand.c:3712
0x6ffa69 expand_gimple_stmt
	.././../gcc/cfgexpand.c:3773
0x70132f expand_gimple_basic_block
	.././../gcc/cfgexpand.c:5774
0x706d36 execute
	.././../gcc/cfgexpand.c:6375

Note that GCC 7.1 did:

$ powerpc64-suse-linux-gcc-7 /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c -c 
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c: In function 'foo':
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c:12:16: error: Builtin function __builtin_altivec_vmaddfp requires the -maltivec option
   vector float b = __builtin_vec_madd (b, a, (vector float) { C, C, C, C });
                ^

So the error somehow disappeared.
Comment 1 Segher Boessenkool 2017-11-05 20:28:51 UTC
Confirmed.
Comment 2 Bill Schmidt 2017-11-06 18:46:48 UTC
CCing Will (fallout from moving this function to gimple expansion).
Comment 3 Will Schmidt 2017-11-17 21:17:12 UTC
(In reply to Martin Liška from comment #0)
> Note that GCC 7.1 did:
> 
> $ powerpc64-suse-linux-gcc-7
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c -c 
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c: In
> function 'foo':
> /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c:12:
> 16: error: Builtin function __builtin_altivec_vmaddfp requires the -maltivec
> option
>    vector float b = __builtin_vec_madd (b, a, (vector float) { C, C, C, C });
>                 ^
> 
> So the error somehow disappeared.

Yes,.. with the gimple-folding in place, that particular function (at .gimple time) is no longer in play.
  bD.2759 = __builtin_altivec_vmaddfpD.1680 (bD.2759, aD.2756, { 3.64337600724452438440169691655378194132868104887894100657e-44, 3.64337600724452438440169691655378194132868104887894100657e-44, 3.64337600724452438440169691655378194132868104887894100657e-44, 3.64337600724452438440169691655378194132868104887894100657e-44 });
is now
  bD.2759 = bD.2759 * aD.2756 + { 3.64337600724452438440169691655378194132868104887894100657e-44, 3.64337600724452438440169691655378194132868104887894100657e-44, 3.64337600724452438440169691655378194132868104887894100657e-44, 3.64337600724452438440169691655378194132868104887894100657e-44 };
.  

If you use the option " -mno-fold-gimple " you should get the un-folded behavior.  Which would be good to confirm this is the root cause, but not long-term recommended for optimization reasons.

So all that said.. I'm struggling to recreate this one.   
My latest attempt was on gcc110.  I've tried on a few other power systems, with similar/same results.

Anything obvious that I may have mis-configured here?

[willschm@gcc1-power7 gcc]$ /home/willschm/gcc/install/gcc/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/home/willschm/gcc/install/gcc/bin/gcc
COLLECT_LTO_WRAPPER=/home/willschm/gcc/install/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/8.0.0/lto-wrapper
Target: powerpc64-unknown-linux-gnu
Configured with: ../../src/gcc/configure --enable-languages=c,c++,fortran,objc,obj-c++ --with-cpu=power7 --with-long-double-128 --prefix=/home/willschm/gcc/install/gcc/ --disable-bootstrap
Thread model: posix
gcc version 8.0.0 20171117 (experimental) (GCC) 

[willschm@gcc1-power7 gcc]$ /home/willschm/gcc/install/gcc/bin/gcc  /home/willschm/gcc/src/gcc/gcc/testsuite/gcc.target/powerpc/pr37168.c -c
[willschm@gcc1-power7 gcc]$ ls -lart pr37168.o 
-rw-rw-r--. 1 willschm willschm 1200 Nov 17 21:06 pr37168.o
Comment 4 Jakub Jelinek 2017-11-23 09:43:22 UTC
Created attachment 42692 [details]
gcc8-pr82848.patch

Untested fix.  I think it is better to just punt on all the ones and get diagnostics.  Technically, the problem is mostly in stuff that tree-vect-generic.c doesn't handle (FMA_EXPR, widening stuff, etc.), but I think it is just wrong to error on something with -mno-fold-gimple and not with -mfold-gimple.
Comment 5 Jakub Jelinek 2017-11-25 10:19:47 UTC
Author: jakub
Date: Sat Nov 25 10:19:16 2017
New Revision: 255148

URL: https://gcc.gnu.org/viewcvs?rev=255148&root=gcc&view=rev
Log:
	PR target/82848
	* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Don't fold
	builtins not enabled in the currently selected ISA.

	* gcc.target/powerpc/pr82848.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr82848.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2017-11-25 11:12:44 UTC
Fixed.