Bug 82748 - ICE with __builtin_fabsq and __float128 in copy_to_mode_reg, at explow.c:612
Summary: ICE with __builtin_fabsq and __float128 in copy_to_mode_reg, at explow.c:612
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.2.1
: P3 normal
Target Milestone: ---
Assignee: Michael Meissner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-27 14:45 UTC by Gabriel F. T. Gomes
Modified: 2017-12-12 20:30 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc64le-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-11-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gabriel F. T. Gomes 2017-10-27 14:45:35 UTC
The following code, when compiled with -mfloat128 -mabi=ieeelongdouble for powerpc64le-linux-gnu, produces the following ICE.  The error message was produce with GCC 7.  With GCC 8, it also fails and -mfloat128 is not required.  With GCC 6 it doesn't fail.

__float128 d;

__float128
foobar (__float128 x)
{
  d = __builtin_fabsq (x);
  return d;
}

gcc: warning: using IEEE extended precision long double
cc1: warning: using IEEE extended precision long double
test.c: In function ‘foobar’:
test.c:6:7: internal compiler error: in copy_to_mode_reg, at explow.c:612
   d = __builtin_fabsq (x);
       ^~~~~~~~~~~~~~~~~~~
0x105176af copy_to_mode_reg(machine_mode, rtx_def*)
	/home/meissner/fsf-src/gcc-7-branch/gcc/explow.c:612
0x10dbacf3 rs6000_expand_unop_builtin
	/home/meissner/fsf-src/gcc-7-branch/gcc/config/rs6000/rs6000.c:14628
0x10e00a93 rs6000_expand_builtin
	/home/meissner/fsf-src/gcc-7-branch/gcc/config/rs6000/rs6000.c:17312
0x10383b1b expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
	/home/meissner/fsf-src/gcc-7-branch/gcc/builtins.c:6368
0x10539263 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/home/meissner/fsf-src/gcc-7-branch/gcc/expr.c:10821
0x105483ff store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*)
	/home/meissner/fsf-src/gcc-7-branch/gcc/expr.c:5552
0x1054a10f expand_assignment(tree_node*, tree_node*, bool)
	/home/meissner/fsf-src/gcc-7-branch/gcc/expr.c:5321
0x103b509b expand_call_stmt
	/home/meissner/fsf-src/gcc-7-branch/gcc/cfgexpand.c:2656
0x103b509b expand_gimple_stmt_1
	/home/meissner/fsf-src/gcc-7-branch/gcc/cfgexpand.c:3571
0x103b509b expand_gimple_stmt
	/home/meissner/fsf-src/gcc-7-branch/gcc/cfgexpand.c:3737
0x103bc327 expand_gimple_basic_block
	/home/meissner/fsf-src/gcc-7-branch/gcc/cfgexpand.c:5744
0x103bf467 execute
	/home/meissner/fsf-src/gcc-7-branch/gcc/cfgexpand.c:6357
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Gabriel F. T. Gomes 2017-10-27 15:07:05 UTC
Some additional information:

Replacing __builtin_fabsq (x) with __builtin_copysignq (x, x), in the test program, causes a similar error.

