]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[ARM] Fix PR85261: ICE with FPSCR setter builtin
authorThomas Preud'homme <thomas.preudhomme@arm.com>
Wed, 18 Apr 2018 13:17:30 +0000 (13:17 +0000)
committerThomas Preud'homme <thopre01@gcc.gnu.org>
Wed, 18 Apr 2018 13:17:30 +0000 (13:17 +0000)
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.

From-SVN: r259469

gcc/ChangeLog
gcc/config/arm/arm-builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/fpscr.c

index 2dbf8f1eb1400b088f461e5bbaf2fab991b7db60..2631728fc5f68d1a9a25009ec859a335576fbe6e 100644 (file)
@@ -1,3 +1,12 @@
+2018-04-18  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       Backport from mainline
+       2018-04-11  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       PR target/85261
+       * config/arm/arm-builtins.c (arm_expand_builtin): Force input operand
+       into register.
+
 2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline
index 809c43e7d8d0a0324afb45455c76bd7611ab3a25..cba582fa6684665ec7433f81bb6424d29efd15d5 100644 (file)
@@ -2368,7 +2368,7 @@ arm_expand_builtin (tree exp,
          icode = CODE_FOR_set_fpscr;
          arg0 = CALL_EXPR_ARG (exp, 0);
          op0 = expand_normal (arg0);
-         pat = GEN_FCN (icode) (op0);
+         pat = GEN_FCN (icode) (force_reg (SImode, op0));
        }
       emit_insn (pat);
       return target;
index e663523b317755811136839ce66fc84159a59c38..a03fe2e98102b0e9576b03d77fa4ecb2c099de08 100644 (file)
@@ -1,3 +1,13 @@
+2018-04-18  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       Backport from mainline
+       2018-04-11  Thomas Preud'homme  <thomas.preudhomme@arm.com>
+
+       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.
+
 2018-04-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from mainline
index 7b4d71d72d8964f6da0d0604bf59aeb4a895df43..4c3eaf7fcf75ad8582071ecb110fd1e4976a3b24 100644 (file)
@@ -6,11 +6,14 @@
 /* { dg-add-options arm_fp } */
 
 void
-test_fpscr ()
+test_fpscr (void)
 {
-  volatile unsigned int status = __builtin_arm_get_fpscr ();
+  unsigned status;
+
+  __builtin_arm_set_fpscr (0);
+  status = __builtin_arm_get_fpscr ();
   __builtin_arm_set_fpscr (status);
 }
 
 /* { dg-final { scan-assembler "mrc\tp10, 7, r\[0-9\]+, cr1, cr0, 0" } } */
-/* { dg-final { scan-assembler "mcr\tp10, 7, r\[0-9\]+, cr1, cr0, 0" } } */
+/* { dg-final { scan-assembler-times "mcr\tp10, 7, r\[0-9\]+, cr1, cr0, 0" 2 } } */