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

Andrzej WarzyƄski via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 22 03:20:31 PDT 2026


================

----------------
banach-space wrote:

Could you restore the check-lines that track the input variables? For example:
```

// CHECK-LABEL: define dso_local <4 x i16> @test_vhadd_s16(
// CHECK-SAME: <4 x i16> noundef [[V1:%.*]], <4 x i16> noundef [[V2:%.*]]) #[[ATTR0]] {
// CHECK-NEXT:  [[ENTRY:.*:]]
// CHECK-NEXT:    [[TMP0:%.*]] = bitcast <4 x i16> [[V1]] to <8 x i8>
// CHECK-NEXT:    [[TMP1:%.*]] = bitcast <4 x i16> [[V2]] to <8 x i8>
// CHECK-NEXT:    [[VHADD_V_I:%.*]] = bitcast <8 x i8> [[TMP0]] to <4 x i16>
// CHECK-NEXT:    [[VHADD_V1_I:%.*]] = bitcast <8 x i8> [[TMP1]] to <4 x i16>
// CHECK-NEXT:    [[VHADD_V2_I:%.*]] = call <4 x i16> @llvm.aarch64.neon.shadd.v4i16(<4 x i16> [[VHADD_V_I]], <4 x i16> [[VHADD_V1_I]])
// CHECK-NEXT:    [[VHADD_V3_I:%.*]] = bitcast <4 x i16> [[VHADD_V2_I]] to <8 x i8>
// CHECK-NEXT:    [[TMP2:%.*]] = bitcast <8 x i8> [[VHADD_V3_I]] to <4 x i16>
// CHECK-NEXT:    ret <4 x i16> [[TMP2]]
//
int16x4_t test_vhadd_s16(int16x4_t v1, int16x4_t v2) {
  return vhadd_s16(v1, v2);
}
```

I am hoping that we can actually avoid the bit-casts. If that doesn't work, you could try adding some `opt` flags to simplify the output (e.g. `-instcombine`).

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


More information about the cfe-commits mailing list