Replacing the 'q'-suffixed builtin with its 'f128'-suffixed counterpart makes the error go away.
Comment 2 Michael Meissner 2017-11-03 19:34:41 UTC
Inside the compiler we use TFmode for the IEEE 128-bit type when the default long double is IEEE 128-bit floating point and KFmode when the default long double is IBM double-double.
Comment 3 Michael Meissner 2017-11-06 18:32:19 UTC
Author: meissner
Date: Mon Nov  6 18:31:48 2017
New Revision: 254462

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

	PR target/82748
	* config/rs6000/rs6000-builtin.def (BU_FLOAT128_1): Delete
	float128 helper macros, which are no longer used after deleting
	the old 'q' built-in functions, and moving the round to odd
	built-in functions to being special built-in functions.
	(BU_FLOAT128_2): Likewise.
	(BU_FLOAT128_1_HW): Likewise.
	(BU_FLOAT128_2_HW): Likewise.
	(BU_FLOAT128_3_HW): Likewise.
	(FABSQ): Delete old 'q' built-in functions.
	(COPYSIGNQ): Likewise.
	(SQRTF128_ODD): Move round to odd built-in functions to be
	special built-in functions, so that we can handle
	-mabi=ieeelongdouble.
	(TRUNCF128_ODD): Likewise.
	(ADDF128_ODD): Likewise.
	(SUBF128_ODD): Likewise.
	(MULF128_ODD): Likewise.
	(DIVF128_ODD): Likewise.
	(FMAF128_ODD): Likewise.
	* config/rs6000/rs6000-c.c (rs6000_cpu_cpp_builtins): Map old 'q'
	built-in names to 'f128'.
	* config/rs6000/rs6000.c (rs6000_fold_builtin): Remove folding the
	old 'q' built-in functions, as the machine independent code for
	'f128' built-in functions handles this.
	(rs6000_expand_builtin): Add expansion for float128 round to odd
	functions, keying off on -mabi=ieeelongdouble of whether to use
	the KFmode or TFmode variant.
	(rs6000_init_builtins): Initialize the _Float128 round to odd
	built-in functions.
	* doc/extend.texi (PowerPC Built-in Functions): Document the old
	_Float128 'q' built-in functions are now mapped into the new
	'f128' built-in functions.

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

	PR target/82748
	* gcc.target/powerpc/pr82748-1.c: New test.
	* gcc.target/powerpc/pr82748-2.c: Likewise.


Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr82748-1.c
    trunk/gcc/testsuite/gcc.target/powerpc/pr82748-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000-builtin.def
    trunk/gcc/config/rs6000/rs6000-c.c
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/doc/extend.texi
    trunk/gcc/testsuite/ChangeLog
