Bug 79947 - [6 Regression] ICE in rs6000_emit_swsqrt at gcc/config/rs6000/rs6000.c:37570
Summary: [6 Regression] ICE in rs6000_emit_swsqrt at gcc/config/rs6000/rs6000.c:37570
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.0
: P2 normal
Target Milestone: 6.4
Assignee: Michael Meissner
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-03-07 20:59 UTC by Martin Liška
Modified: 2017-04-03 22:59 UTC (History)
4 users (show)

See Also:
Host: x86_64-linux-gnu
Target: ppc64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-03-14 00:00:00


Attachments
Proposed patch to fix the problem (627 bytes, patch)
2017-03-14 20:29 UTC, Michael Meissner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2017-03-07 20:59:16 UTC
Using cross-compiler for ppc64-linux-gnu (on x86_64-linux-gnu) I see:

ppc64-linux-gnu-gcc /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c -Ofast -mno-powerpc-gfxopt -mcmpb -c
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c: In function ‘test_float_sqrt’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/powerpc/vsx-mass-1.c:518:13: internal compiler error: Segmentation fault
     f1[i] = __builtin_sqrtf (f2[i]);
             ^~~~~~~~~~~~~~~~~~~~~~~
0xb7b6cf crash_signal
	.././../gcc/toplev.c:337
0x845b9d emit_move_insn(rtx_def*, rtx_def*)
	.././../gcc/expr.c:3697
0xed6c7c rs6000_emit_swsqrt(rtx_def*, rtx_def*, bool)
	.././../gcc/config/rs6000/rs6000.c:37570
0x104722a gen_sqrtsf2(rtx_def*, rtx_def*)
	.././../gcc/config/rs6000/rs6000.md:4612
0xa85ac8 maybe_expand_insn(insn_code, unsigned int, expand_operand*)
	.././../gcc/optabs.c:7078
0xa85ac8 expand_insn(insn_code, unsigned int, expand_operand*)
	.././../gcc/optabs.c:7109
0x95cb84 expand_direct_optab_fn
	.././../gcc/internal-fn.c:2550
0x735a6d expand_call_stmt
	.././../gcc/cfgexpand.c:2584
0x735a6d expand_gimple_stmt_1
	.././../gcc/cfgexpand.c:3571
0x735a6d expand_gimple_stmt
	.././../gcc/cfgexpand.c:3737
0x73729e expand_gimple_basic_block
	.././../gcc/cfgexpand.c:5744
0x73d0b6 execute
	.././../gcc/cfgexpand.c:6357

GCC 5 works fone.
Comment 1 Jakub Jelinek 2017-03-09 11:58:29 UTC
Can't reproduce, rs6000_emit_swsqrt isn't called in my case.
Comment 2 Martin Liška 2017-03-09 12:16:51 UTC
There's reduced test-case:

******** /tmp/ppc-ice.c ********

float a, b;
void
c ()
{
  a = __builtin_sqrtf (b);
}

$ ppc64-linux-gnu-gcc -Ofast -mno-powerpc-gfxopt -mcmpb -c ppc-ice.c --verbose
Using built-in specs.
COLLECT_GCC=ppc64-linux-gnu-gcc
Target: ppc64-linux-gnu
Configured with: ./../configure --enable-linker-build-id --prefix=/home/marxin/BIG/buildbot/slave/gcc-master-build-ppc64/../install/gcc-6fe883d64cf228785f3d0a4e24f9138c8958c93b --target=ppc64-linux-gnu --with-as=/usr/bin/powerpc64-suse-linux-as --disable-bootstrap

...

 /home/marxin/BIG/buildbot/slave/install/gcc-6fe883d64cf228785f3d0a4e24f9138c8958c93b/bin/../lib/gcc/ppc64-linux-gnu/7.0.1/cc1 -quiet -v -iprefix /home/marxin/BIG/buildbot/slave/install/gcc-6fe883d64cf228785f3d0a4e24f9138c8958c93b/bin/../lib64/gcc/ppc64-linux-gnu/7.0.1/ -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix ppc-ice.c -quiet -dumpbase ppc-ice.c -mno-powerpc-gfxopt -mcmpb -auxbase ppc-ice -Ofast -version -o /tmp/ccSq65JO.s

Hope you'll reproduce it now.
Comment 3 Michael Meissner 2017-03-14 19:49:11 UTC
The problem is the -mno-powerpc-gfxopt option disables floating point conditional moves, which is needed to use the floating point reciprocal estimate instructions.

The macro TARGET_FRSQRTES did not have a check for GFXOPT.
Comment 4 Michael Meissner 2017-03-14 20:29:14 UTC
Created attachment 40976 [details]
Proposed patch to fix the problem

The tARGET_RSQRTES macro needed a guard to require -mpowerpc-gfxopt.
Comment 5 Michael Meissner 2017-03-15 00:25:41 UTC
Author: meissner
Date: Wed Mar 15 00:25:10 2017
New Revision: 246150

URL: https://gcc.gnu.org/viewcvs?rev=246150&root=gcc&view=rev
Log:
[gcc]
2017-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/79947
	* config/rs6000/rs6000.h (TARGET_FRSQRTES): Add check for
	-mpowerpc-gfxopt.

[gcc/testsuite]
2017-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/79947
	* gcc.target/powerpc/pr79947.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr79947.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.h
    trunk/gcc/testsuite/ChangeLog
Comment 6 Michael Meissner 2017-04-03 22:58:04 UTC
Author: meissner
Date: Mon Apr  3 22:57:32 2017
New Revision: 246665

URL: https://gcc.gnu.org/viewcvs?rev=246665&root=gcc&view=rev
Log:
[gcc]
2017-04-03  Michael Meissner  <meissner@linux.vnet.ibm.com>

	Back port from the trunk
	2017-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/79947
	* config/rs6000/rs6000.h (TARGET_FRSQRTES): Add check for
	-mpowerpc-gfxopt.

[gcc/testsuite]
2017-04-03  Michael Meissner  <meissner@linux.vnet.ibm.com>

	Back port from the trunk
	2017-03-14  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/79947
	* gcc.target/powerpc/pr79947.c: New test.


Added:
    branches/gcc-6-branch/gcc/testsuite/gcc.target/powerpc/pr79947.c
      - copied unchanged from r246661, trunk/gcc/testsuite/gcc.target/powerpc/pr79947.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/config/rs6000/rs6000.h
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 7 Michael Meissner 2017-04-03 22:59:35 UTC
Fixed in the trunk with subversion id 246150, and back ported to GCC 6 with subversion id 246150.