[clang] [CIR] ExtVectorElementExpr with rvalue base (PR #168260)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 17 11:45:44 PST 2025


================
@@ -1189,9 +1189,15 @@ LValue CIRGenFunction::emitExtVectorElementExpr(const ExtVectorElementExpr *e) {
     base = emitLValue(e->getBase());
   } else {
     // Otherwise, the base is a normal rvalue (as in (V+V).x), emit it as such.
-    cgm.errorNYI(e->getSourceRange(),
-                 "emitExtVectorElementExpr: base is a normal rvalue");
-    return {};
+    assert(e->getBase()->getType()->isVectorType() &&
+           "Result must be a vector");
+    mlir::Value vec = emitScalarExpr(e->getBase());
+
+    // Store the vector to memory (because LValue wants an address).
+    QualType baseTy = e->getBase()->getType();
+    Address vecMem = createMemTemp(baseTy, vec.getLoc(), "tmp");
+    builder.createStore(vec.getLoc(), vec, vecMem);
----------------
andykaylor wrote:

Classic codegen has some recently added code here to handle a vector of bools by zero-extending. See https://github.com/llvm/llvm-project/pull/123977

We should update this to handle that case.

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


More information about the cfe-commits mailing list