Comment 4 Michael Meissner 2017-11-16 20:30:24 UTC
Author: meissner
Date: Thu Nov 16 20:29:52 2017
New Revision: 254846

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

	Back port from trunk
	2017-11-16  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config/rs6000/rs6000.c (rs6000_expand_builtin): Do not do the
	switch statement mapping KF built-ins to TF built-ins if we don't
	have the proper ISA 3.0 assembler support.

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

	* config/rs6000/rs6000-c.c (is_float128_p): New helper function.
	(rs6000_builtin_type_compatible): Treat _Float128 and long double
	as being compatible if -mabi=ieeelongdouble.
	* config/rs6000/rs6000-builtin.def (BU_FLOAT128_HW_1): New macros
	to setup float128 built-ins with hardware support.
	(BU_FLOAT128_HW_2): Likewise.
	(BU_FLOAT128_HW_3): Likewise.
	(BU_FLOAT128_HW_VSX_1): Likewise.
	(BU_FLOAT128_HW_VSX_2): Likewise.
	(scalar_extract_expq): Change float128 built-in functions to
	accommodate having both KFmode and TFmode functions.  Use the
	KFmode variant as the default.
	(scalar_extract_sigq): Likewise.
	(scalar_test_neg_qp): Likewise.
	(scalar_insert_exp_q): Likewise.
	(scalar_insert_exp_qp): Likewise.
	(scalar_test_data_class_qp): Likewise.
	(sqrtf128_round_to_odd): Delete processing the round to odd
	built-in functions as special built-in functions, and define them
	as float128 built-ins.  Use the KFmode variant as the default.
	(truncf128_round_to_odd): Likewise.
	(addf128_round_to_odd): Likewise.
	(subf128_round_to_odd): Likewise.
	(mulf128_round_to_odd): Likewise.
	(divf128_round_to_odd): Likewise.
	(fmaf128_round_to_odd): Likewise.
	* config/rs6000/rs6000.c (rs6000_expand_binop_builtin): Add
	support for KFmode and TFmode xststdcqp calls.
	(rs6000_expand_builtin): If long double is IEEE 128-bit floating
	point, switch the built-in handlers for the get/set float128
	exponent, get float128 mantissa, float128 test built-ins, and the
	float128 round to odd built-in functions.  Eliminate creating the
	float128 round to odd built-in functions as special built-ins.
	(rs6000_init_builtins): Eliminate special creation of the float128
	round to odd built-in functions.
	* config/rs6000/vsx.md (xsxexpqp_<mode>): Change float128 built-in
	function insns to support both TFmode and KFmode variants.
	(xsxsigqp_<mode>): Likewise.
	(xsiexpqpf_<mode>): Likewise.
	(xsiexpqp_<mode>): Likewise.
	(xststdcqp_<mode>): Likewise.
	(xststdcnegqp_<mode>): Likewise.
	(xststdcqp_<mode>): Likewise.

	Back port from trunk
	2017-11-06  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/82748
	* config/rs6000/rs6000-builtin.def (BU_FLOAT128_1): Delete
	float128 helper macros, which are no longer used after deleting
	the old 'q' built-in functions, and moving the round to odd
	built-in functions to being special built-in functions.
	(BU_FLOAT128_2): Likewise.
	(BU_FLOAT128_1_HW): Likewise.
	(BU_FLOAT128_2_HW): Likewise.
	(BU_FLOAT128_3_HW): Likewise.
	(FABSQ): Delete old 'q' built-in functions.
	(COPYSIGNQ): Likewise.
	(SQRTF128_ODD): Move round to odd built-in functions to be
	special built-in functions, so that we can handle
	-mabi=ieeelongdouble.
	(TRUNCF128_ODD): Likewise.
	(ADDF128_ODD): Likewise.
	(SUBF128_ODD): Likewise.
	(MULF128_ODD): Likewise.
	(DIVF128_ODD): Likewise.
	(FMAF128_ODD): Likewise.
	* config/rs6000/rs6000-c.c (rs6000_cpu_cpp_builtins): Map old 'q'
	built-in names to 'f128'.
	* config/rs6000/rs6000.c (rs6000_fold_builtin): Remove folding the
	old 'q' built-in functions, as the machine independent code for
	'f128' built-in functions handles this.
	(rs6000_expand_builtin): Add expansion for float128 round to odd
	functions, keying off on -mabi=ieeelongdouble of whether to use
	the KFmode or TFmode variant.
	(rs6000_init_builtins): Initialize the _Float128 round to odd
	built-in functions.
	* doc/extend.texi (PowerPC Built-in Functions): Document the old
	_Float128 'q' built-in functions are now mapped into the new
	'f128' built-in functions.


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

	Back port from trunk
	2017-11-16  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* gcc.target/powerpc/bfp/bfp.exp: Look for *.c files, not *.c*
	files to prevent ~ files from getting recognized.
	* gcc.target/powerpc/dfp/dfp.exp: Likewise.
	* gcc.target/powerpc/vsu/vsu.exp: Likewise.

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

	* gcc.target/powerpc/float128-hw4.c: New test.

	Back port from trunk
	2017-08-14  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR target/79845
	* gcc.target/powerpc/bfp/scalar-extract-exp-4.c: Adjust diagnostic
	strings.
	* gcc.target/powerpc/bfp/scalar-extract-sig-4.c: Likewise.
	* gcc.target/powerpc/bfp/scalar-insert-exp-10.c: Likewise.
	* gcc.target/powerpc/bfp/scalar-insert-exp-7.c: Likewise.
	* gcc.target/powerpc/bfp/scalar-test-data-class-11.c: Likewise.
	* gcc.target/powerpc/bfp/scalar-test-neg-5.c: Likewise.


Added:
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/float128-hw4.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/pr82748-1.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/pr82748-2.c
Modified:
    branches/ibm/gcc-7-branch/gcc/ChangeLog.ibm
    branches/ibm/gcc-7-branch/gcc/config/rs6000/rs6000-builtin.def
    branches/ibm/gcc-7-branch/gcc/config/rs6000/rs6000-c.c
    branches/ibm/gcc-7-branch/gcc/config/rs6000/rs6000.c
    branches/ibm/gcc-7-branch/gcc/config/rs6000/vsx.md
    branches/ibm/gcc-7-branch/gcc/doc/extend.texi
    branches/ibm/gcc-7-branch/gcc/testsuite/ChangeLog.ibm
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/bfp/bfp.exp
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/bfp/scalar-extract-exp-4.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/bfp/scalar-extract-sig-4.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/bfp/scalar-insert-exp-10.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/bfp/scalar-insert-exp-7.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/bfp/scalar-test-data-class-11.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/bfp/scalar-test-neg-5.c
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/dfp/dfp.exp
    branches/ibm/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/vsu/vsu.exp
Comment 5 Michael Meissner 2017-12-12 20:02:52 UTC
Fixed in GCC 8 trunk, and back ported to the IBM Advance Toolchain AT 11.0 branch.  Unless there is need to get it in GCC 7.0, people using -mabi=ieeelongdouble should be using GCC 8 and/or AT 11.0.