Pat noticed that the updated pack03.c DFP test case is FAILing on
older Power hardware without DFP support (ie, power5 and earlier).
The problem is that the dg-require-effective-target dfprt use
only protects against use on system without a DFP runtime, not
a system without dfp hardware instructions.  It seems we don't
have test, so the following patch added a dfp_hw test that fixes
the problem.

This passed bootstrap and regtesting on powerpc64-linux with no
regressions on both power5 and power8 systems.
Ok for mainline, 4.9 and 4.8 branches to fixup the test cases
there?

Peter


gcc/testsuite/

        * lib/target-support.exp (check_dfp_hw_available): New function.
        (is-effective-target): Check $arg for dfp_hw.
        (is-effective-target-keyword): Likewise.
        * gcc.target/powerpc/pack03.c: (dg-require-effective-target):
        Change target to dfp_hw.

Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp       (revision 210242)
+++ gcc/testsuite/lib/target-supports.exp       (working copy)
@@ -1956,6 +1956,32 @@ proc check_effective_target_dfprt { } {
     }]
 }
 
+# Return 1 if the target supports executing DFP hardware instructions,
+# 0 otherwise.  Cache the result.
+
+proc check_dfp_hw_available { } {
+    return [check_cached_effective_target dfp_hw_available {
+       # For now, disable on Darwin
+       if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || 
[istarget *-*-darwin*]} {
+           expr 0
+       } else {
+           check_runtime_nocache dfp_hw_available {
+               volatile _Decimal64 r;
+               volatile _Decimal64 a = 4.0DD;
+               volatile _Decimal64 b = 2.0DD;
+               int main()
+               {
+                 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 return 0;
+               }
+           } "-mcpu=power6 -mhard-float"
+       }
+    }]
+}
+
 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
 
 proc check_effective_target_ucn_nocache { } {
@@ -4936,6 +4962,7 @@ proc is-effective-target { arg } {
          "vsx_hw"         { set selected [check_vsx_hw_available] }
          "p8vector_hw"    { set selected [check_p8vector_hw_available] }
          "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
+         "dfp_hw"         { set selected [check_dfp_hw_available] }
          "named_sections" { set selected [check_named_sections_available] }
          "gc_sections"    { set selected [check_gc_sections_available] }
          "cxa_atexit"     { set selected [check_cxa_atexit_available] }
@@ -4958,6 +4985,7 @@ proc is-effective-target-keyword { arg }
          "vsx_hw"         { return 1 }
          "p8vector_hw"    { return 1 }
          "ppc_recip_hw"   { return 1 }
+         "dfp_hw"         { return 1 }
          "named_sections" { return 1 }
          "gc_sections"    { return 1 }
          "cxa_atexit"     { return 1 }
Index: gcc/testsuite/gcc.target/powerpc/pack03.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pack03.c   (revision 210242)
+++ gcc/testsuite/gcc.target/powerpc/pack03.c   (working copy)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { powerpc*-*-linux* } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 /* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
-/* { dg-require-effective-target dfprt } */
+/* { dg-require-effective-target dfp_hw } */
 /* { dg-options "-O2 -mhard-dfp" } */
 
 #include <stddef.h>


Reply via email to