[clang] [Clang] Fix incorrect type for `__mfp8` in `extractelement` codegen (PR #192977)
Momchil Velikov via cfe-commits
cfe-commits at lists.llvm.org
Fri May 8 05:26:00 PDT 2026
================
@@ -2213,7 +2213,14 @@ Value *ScalarExprEmitter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
if (CGF.SanOpts.has(SanitizerKind::ArrayBounds))
CGF.EmitBoundsCheck(E, E->getBase(), Idx, IdxTy, /*Accessed*/true);
- return Builder.CreateExtractElement(Base, Idx, "vecext");
+ Value *Ret = Builder.CreateExtractElement(Base, Idx, "vecext");
+
+ // Even being a scalar the `__mfp8` type corresponds to `<1 x i8>` in LLVM IR.
+ // Cast the extracted element to the vector type to keep it consistent in
+ // Clang.
+ if (E->getType()->isMFloat8Type())
+ Ret = Builder.CreateBitCast(Ret, ConvertType(E->getType()), "mfp8ext");
----------------
momchil-velikov wrote:
Seem `insertelement` is the most sensible op to emit and it will either be left intact by `instcombine` or changed to a `shufflevector` if the index is a constant.
https://github.com/llvm/llvm-project/pull/192977
More information about the cfe-commits
mailing list