re PR target/63408 (GCC emits incorrect fixed->fp conversion instruction on Cortex...
authorRamana Radhakrishnan <ramana.radhakrishnan@arm.com>
Wed, 24 Jun 2015 08:28:08 +0000 (08:28 +0000)
committerRamana Radhakrishnan <ramana@gcc.gnu.org>
Wed, 24 Jun 2015 08:28:08 +0000 (08:28 +0000)
Fix PR target/63408

The attached patch fixes PR target/63408 and adds a regression test
for the same. The problem is essentially that
vfp3_const_double_for_fract_bits() needs to be aware that negative
values cannot be used in this context.

Tested with a bootstrap and regression test run on armhf. Applied.

2015-06-24  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

PR target/63408
* config/arm/arm.c (vfp3_const_double_for_fract_bits): Disable
for negative numbers.

2015-06-24  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

PR target/63408
* gcc.target/arm/pr63408.c: New test.

From-SVN: r224879

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/pr63408.c [new file with mode: 0644]

index d1f82b29f53d87e2f0b40b23a93fb3b6d0e886bc..8a95bc27bb72fe417490417dd0861724413e5110 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-24  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+
+       PR target/63408
+       * config/arm/arm.c (vfp3_const_double_for_fract_bits): Disable
+       for negative numbers.
+
 2015-06-24  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        PR rtl-optimization/66306
index ced4231cd8c5e0cdf4ed4e3e5a37c10bad9e0be4..09191e5d2c2e403808eefc6c91bc931b571585a8 100644 (file)
@@ -27382,7 +27382,8 @@ vfp3_const_double_for_fract_bits (rtx operand)
     return 0;
   
   REAL_VALUE_FROM_CONST_DOUBLE (r0, operand);
-  if (exact_real_inverse (DFmode, &r0))
+  if (exact_real_inverse (DFmode, &r0)
+      && !REAL_VALUE_NEGATIVE (r0))
     {
       if (exact_real_truncate (DFmode, &r0))
        {
index ee58cdc36a2b9e47bf8f8102a5d35f6f2de2f301..daadf4c4229d592bef7145220575f6d6eeb91bd2 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-24  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+
+       PR target/63408
+       * gcc.target/arm/pr63408.c: New test.
+
 2015-06-24  James Greenhalgh  <james.greenhalgh@arm.com>
 
         * lib/c-torture.exp: Don't call check_effective_target_lto
diff --git a/gcc/testsuite/gcc.target/arm/pr63408.c b/gcc/testsuite/gcc.target/arm/pr63408.c
new file mode 100644 (file)
index 0000000..850596b
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run }  */
+/* { dg-options "-O2" } */
+void abort (void) __attribute__ ((noreturn));
+float __attribute__((noinline))
+f(float a, int b)
+{
+  return a - (((float)b / 0x7fffffff) * 100);
+}
+
+int
+main (void)
+{
+  float a[] = { 100.0, 0.0, 0.0};
+  int b[] = { 0x7fffffff, 0x7fffffff/100.0f, -0x7fffffff / 100.0f};
+  float c[] = { 0.0, -1.0, 1.0 };
+  int i;
+
+  for (i = 0; i < (sizeof(a) / sizeof (float)); i++)
+    if (f (a[i], b[i]) != c[i])
+       abort ();
+
+  return 0;
+}