Hi,

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 to trunk.

Will apply to 5 after regression testing there and 4.9 after it unfreezes.

Ramana




2015-06-24  Ramana Radhakrishnan  <ramana.radhakrish...@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.radhakrish...@arm.com>

        PR target/63408
        * gcc.target/arm/pr63408.c: New test.
commit 9e6fb32c5ba143912c1114a59af0114500c5bc31
Author: Ramana Radhakrishnan <ramana.radhakrish...@arm.com>
Date:   Tue Jun 23 17:04:40 2015 +0100

    Fix PR target/63408

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4fea1a6..4a284ec 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -29812,7 +29812,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))
        {
diff --git a/gcc/testsuite/gcc.target/arm/pr63408.c 
b/gcc/testsuite/gcc.target/arm/pr63408.c
new file mode 100644
index 0000000..a23b2a4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr63408.c
@@ -0,0 +1,25 @@
+
+/* { 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;
+}

Reply via email to