Bug 85261 - __builtin_arm_set_fpscr ICEs with constant input
Summary: __builtin_arm_set_fpscr ICEs with constant input
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.0.1
: P3 normal
Target Milestone: ---
Assignee: Thomas Preud'homme
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-04-06 14:16 UTC by Thomas Preud'homme
Modified: 2018-04-18 13:18 UTC (History)
1 user (show)

See Also:
Host:
Target: arm-none-eabi
Build:
Known to work: 6.4.1, 7.3.1, 8.0.1
Known to fail: 6.4.0, 7.3.0
Last reconfirmed: 2018-04-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Preud'homme 2018-04-06 14:16:17 UTC
The following code ICES when compiled with -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 on trunk:

void
test_fpscr (void)
{
  __builtin_arm_set_fpscr (0);
}
Comment 1 Thomas Preud'homme 2018-04-06 14:16:48 UTC
Have a patch, testing it.
Comment 2 Ramana Radhakrishnan 2018-04-06 15:55:03 UTC
What about earlier branches ?
Comment 3 Thomas Preud'homme 2018-04-06 16:02:50 UTC
(In reply to Ramana Radhakrishnan from comment #2)
> What about earlier branches ?

Oh yes, forgot the previous fpscr fix was also backported.
Comment 4 Thomas Preud'homme 2018-04-11 10:07:58 UTC
Author: thopre01
Date: Wed Apr 11 10:07:25 2018
New Revision: 259310

URL: https://gcc.gnu.org/viewcvs?rev=259310&root=gcc&view=rev
Log:
[ARM] Fix PR85261: ICE with FPSCR setter builtin

Instruction pattern for setting the FPSCR expects the input value to be
in a register. However, __builtin_arm_set_fpscr expander does not ensure
that this is the case and as a result GCC ICEs when the builtin is
called with a constant literal.

This commit fixes the builtin to force the input value into a register.
It also remove the unneeded volatile in the existing fpscr test and
fixes the function prototype.

2018-04-11  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    PR target/85261
    * config/arm/arm-builtins.c (arm_expand_builtin): Force input operand
    into register.

    gcc/testsuite/
    PR target/85261
    * config/arm/arm-builtins.c (arm_expand_builtin): Force input operand
    into register.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm-builtins.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/arm/fpscr.c
Comment 5 Thomas Preud'homme 2018-04-18 11:42:41 UTC
Author: thopre01
Date: Wed Apr 18 11:42:10 2018
New Revision: 259465

URL: https://gcc.gnu.org/viewcvs?rev=259465&root=gcc&view=rev
Log:
[ARM] Fix PR85261: ICE with FPSCR setter builtin

Instruction pattern for setting the FPSCR expects the input value to be
in a register. However, __builtin_arm_set_fpscr expander does not ensure
that this is the case and as a result GCC ICEs when the builtin is
called with a constant literal.

This commit fixes the builtin to force the input value into a register.
It also remove the unneeded volatile in the existing fpscr test and
fixes the function prototype.

2018-04-18  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    Backport from mainline
    2018-04-11  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    PR target/85261
    * config/arm/arm-builtins.c (arm_expand_builtin): Force input operand
    into register.

    gcc/testsuite/
    PR target/85261
    * gcc.target/arm/fpscr.c: Add call to __builtin_arm_set_fpscr with
    literal value.  Expect 2 MCR instruction.  Fix function prototype.
    Remove volatile keyword.

Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/config/arm/arm-builtins.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/gcc.target/arm/fpscr.c
Comment 6 Thomas Preud'homme 2018-04-18 13:18:02 UTC
Author: thopre01
Date: Wed Apr 18 13:17:30 2018
New Revision: 259469

URL: https://gcc.gnu.org/viewcvs?rev=259469&root=gcc&view=rev
Log:
[ARM] Fix PR85261: ICE with FPSCR setter builtin

Instruction pattern for setting the FPSCR expects the input value to be
in a register. However, __builtin_arm_set_fpscr expander does not ensure
that this is the case and as a result GCC ICEs when the builtin is
called with a constant literal.

This commit fixes the builtin to force the input value into a register.
It also remove the unneeded volatile in the existing fpscr test and
fixes the function prototype.

2018-04-18  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    Backport from mainline
    2018-04-11  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    PR target/85261
    * config/arm/arm-builtins.c (arm_expand_builtin): Force input operand
    into register.

    gcc/testsuite/
    PR target/85261
    * gcc.target/arm/fpscr.c: Add call to __builtin_arm_set_fpscr with
    literal value.  Expect 2 MCR instruction.  Fix function prototype.
    Remove volatile keyword.

Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/config/arm/arm-builtins.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
    branches/gcc-6-branch/gcc/testsuite/gcc.target/arm/fpscr.c
Comment 7 Thomas Preud'homme 2018-04-18 13:18:49 UTC
Fixed in all release branches.