[llvm-branch-commits] [clang] release/21.x: [clang][LoongArch] Ensure `target("lasx")` implies LSX support (#153542) (PR #153739)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 14 21:00:18 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (llvmbot)

<details>
<summary>Changes</summary>

Backport 793a6b4fd402c929e04f9da407fe4491d5d9d22e a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b

Requested by: @<!-- -->Ami-zhang

---
Full diff: https://github.com/llvm/llvm-project/pull/153739.diff


2 Files Affected:

- (modified) clang/lib/Basic/Targets/LoongArch.cpp (+2) 
- (added) clang/test/CodeGen/LoongArch/targetattr-lasx.c (+7) 


``````````diff
diff --git a/clang/lib/Basic/Targets/LoongArch.cpp b/clang/lib/Basic/Targets/LoongArch.cpp
index f6915df1520b7..8e29bb745734b 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -461,6 +461,8 @@ LoongArchTargetInfo::parseTargetAttr(StringRef Features) const {
 
     case AttrFeatureKind::Feature:
       Ret.Features.push_back("+" + Value.str());
+      if (Value == "lasx")
+        Ret.Features.push_back("+lsx");
       break;
     }
   }
diff --git a/clang/test/CodeGen/LoongArch/targetattr-lasx.c b/clang/test/CodeGen/LoongArch/targetattr-lasx.c
new file mode 100644
index 0000000000000..56fd6573ed34c
--- /dev/null
+++ b/clang/test/CodeGen/LoongArch/targetattr-lasx.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple loongarch64 -target-feature -lsx -emit-llvm %s -o - | FileCheck %s
+
+__attribute__((target("lasx")))
+// CHECK: #[[ATTR0:[0-9]+]] {
+void testlasx() {}
+
+// CHECK: attributes #[[ATTR0]] = { {{.*}}"target-features"="+64bit,+lasx,+lsx"{{.*}} }

``````````

</details>


https://github.com/llvm/llvm-project/pull/153739


More information about the llvm-branch-commits mailing list