https://github.com/lucaslive974 updated 
https://github.com/llvm/llvm-project/pull/206388

>From db76d963201d107a660d68a887846e5477cb9a72 Mon Sep 17 00:00:00 2001
From: Lucas-Ribeiro-Lima <[email protected]>
Date: Sun, 28 Jun 2026 22:46:31 -0300
Subject: [PATCH 1/2] [clang][CIR]: X86 movnti/movntsd/movntss CIR
 implementation.

---
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 16 ++++++++++
 clang/test/CIR/CodeGen/builtins-x86.c      | 34 ++++++++++++++++++++--
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 94fd16c6837a6..673ba95bccadb 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -1859,6 +1859,22 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, 
const CallExpr *expr) {
     mlir::Value sv = builder.createVecShuffle(loc, in, zero, indices);
     return builder.createBitcast(sv, ops[0].getType());
   }
+  case X86::BI__builtin_ia32_movnti:
+  case X86::BI__builtin_ia32_movnti64:
+  case X86::BI__builtin_ia32_movntsd:
+  case X86::BI__builtin_ia32_movntss: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+
+    Address dest = Address{ops[0], CharUnits::One()};
+    mlir::Value src = ops[1];
+
+    if (builtinID == X86::BI__builtin_ia32_movntsd ||
+        builtinID == X86::BI__builtin_ia32_movntss)
+      src = builder.createExtractElement(loc, ops[1], 0);
+
+    cir::StoreOp so = builder.createStore(loc, src, dest, false, true);
+    return so.getValue();
+  }
   case X86::BI__builtin_ia32_vprotbi:
   case X86::BI__builtin_ia32_vprotwi:
   case X86::BI__builtin_ia32_vprotdi:
diff --git a/clang/test/CIR/CodeGen/builtins-x86.c 
b/clang/test/CIR/CodeGen/builtins-x86.c
index f6991b4493f7f..2c8ebfd27eefb 100644
--- a/clang/test/CIR/CodeGen/builtins-x86.c
+++ b/clang/test/CIR/CodeGen/builtins-x86.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -target-feature +avx512vl -fclangir 
-emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -target-feature +avx512vl 
-target-feature +sse4a -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -target-feature +avx512vl -fclangir 
-emit-llvm %s -o %t.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -target-feature +avx512vl 
-target-feature +sse4a -fclangir -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -target-feature +avx512vl -emit-llvm %s 
-o %t-ogcg.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature 
+avx512fp16 -target-feature +avx512bf16 -target-feature +avx512vl 
-target-feature +sse4a -emit-llvm %s -o %t-ogcg.ll
 // RUN: FileCheck --input-file=%t-ogcg.ll %s -check-prefix=OGCG
 
 void test_sfence(void) {
@@ -261,3 +261,31 @@ void test_conditional_bzero(void) {
               : foo())
           : __builtin_bzero(dst, len));
 }
+
+void test_movnti(int dest, int src) {
+  // CIR-LABEL: test_movnti
+  // CIR: %[[VAL:.*]] = cir.load
+  // CIR: cir.store nontemporal {{.*}} %[[VAL]]
+  
+  // LLVM-LABEL: @test_movnti
+  // LLVM: store i32 %{{.*}}, ptr %{{.*}}, align 1, !nontemporal
+  
+  // OGCG-LABEL: @test_movnti
+  // OGCG: store i32 %{{.*}}, ptr %{{.*}}, align 1, !nontemporal
+  return __builtin_ia32_movnti(&dest, src);
+}
+
+void test_movntss(float *dest, v4f src) {
+  // CIR-LABEL: test_movntss
+  // CIR: %[[ARR:.*]] = cir.load align(16) {{.*}} : !cir.ptr<!cir.vector<4 x 
!cir.float>>
+  // CIR: %[[IDX:.*]] = cir.const #cir.int<0>
+  // CIR: %[[SCALAR:.*]] = cir.vec.extract %[[ARR]][%[[IDX]] : !u64i]
+  // CIR: cir.store nontemporal align(1) %[[SCALAR]], {{.*}} : !cir.float, 
!cir.ptr<!cir.float>
+
+  // LLVM-LABEL: @test_movntss
+  // LLVM: store float %{{.*}}, ptr %{{.*}}, align 1, !nontemporal
+
+  // OGCG-LABEL: @test_movntss
+  // OGCG: store float %{{.*}}, ptr %{{.*}}, align 1, !nontemporal 
+  return __builtin_ia32_movntss(dest, src);
+}
\ No newline at end of file

>From 2cda0e717ef9a02028b04e437d18f585e0677709 Mon Sep 17 00:00:00 2001
From: Lucas-Ribeiro-Lima <[email protected]>
Date: Mon, 29 Jun 2026 16:33:57 -0300
Subject: [PATCH 2/2] [clang][CIR] Adjust x86 builtin formatting and missing
 line-feed

---
 clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 4 +++-
 clang/test/CIR/CodeGen/builtins-x86.c      | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 673ba95bccadb..2b5b27fa7cfb2 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -1872,7 +1872,9 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, 
const CallExpr *expr) {
         builtinID == X86::BI__builtin_ia32_movntss)
       src = builder.createExtractElement(loc, ops[1], 0);
 
-    cir::StoreOp so = builder.createStore(loc, src, dest, false, true);
+    cir::StoreOp so =
+        builder.createStore(loc, src, dest,
+                            /*isVolatile=*/false, /*isNontemporal=*/true);
     return so.getValue();
   }
   case X86::BI__builtin_ia32_vprotbi:
diff --git a/clang/test/CIR/CodeGen/builtins-x86.c 
b/clang/test/CIR/CodeGen/builtins-x86.c
index 2c8ebfd27eefb..fa0cfd2fd5322 100644
--- a/clang/test/CIR/CodeGen/builtins-x86.c
+++ b/clang/test/CIR/CodeGen/builtins-x86.c
@@ -288,4 +288,4 @@ void test_movntss(float *dest, v4f src) {
   // OGCG-LABEL: @test_movntss
   // OGCG: store float %{{.*}}, ptr %{{.*}}, align 1, !nontemporal 
   return __builtin_ia32_movntss(dest, src);
-}
\ No newline at end of file
+}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to