Fix PR target/63408
authorramana <ramana@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Jun 2015 08:28:08 +0000 (08:28 +0000)
committerramana <ramana@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Jun 2015 08:28:08 +0000 (08:28 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224879 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d1f82b2..8a95bc2 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 ced4231..09191e5 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 ee58cdc..daadf4c 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;
+}