llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Akimasa Watanuki (Men-cotton)

<details>
<summary>Changes</summary>

In `ScalarExprEmitter::VisitCastExpr`, guard `CK_VectorSplat` so 
`cir::VecSplatOp` is only created for a valid scalar value.

Update clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl to use 
`-verify` with expected CIR NYI diagnostics.

---
Full diff: https://github.com/llvm/llvm-project/pull/182817.diff


2 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+4-1) 
- (modified) clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl (+6-6) 


``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index d523aa2fdb737..e5f17d720ee86 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -2371,9 +2371,12 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr 
*ce) {
   case CK_VectorSplat: {
     // Create a vector object and fill all elements with the same scalar value.
     assert(destTy->isVectorType() && "CK_VectorSplat to non-vector type");
+    mlir::Value scalar = Visit(subExpr);
+    if (!scalar)
+      return {};
     return cir::VecSplatOp::create(builder,
                                    cgf.getLoc(subExpr->getSourceRange()),
-                                   cgf.convertType(destTy), Visit(subExpr));
+                                   cgf.convertType(destTy), scalar);
   }
   case CK_FunctionToPointerDecay:
     return cgf.emitLValue(subExpr).getPointer();
diff --git a/clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl 
b/clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl
index 279075a6dab60..f3c6d1fefd1f0 100644
--- a/clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl
+++ b/clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl
@@ -1,8 +1,8 @@
-// RUN: not %clang_cc1 -x hlsl -finclude-default-header -triple 
spirv-unknown-vulkan-compute %s \
-// RUN:   -fclangir -emit-cir -disable-llvm-passes 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -x hlsl -finclude-default-header -triple 
spirv-unknown-vulkan-compute %s \
+// RUN:   -fclangir -emit-cir -disable-llvm-passes -verify
 
-// CHECK: ClangIR code gen Not Yet Implemented: processing of type: 
ConstantMatrix
-float1 test_zero_indexed(float2x2 M) { 
-  // CHECK: ClangIR code gen Not Yet Implemented: ScalarExprEmitter: matrix 
element
-  return M._m00; 
+// expected-error@*:* {{ClangIR code gen Not Yet Implemented: processing of 
type: ConstantMatrix}}
+float1 test_zero_indexed(float2x2 M) {
+  // expected-error@+1 {{ClangIR code gen Not Yet Implemented: 
ScalarExprEmitter: matrix element}}
+  return M._m00;
 }

``````````

</details>


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

Reply via email to