[clang] [CIR] Fix VecExtract index type in Vec truncation cast (PR #246065)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 25 08:59:13 PST 2026


================
@@ -3009,8 +3009,10 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *ce) {
       std::iota(mask.begin(), mask.end(), 0);
       return builder.createVecShuffle(loc, vec, mask);
     }
-    return builder.createExtractElement(loc, vec, /*idx=*/0);
+    mlir::Value idx = builder.getConstInt(loc, cgf.sizeTy, 0);
----------------
erichkeane wrote:

Accepting a type or an mlir::Value are both much better approaches IMO.

I DO see the 'bare' index here though which leaves me VERY concerned.  The amount of fixes we've had to do with the 'large negative 32 bit value coerced to 64 bits and then being weird' is pretty high :D 

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


More information about the cfe-commits mailing list