[clang] [llvm] [X86] EmitX86BuiltinExpr - attempt to convert SSE41/AVX1 roundps/d/ss/sd builtins to regular rounding modes (PR #171227)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 17 07:34:41 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c -- clang/test/CodeGen/X86/sse41-builtins-constrained.c clang/lib/CodeGen/TargetBuiltins/X86.cpp clang/test/CodeGen/X86/avx-builtins-constrained.c clang/test/CodeGen/X86/avx-builtins.c clang/test/CodeGen/X86/pr51324.c clang/test/CodeGen/X86/sse41-builtins.c --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CodeGen/TargetBuiltins/X86.cpp b/clang/lib/CodeGen/TargetBuiltins/X86.cpp
index f76233d38..6daa7783b 100644
--- a/clang/lib/CodeGen/TargetBuiltins/X86.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/X86.cpp
@@ -75,9 +75,10 @@ static Value *getMaskVecValue(CodeGenFunction &CGF, Value *Mask,
   return MaskVec;
 }
 
-/// Emit rounding for the value \p X according to the rounding \p RoundingControl based on bits 0 and 1.
+/// Emit rounding for the value \p X according to the rounding \p
+/// RoundingControl based on bits 0 and 1.
 static Value *emitX86RoundImmediate(CodeGenFunction &CGF, Value *X,
-                           unsigned RoundingControl) {
+                                    unsigned RoundingControl) {
   unsigned RoundingMask = 0b11;
   unsigned RoundingMode = RoundingControl & RoundingMask;
 
@@ -904,15 +905,24 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
     unsigned UseMXCSR = MXCSRMask & M;
 
     if (UseMXCSR) {
-      
+
       Intrinsic::ID ID = Intrinsic::not_intrinsic;
 
       switch (BuiltinID) {
-        case X86::BI__builtin_ia32_roundps:     ID = Intrinsic::x86_sse41_round_ps; break;
-        case X86::BI__builtin_ia32_roundps256:  ID = Intrinsic::x86_avx_round_ps_256; break;
-        case X86::BI__builtin_ia32_roundpd:     ID = Intrinsic::x86_sse41_round_pd; break;
-        case X86::BI__builtin_ia32_roundpd256:  ID = Intrinsic::x86_avx_round_pd_256; break;
-        default: llvm_unreachable("must return from switch");
+      case X86::BI__builtin_ia32_roundps:
+        ID = Intrinsic::x86_sse41_round_ps;
+        break;
+      case X86::BI__builtin_ia32_roundps256:
+        ID = Intrinsic::x86_avx_round_ps_256;
+        break;
+      case X86::BI__builtin_ia32_roundpd:
+        ID = Intrinsic::x86_sse41_round_pd;
+        break;
+      case X86::BI__builtin_ia32_roundpd256:
+        ID = Intrinsic::x86_avx_round_pd_256;
+        break;
+      default:
+        llvm_unreachable("must return from switch");
       }
 
       Function *F = CGM.getIntrinsic(ID);
@@ -932,9 +942,14 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
       Intrinsic::ID ID = Intrinsic::not_intrinsic;
 
       switch (BuiltinID) {
-        case X86::BI__builtin_ia32_roundss:    ID = Intrinsic::x86_sse41_round_ss; break;
-        case X86::BI__builtin_ia32_roundsd:    ID = Intrinsic::x86_sse41_round_sd; break;
-        default: llvm_unreachable("must return from switch");
+      case X86::BI__builtin_ia32_roundss:
+        ID = Intrinsic::x86_sse41_round_ss;
+        break;
+      case X86::BI__builtin_ia32_roundsd:
+        ID = Intrinsic::x86_sse41_round_sd;
+        break;
+      default:
+        llvm_unreachable("must return from switch");
       }
 
       Function *F = CGM.getIntrinsic(ID);

``````````

</details>


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


More information about the llvm-commits mailing list