[clang] [CIR][AArch64] Upstream narrowing-addition NEON builtins (PR #204989)

Vicky Nguyen via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 22 16:47:43 PDT 2026


================
@@ -685,7 +685,28 @@ static mlir::Value emitCommonNeonBuiltinExpr(
     mlir::Value result = cgf.getBuilder().createXor(loc, ops[0], ops[1]);
     return cgf.getBuilder().createBitcast(result, ty);
   }
-  case NEON::BI__builtin_neon_vaddhn_v:
+  case NEON::BI__builtin_neon_vaddhn_v: {
+    cir::VectorType srcTy =
+        cgf.getBuilder().getExtendedOrTruncatedElementVectorType(
+            vTy, /*isExtended=*/true, /*isSigned=*/false);
+
+    // %sum = add <4 x i32> %lhs, %rhs
+    ops[0] = cgf.getBuilder().createBitcast(ops[0], srcTy);
+    ops[1] = cgf.getBuilder().createBitcast(ops[1], srcTy);
----------------
iamvickynguyen wrote:

You're right that the bitcast part in `ARM.cpp` is dead

https://github.com/llvm/llvm-project/blob/a7263bea29efd710a1207afe5641fad54692284d/clang/lib/CodeGen/TargetBuiltins/ARM.cpp#L1193-L1199

`getExtendedElementVectorType` only extends the size, so `CreateBitCast` with the same type in and type out is a no-op.

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


More information about the cfe-commits mailing list