rs6000: Fix check_effective_target_sqrt_insn (PR99352)
authorSegher Boessenkool <segher@kernel.crashing.org>
Wed, 3 Mar 2021 20:34:32 +0000 (20:34 +0000)
committerSegher Boessenkool <segher@kernel.crashing.org>
Tue, 9 Mar 2021 17:10:33 +0000 (17:10 +0000)
The previous version returned true for all PowerPC.  This is incorrect.
We only support floating point square root instructions if a) we support
floating point instructions at all, and b) we have _ARCH_PPCSQ defined.

2020-03-09  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_powerpc_sqrt): New.
(check_effective_target_sqrt_insn): Use it.

gcc/testsuite/lib/target-supports.exp

index 570d5d3..52d3d03 100644 (file)
@@ -5887,6 +5887,21 @@ proc check_effective_target_powerpc_hard_double { } {
     }
 }
 
+# Return 1 if this is a PowerPC target with hardware floating point sqrt.
+
+proc check_effective_target_powerpc_sqrt { } {
+    # We need to be PowerPC, and we need to have hardware fp enabled.
+    if {![check_effective_target_powerpc_fprs]} {
+      return 0;
+    }
+
+    return [check_no_compiler_messages powerpc_sqrt object {
+       #ifndef _ARCH_PPCSQ
+       #error _ARCH_PPCSQ is not defined
+       #endif
+    } {}]
+}
+
 # Return 1 if this is a PowerPC target supporting -maltivec.
 
 proc check_effective_target_powerpc_altivec_ok { } {
@@ -7581,7 +7596,7 @@ proc check_effective_target_vect_call_copysignf { } {
 proc check_effective_target_sqrt_insn { } {
     return [check_cached_effective_target sqrt_insn {
       expr { [istarget i?86-*-*] || [istarget x86_64-*-*]
-            || [istarget powerpc*-*-*]
+            || [check_effective_target_powerpc_sqrt]
             || [istarget aarch64*-*-*]
             || ([istarget arm*-*-*] && [check_effective_target_arm_vfp_ok])
             || ([istarget s390*-*-*]