[v3,1/2] LoongArch: Enable vect.exp for LoongArch. [PR111424]

Message ID 20230928100526.3351245-2-panchenghui@loongson.cn
State Unresolved
Headers
Series LoongArch: Update target-supports.exp for LoongArch SX/ASX. |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Chenghui Pan Sept. 28, 2023, 10:05 a.m. UTC
  gcc/testsuite/ChangeLog:

	* lib/target-supports.exp: Enable vect.exp for LoongArch.
---
 gcc/testsuite/lib/target-supports.exp | 31 +++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
  

Patch

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 3a472943a9b..25958aaf0c5 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -11335,6 +11335,13 @@  proc check_vect_support_and_set_flags { } {
 	    lappend DEFAULT_VECTCFLAGS "--param" "riscv-vector-abi"
 	    set dg-do-what-default compile
 	}
+    } elseif [istarget loongarch*-*-*] {
+      lappend DEFAULT_VECTCFLAGS "-mdouble-float" "-mlasx"
+      if [check_effective_target_loongarch_asx_hw] {
+	  set dg-do-what-default run
+      } else {
+	  set dg-do-what-default compile
+      }
     } else {
         return 0
     }
@@ -12817,6 +12824,30 @@  proc check_effective_target_const_volatile_readonly_section { } {
   return 1
 }
 
+proc check_effective_target_loongarch_sx_hw { } {
+    return [check_runtime loongarch_sx_hw {
+	#include <lsxintrin.h>
+	int main (void)
+	{
+	  __m128i a, b, c;
+	  c = __lsx_vand_v (a, b);
+	  return 0;
+	}
+    } "-mlsx"]
+}
+
+proc check_effective_target_loongarch_asx_hw { } {
+    return [check_runtime loongarch_asx_hw {
+	#include <lasxintrin.h>
+	int main (void)
+	{
+	  __m256i a, b, c;
+	  c = __lasx_xvand_v (a, b);
+	  return 0;
+	}
+    } "-mlasx"]
+}
+
 # Appends necessary Python flags to extra-tool-flags if Python.h is supported.
 # Otherwise, modifies dg-do-what.
 proc dg-require-python-h { args } {