[clang] [HLSL] Extract matrix elementwise cast operands from SSA (PR #227065)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 10:58:28 PDT 2026


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 -- clang/lib/CodeGen/CGExprScalar.cpp --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/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 488df3345..5ee0eeffd 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2549,13 +2549,14 @@ bool CodeGenFunction::ShouldNullCheckClassCastValue(const CastExpr *CE) {
 }
 
 template <typename GetElementTy>
-static Value *EmitHLSLElementwiseCastToVector(
-    CodeGenFunction &CGF, QualType DestTy, unsigned NumSrcElements,
-    GetElementTy GetElement, SourceLocation Loc) {
+static Value *
+EmitHLSLElementwiseCastToVector(CodeGenFunction &CGF, QualType DestTy,
+                                unsigned NumSrcElements,
+                                GetElementTy GetElement, SourceLocation Loc) {
   const auto *VecTy = DestTy->castAs<VectorType>();
   assert(NumSrcElements >= VecTy->getNumElements() &&
-           "Flattened type on RHS must have the same number or more elements "
-           "than vector on LHS.");
+         "Flattened type on RHS must have the same number or more elements "
+         "than vector on LHS.");
   Value *V = CGF.Builder.CreateLoad(
       CGF.CreateIRTempWithoutCast(DestTy, "flatcast.tmp"));
   for (unsigned I = 0, E = VecTy->getNumElements(); I < E; ++I) {
@@ -3211,8 +3212,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
           [&](unsigned I) {
             unsigned Row = I / SrcMatTy->getNumColumns();
             unsigned Col = I % SrcMatTy->getNumColumns();
-            unsigned Idx =
-                SrcMatTy->getColumnMajorFlattenedIndex(Row, Col);
+            unsigned Idx = SrcMatTy->getColumnMajorFlattenedIndex(Row, Col);
             Value *Element =
                 Builder.CreateExtractElement(SrcVal, Idx, "matrixext");
             Element = CGF.EmitFromMemory(Element, SrcMatTy->getElementType());

``````````

</details>


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


More information about the cfe-commits mailing list