[llvm] [X86][Inline] Don't inline callee with cx16 if caller is without cx16 (PR #187505)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 04:52:41 PDT 2026


https://github.com/usamoi updated https://github.com/llvm/llvm-project/pull/187505

>From 030f67022b173b6eb69d5e43ec8fb2e28a6b63e2 Mon Sep 17 00:00:00 2001
From: usamoi <usamoi at outlook.com>
Date: Thu, 19 Mar 2026 22:08:19 +0800
Subject: [PATCH] [X86][Inline] Don't inline callee with cx16 if caller is
 without cx16

---
 llvm/lib/Target/X86/X86.td                                  | 3 +--
 llvm/test/Transforms/Inline/X86/inline-target-cpu-i686.ll   | 2 +-
 llvm/test/Transforms/Inline/X86/inline-target-cpu-x86_64.ll | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 1496d3b4a8b22..a74800a1f7e86 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -108,10 +108,9 @@ def FeatureMMX     : SubtargetFeature<"mmx","HasMMX", "true",
 def FeatureX86_64   : SubtargetFeature<"64bit", "HasX86_64", "true",
                                       "Support 64-bit instructions", [],
                                       InlineIgnore>;
-// TODO: This should not be InlineIgnore, as it affects the atomics ABI.
 def FeatureCX16     : SubtargetFeature<"cx16", "HasCX16", "true",
                                        "64-bit with cmpxchg16b (this is true for most x86-64 chips, but not the first AMD chips)",
-                                       [FeatureCX8], InlineIgnore>;
+                                       [FeatureCX8]>;
 def FeatureSSE4A   : SubtargetFeature<"sse4a", "HasSSE4A", "true",
                                       "Support SSE 4a instructions",
                                       [FeatureSSE3]>;
diff --git a/llvm/test/Transforms/Inline/X86/inline-target-cpu-i686.ll b/llvm/test/Transforms/Inline/X86/inline-target-cpu-i686.ll
index 187278d1c9035..ef2eee0df87b2 100644
--- a/llvm/test/Transforms/Inline/X86/inline-target-cpu-i686.ll
+++ b/llvm/test/Transforms/Inline/X86/inline-target-cpu-i686.ll
@@ -16,5 +16,5 @@ define i32 @target_cpu_prescott_call_target_cpu_nocona() #1 {
   ret i32 %call
 }
 
-attributes #0 = { nounwind "target-cpu"="nocona" }
+attributes #0 = { nounwind "target-cpu"="nocona" "target-features"="-cx16" }
 attributes #1 = { nounwind "target-cpu"="prescott" }
diff --git a/llvm/test/Transforms/Inline/X86/inline-target-cpu-x86_64.ll b/llvm/test/Transforms/Inline/X86/inline-target-cpu-x86_64.ll
index e6693a637d820..a264f90dc28c8 100644
--- a/llvm/test/Transforms/Inline/X86/inline-target-cpu-x86_64.ll
+++ b/llvm/test/Transforms/Inline/X86/inline-target-cpu-x86_64.ll
@@ -51,4 +51,4 @@ attributes #0 = { nounwind "target-cpu"="x86-64" }
 attributes #1 = { nounwind "target-cpu"="k8" }
 attributes #2 = { nounwind "target-cpu"="nehalem" }
 attributes #3 = { nounwind "target-cpu"="goldmont" }
-attributes #4 = { nounwind "target-cpu"="nocona" "target-features"="-sse3" }
+attributes #4 = { nounwind "target-cpu"="nocona" "target-features"="-sse3,-cx16" }



More information about the llvm-commits mailing list