[clang] [X86][AVX10] Fix a bug when using -march with no-evex512 attribute (PR #72126)
Phoebe Wang via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 13 18:20:57 PST 2023
https://github.com/phoebewang updated https://github.com/llvm/llvm-project/pull/72126
>From a7642c3216cac9901f2e8b2290732ad526406b06 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Mon, 13 Nov 2023 23:21:35 +0800
Subject: [PATCH 1/6] [X86][AVX10] Fix a bug when using -march with no-evex512
attribute
failed to clear EVEX512 feature for intended intrinsics.
Fixes #72106
---
clang/lib/Basic/Targets/X86.cpp | 2 +-
clang/test/CodeGen/X86/pr72106.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 clang/test/CodeGen/X86/pr72106.c
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index eb127a8a11fffd5..acde3c1661748f0 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -122,7 +122,7 @@ bool X86TargetInfo::initFeatureMap(
std::vector<std::string> UpdatedAVX10FeaturesVec;
enum { FE_NOSET = -1, FE_FALSE, FE_TRUE };
int HasEVEX512 = FE_NOSET;
- bool HasAVX512F = false;
+ bool HasAVX512F = Features["avx512f"];
bool HasAVX10 = false;
bool HasAVX10_512 = false;
std::string LastAVX10;
diff --git a/clang/test/CodeGen/X86/pr72106.c b/clang/test/CodeGen/X86/pr72106.c
new file mode 100644
index 000000000000000..7ff4012f319b5b1
--- /dev/null
+++ b/clang/test/CodeGen/X86/pr72106.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -ffreestanding -target-cpu cannonlake -emit-llvm < %s | FileCheck %s
+
+#include <immintrin.h>
+
+int main(int argc, char **argv) {
+ // CHECK-LABEL: @main
+ // CHECK: @llvm.masked.load.v4i64.p0
+ __m256i ptrs = _mm256_maskz_loadu_epi64(0, argv);
+ return 0;
+}
>From 2124770f737a15c733d024b343583dc8568865f7 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Mon, 13 Nov 2023 23:46:08 +0800
Subject: [PATCH 2/6] Initialize AVX10.1 features too, though we don't have a
target for test
---
clang/lib/Basic/Targets/X86.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index acde3c1661748f0..60ca8ff8f681ca0 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -123,8 +123,8 @@ bool X86TargetInfo::initFeatureMap(
enum { FE_NOSET = -1, FE_FALSE, FE_TRUE };
int HasEVEX512 = FE_NOSET;
bool HasAVX512F = Features["avx512f"];
- bool HasAVX10 = false;
- bool HasAVX10_512 = false;
+ bool HasAVX10 = Features["avx10.1-256"];
+ bool HasAVX10_512 = Features["avx10.1-512"];
std::string LastAVX10;
std::string LastAVX512;
for (const auto &Feature : FeaturesVec) {
>From d072431a86aa811cd7d053f35f8b4939a93216e3 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Tue, 14 Nov 2023 00:07:00 +0800
Subject: [PATCH 3/6] Revert "Initialize AVX10.1 features too, though we don't
have a target for test"
This reverts commit 2124770f737a15c733d024b343583dc8568865f7.
Do not initialize AVX10.1 features for now since it affects other lit tests.
---
clang/lib/Basic/Targets/X86.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 60ca8ff8f681ca0..acde3c1661748f0 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -123,8 +123,8 @@ bool X86TargetInfo::initFeatureMap(
enum { FE_NOSET = -1, FE_FALSE, FE_TRUE };
int HasEVEX512 = FE_NOSET;
bool HasAVX512F = Features["avx512f"];
- bool HasAVX10 = Features["avx10.1-256"];
- bool HasAVX10_512 = Features["avx10.1-512"];
+ bool HasAVX10 = false;
+ bool HasAVX10_512 = false;
std::string LastAVX10;
std::string LastAVX512;
for (const auto &Feature : FeaturesVec) {
>From ec72ea87e792d85e1747ff48da29f72c688c2802 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Tue, 14 Nov 2023 09:29:45 +0800
Subject: [PATCH 4/6] Always append "-evex512" for "no-evex512" feature
---
clang/lib/Basic/Targets/X86.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index acde3c1661748f0..7a5587bb70da610 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -122,7 +122,7 @@ bool X86TargetInfo::initFeatureMap(
std::vector<std::string> UpdatedAVX10FeaturesVec;
enum { FE_NOSET = -1, FE_FALSE, FE_TRUE };
int HasEVEX512 = FE_NOSET;
- bool HasAVX512F = Features["avx512f"];
+ bool HasAVX512F = false;
bool HasAVX10 = false;
bool HasAVX10_512 = false;
std::string LastAVX10;
@@ -180,6 +180,8 @@ bool X86TargetInfo::initFeatureMap(
Diags.Report(diag::warn_invalid_feature_combination)
<< LastAVX10 + (HasEVEX512 == FE_TRUE ? " +evex512" : " -evex512");
UpdatedFeaturesVec.push_back(HasAVX10_512 ? "+evex512" : "-evex512");
+ } else if (HasEVEX512 == FE_FALSE) {
+ UpdatedFeaturesVec.push_back("-evex512");
}
if (!TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec))
>From fff4b0e9f42813b2888b42bfed872920aa3af7b8 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Tue, 14 Nov 2023 09:57:34 +0800
Subject: [PATCH 5/6] Revert "Always append "-evex512" for "no-evex512"
feature"
This reverts commit ec72ea87e792d85e1747ff48da29f72c688c2802.
---
clang/lib/Basic/Targets/X86.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 7a5587bb70da610..acde3c1661748f0 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -122,7 +122,7 @@ bool X86TargetInfo::initFeatureMap(
std::vector<std::string> UpdatedAVX10FeaturesVec;
enum { FE_NOSET = -1, FE_FALSE, FE_TRUE };
int HasEVEX512 = FE_NOSET;
- bool HasAVX512F = false;
+ bool HasAVX512F = Features["avx512f"];
bool HasAVX10 = false;
bool HasAVX10_512 = false;
std::string LastAVX10;
@@ -180,8 +180,6 @@ bool X86TargetInfo::initFeatureMap(
Diags.Report(diag::warn_invalid_feature_combination)
<< LastAVX10 + (HasEVEX512 == FE_TRUE ? " +evex512" : " -evex512");
UpdatedFeaturesVec.push_back(HasAVX10_512 ? "+evex512" : "-evex512");
- } else if (HasEVEX512 == FE_FALSE) {
- UpdatedFeaturesVec.push_back("-evex512");
}
if (!TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec))
>From d83845172942fcc5902e203090a52e963b49a732 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Tue, 14 Nov 2023 10:12:53 +0800
Subject: [PATCH 6/6] Fix lit failures
---
clang/lib/Basic/Targets/X86.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index acde3c1661748f0..f1ff17da4eb2799 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -122,7 +122,7 @@ bool X86TargetInfo::initFeatureMap(
std::vector<std::string> UpdatedAVX10FeaturesVec;
enum { FE_NOSET = -1, FE_FALSE, FE_TRUE };
int HasEVEX512 = FE_NOSET;
- bool HasAVX512F = Features["avx512f"];
+ bool HasAVX512F = Features.count("avx512f") && Features["avx512f"];
bool HasAVX10 = false;
bool HasAVX10_512 = false;
std::string LastAVX10;
More information about the cfe-commits
mailing list