; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+sve | FileCheck %s -check-prefixes=CHECK,SVE ; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+sve2 | FileCheck %s -check-prefixes=CHECK,SVE2 define @hadds_v2i64( %s0, %s1) { ; SVE-LABEL: hadds_v2i64: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.d, z2.d, #1 ; SVE-NEXT: add z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v2i64: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: shadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i128 1) %s2 = trunc %s to ret %s2 } define @hadds_v2i64_lsh( %s0, %s1) { ; SVE-LABEL: hadds_v2i64_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.d, z2.d, #1 ; SVE-NEXT: add z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v2i64_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: shadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i128 1) %s2 = trunc %s to ret %s2 } define @haddu_v2i64( %s0, %s1) { ; SVE-LABEL: haddu_v2i64: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.d, z2.d, #1 ; SVE-NEXT: add z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v2i64: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: uhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i128 1) %s2 = trunc %s to ret %s2 } define @hadds_v2i32( %s0, %s1) { ; SVE-LABEL: hadds_v2i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.d ; SVE-NEXT: sxtw z0.d, p0/m, z0.d ; SVE-NEXT: adr z0.d, [z0.d, z1.d, sxtw] ; SVE-NEXT: asr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v2i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: sxtw z1.d, p0/m, z1.d ; SVE2-NEXT: sxtw z0.d, p0/m, z0.d ; SVE2-NEXT: shadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i64 1) %s2 = trunc %s to ret %s2 } define @hadds_v2i32_lsh( %s0, %s1) { ; CHECK-LABEL: hadds_v2i32_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.d ; CHECK-NEXT: sxtw z0.d, p0/m, z0.d ; CHECK-NEXT: adr z0.d, [z0.d, z1.d, sxtw] ; CHECK-NEXT: lsr z0.d, z0.d, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i64 1) %s2 = trunc %s to ret %s2 } define @haddu_v2i32( %s0, %s1) { ; SVE-LABEL: haddu_v2i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z0.d, z0.d, #0xffffffff ; SVE-NEXT: adr z0.d, [z0.d, z1.d, uxtw] ; SVE-NEXT: lsr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v2i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.d, z1.d, #0xffffffff ; SVE2-NEXT: and z0.d, z0.d, #0xffffffff ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: uhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i64 1) %s2 = trunc %s to ret %s2 } define @hadds_v4i32( %s0, %s1) { ; SVE-LABEL: hadds_v4i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.s, z2.s, #1 ; SVE-NEXT: add z0.s, z0.s, z1.s ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v4i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: shadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i64 1) %s2 = trunc %s to ret %s2 } define @hadds_v4i32_lsh( %s0, %s1) { ; SVE-LABEL: hadds_v4i32_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.s, z2.s, #1 ; SVE-NEXT: add z0.s, z0.s, z1.s ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v4i32_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: shadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i64 1) %s2 = trunc %s to ret %s2 } define @haddu_v4i32( %s0, %s1) { ; SVE-LABEL: haddu_v4i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.s, z2.s, #1 ; SVE-NEXT: add z0.s, z0.s, z1.s ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v4i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: uhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i64 1) %s2 = trunc %s to ret %s2 } define @hadds_v2i16( %s0, %s1) { ; SVE-LABEL: hadds_v2i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.d ; SVE-NEXT: sxth z1.d, p0/m, z1.d ; SVE-NEXT: sxth z0.d, p0/m, z0.d ; SVE-NEXT: add z0.d, z0.d, z1.d ; SVE-NEXT: asr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v2i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: sxth z1.d, p0/m, z1.d ; SVE2-NEXT: sxth z0.d, p0/m, z0.d ; SVE2-NEXT: shadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @hadds_v2i16_lsh( %s0, %s1) { ; CHECK-LABEL: hadds_v2i16_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.d ; CHECK-NEXT: sxth z0.d, p0/m, z0.d ; CHECK-NEXT: sxth z1.d, p0/m, z1.d ; CHECK-NEXT: add z0.d, z0.d, z1.d ; CHECK-NEXT: and z0.d, z0.d, #0xffffffff ; CHECK-NEXT: lsr z0.d, z0.d, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @haddu_v2i16( %s0, %s1) { ; SVE-LABEL: haddu_v2i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z1.d, z1.d, #0xffff ; SVE-NEXT: and z0.d, z0.d, #0xffff ; SVE-NEXT: add z0.d, z0.d, z1.d ; SVE-NEXT: lsr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v2i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.d, z1.d, #0xffff ; SVE2-NEXT: and z0.d, z0.d, #0xffff ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: uhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @hadds_v4i16( %s0, %s1) { ; SVE-LABEL: hadds_v4i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.s ; SVE-NEXT: sxth z1.s, p0/m, z1.s ; SVE-NEXT: sxth z0.s, p0/m, z0.s ; SVE-NEXT: add z0.s, z0.s, z1.s ; SVE-NEXT: asr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v4i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: sxth z1.s, p0/m, z1.s ; SVE2-NEXT: sxth z0.s, p0/m, z0.s ; SVE2-NEXT: shadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @hadds_v4i16_lsh( %s0, %s1) { ; CHECK-LABEL: hadds_v4i16_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: sxth z0.s, p0/m, z0.s ; CHECK-NEXT: sxth z1.s, p0/m, z1.s ; CHECK-NEXT: add z0.s, z0.s, z1.s ; CHECK-NEXT: lsr z0.s, z0.s, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @haddu_v4i16( %s0, %s1) { ; SVE-LABEL: haddu_v4i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z1.s, z1.s, #0xffff ; SVE-NEXT: and z0.s, z0.s, #0xffff ; SVE-NEXT: add z0.s, z0.s, z1.s ; SVE-NEXT: lsr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v4i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.s, z1.s, #0xffff ; SVE2-NEXT: and z0.s, z0.s, #0xffff ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: uhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @hadds_v8i16( %s0, %s1) { ; SVE-LABEL: hadds_v8i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.h, z2.h, #1 ; SVE-NEXT: add z0.h, z0.h, z1.h ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v8i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: shadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @hadds_v8i16_lsh( %s0, %s1) { ; SVE-LABEL: hadds_v8i16_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.h, z2.h, #1 ; SVE-NEXT: add z0.h, z0.h, z1.h ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v8i16_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: shadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @haddu_v8i16( %s0, %s1) { ; SVE-LABEL: haddu_v8i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.h, z2.h, #1 ; SVE-NEXT: add z0.h, z0.h, z1.h ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v8i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: uhadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i32 1) %s2 = trunc %s to ret %s2 } define @hadds_v4i8( %s0, %s1) { ; SVE-LABEL: hadds_v4i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.s ; SVE-NEXT: sxtb z1.s, p0/m, z1.s ; SVE-NEXT: sxtb z0.s, p0/m, z0.s ; SVE-NEXT: add z0.s, z0.s, z1.s ; SVE-NEXT: asr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v4i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: sxtb z1.s, p0/m, z1.s ; SVE2-NEXT: sxtb z0.s, p0/m, z0.s ; SVE2-NEXT: shadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @hadds_v4i8_lsh( %s0, %s1) { ; CHECK-LABEL: hadds_v4i8_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: sxtb z0.s, p0/m, z0.s ; CHECK-NEXT: sxtb z1.s, p0/m, z1.s ; CHECK-NEXT: add z0.s, z0.s, z1.s ; CHECK-NEXT: and z0.s, z0.s, #0xffff ; CHECK-NEXT: lsr z0.s, z0.s, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @haddu_v4i8( %s0, %s1) { ; SVE-LABEL: haddu_v4i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z1.s, z1.s, #0xff ; SVE-NEXT: and z0.s, z0.s, #0xff ; SVE-NEXT: add z0.s, z0.s, z1.s ; SVE-NEXT: lsr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v4i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.s, z1.s, #0xff ; SVE2-NEXT: and z0.s, z0.s, #0xff ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: uhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @hadds_v8i8( %s0, %s1) { ; SVE-LABEL: hadds_v8i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.h ; SVE-NEXT: sxtb z1.h, p0/m, z1.h ; SVE-NEXT: sxtb z0.h, p0/m, z0.h ; SVE-NEXT: add z0.h, z0.h, z1.h ; SVE-NEXT: asr z0.h, z0.h, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v8i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: sxtb z1.h, p0/m, z1.h ; SVE2-NEXT: sxtb z0.h, p0/m, z0.h ; SVE2-NEXT: shadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @hadds_v8i8_lsh( %s0, %s1) { ; CHECK-LABEL: hadds_v8i8_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.h ; CHECK-NEXT: sxtb z0.h, p0/m, z0.h ; CHECK-NEXT: sxtb z1.h, p0/m, z1.h ; CHECK-NEXT: add z0.h, z0.h, z1.h ; CHECK-NEXT: lsr z0.h, z0.h, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @haddu_v8i8( %s0, %s1) { ; SVE-LABEL: haddu_v8i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z1.h, z1.h, #0xff ; SVE-NEXT: and z0.h, z0.h, #0xff ; SVE-NEXT: add z0.h, z0.h, z1.h ; SVE-NEXT: lsr z0.h, z0.h, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v8i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.h, z1.h, #0xff ; SVE2-NEXT: and z0.h, z0.h, #0xff ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: uhadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @hadds_v16i8( %s0, %s1) { ; SVE-LABEL: hadds_v16i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.b, z2.b, #1 ; SVE-NEXT: add z0.b, z0.b, z1.b ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v16i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.b ; SVE2-NEXT: shadd z0.b, p0/m, z0.b, z1.b ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = ashr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @hadds_v16i8_lsh( %s0, %s1) { ; SVE-LABEL: hadds_v16i8_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.b, z2.b, #1 ; SVE-NEXT: add z0.b, z0.b, z1.b ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v16i8_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.b ; SVE2-NEXT: shadd z0.b, p0/m, z0.b, z1.b ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %m = add nsw %s0s, %s1s %s = lshr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @haddu_v16i8( %s0, %s1) { ; SVE-LABEL: haddu_v16i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.b, z2.b, #1 ; SVE-NEXT: add z0.b, z0.b, z1.b ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v16i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.b ; SVE2-NEXT: uhadd z0.b, p0/m, z0.b, z1.b ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %m = add nuw nsw %s0s, %s1s %s = lshr %m, splat (i16 1) %s2 = trunc %s to ret %s2 } define @rhadds_v2i64( %s0, %s1) { ; SVE-LABEL: rhadds_v2i64: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.d, z2.d, #1 ; SVE-NEXT: sub z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v2i64: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: srhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i128 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i128 1) %result = trunc %s to ret %result } define @rhadds_v2i64_lsh( %s0, %s1) { ; SVE-LABEL: rhadds_v2i64_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.d, z2.d, #1 ; SVE-NEXT: sub z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v2i64_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: srhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i128 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i128 1) %result = trunc %s to ret %result } define @rhaddu_v2i64( %s0, %s1) { ; SVE-LABEL: rhaddu_v2i64: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.d, z2.d, #1 ; SVE-NEXT: sub z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v2i64: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: urhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i128 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i128 1) %result = trunc %s to ret %result } define @rhadds_v2i32( %s0, %s1) { ; SVE-LABEL: rhadds_v2i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.d ; SVE-NEXT: sxtw z0.d, p0/m, z0.d ; SVE-NEXT: sxtw z1.d, p0/m, z1.d ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.d, z1.d, z0.d ; SVE-NEXT: asr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v2i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: sxtw z1.d, p0/m, z1.d ; SVE2-NEXT: sxtw z0.d, p0/m, z0.d ; SVE2-NEXT: srhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i64 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i64 1) %result = trunc %s to ret %result } define @rhadds_v2i32_lsh( %s0, %s1) { ; CHECK-LABEL: rhadds_v2i32_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.d ; CHECK-NEXT: sxtw z0.d, p0/m, z0.d ; CHECK-NEXT: sxtw z1.d, p0/m, z1.d ; CHECK-NEXT: subr z0.b, z0.b, #255 // =0xff ; CHECK-NEXT: sub z0.d, z1.d, z0.d ; CHECK-NEXT: lsr z0.d, z0.d, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i64 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i64 1) %result = trunc %s to ret %result } define @rhaddu_v2i32( %s0, %s1) { ; SVE-LABEL: rhaddu_v2i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z0.d, z0.d, #0xffffffff ; SVE-NEXT: and z1.d, z1.d, #0xffffffff ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.d, z1.d, z0.d ; SVE-NEXT: lsr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v2i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.d, z1.d, #0xffffffff ; SVE2-NEXT: and z0.d, z0.d, #0xffffffff ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: urhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i64 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i64 1) %result = trunc %s to ret %result } define @rhadds_v4i32( %s0, %s1) { ; SVE-LABEL: rhadds_v4i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.s, z2.s, #1 ; SVE-NEXT: sub z0.s, z0.s, z1.s ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v4i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: srhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i64 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i64 1) %result = trunc %s to ret %result } define @rhadds_v4i32_lsh( %s0, %s1) { ; SVE-LABEL: rhadds_v4i32_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.s, z2.s, #1 ; SVE-NEXT: sub z0.s, z0.s, z1.s ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v4i32_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: srhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i64 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i64 1) %result = trunc %s to ret %result } define @rhaddu_v4i32( %s0, %s1) { ; SVE-LABEL: rhaddu_v4i32: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.s, z2.s, #1 ; SVE-NEXT: sub z0.s, z0.s, z1.s ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v4i32: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: urhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i64 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i64 1) %result = trunc %s to ret %result } define @rhadds_v2i16( %s0, %s1) { ; SVE-LABEL: rhadds_v2i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.d ; SVE-NEXT: sxth z0.d, p0/m, z0.d ; SVE-NEXT: sxth z1.d, p0/m, z1.d ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.d, z1.d, z0.d ; SVE-NEXT: asr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v2i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: sxth z1.d, p0/m, z1.d ; SVE2-NEXT: sxth z0.d, p0/m, z0.d ; SVE2-NEXT: srhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i32 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhadds_v2i16_lsh( %s0, %s1) { ; CHECK-LABEL: rhadds_v2i16_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.d ; CHECK-NEXT: sxth z0.d, p0/m, z0.d ; CHECK-NEXT: sxth z1.d, p0/m, z1.d ; CHECK-NEXT: subr z0.b, z0.b, #255 // =0xff ; CHECK-NEXT: sub z0.d, z1.d, z0.d ; CHECK-NEXT: and z0.d, z0.d, #0xffffffff ; CHECK-NEXT: lsr z0.d, z0.d, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i32 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhaddu_v2i16( %s0, %s1) { ; SVE-LABEL: rhaddu_v2i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z0.d, z0.d, #0xffff ; SVE-NEXT: and z1.d, z1.d, #0xffff ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.d, z1.d, z0.d ; SVE-NEXT: lsr z0.d, z0.d, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v2i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.d, z1.d, #0xffff ; SVE2-NEXT: and z0.d, z0.d, #0xffff ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: urhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i32 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhadds_v4i16( %s0, %s1) { ; SVE-LABEL: rhadds_v4i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.s ; SVE-NEXT: sxth z0.s, p0/m, z0.s ; SVE-NEXT: sxth z1.s, p0/m, z1.s ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.s, z1.s, z0.s ; SVE-NEXT: asr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v4i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: sxth z1.s, p0/m, z1.s ; SVE2-NEXT: sxth z0.s, p0/m, z0.s ; SVE2-NEXT: srhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i32 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhadds_v4i16_lsh( %s0, %s1) { ; CHECK-LABEL: rhadds_v4i16_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: sxth z0.s, p0/m, z0.s ; CHECK-NEXT: sxth z1.s, p0/m, z1.s ; CHECK-NEXT: subr z0.b, z0.b, #255 // =0xff ; CHECK-NEXT: sub z0.s, z1.s, z0.s ; CHECK-NEXT: lsr z0.s, z0.s, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i32 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhaddu_v4i16( %s0, %s1) { ; SVE-LABEL: rhaddu_v4i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z0.s, z0.s, #0xffff ; SVE-NEXT: and z1.s, z1.s, #0xffff ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.s, z1.s, z0.s ; SVE-NEXT: lsr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v4i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.s, z1.s, #0xffff ; SVE2-NEXT: and z0.s, z0.s, #0xffff ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: urhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i32 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhadds_v8i16( %s0, %s1) { ; SVE-LABEL: rhadds_v8i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.h, z2.h, #1 ; SVE-NEXT: sub z0.h, z0.h, z1.h ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v8i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: srhadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i32 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhadds_v8i16_lsh( %s0, %s1) { ; SVE-LABEL: rhadds_v8i16_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.h, z2.h, #1 ; SVE-NEXT: sub z0.h, z0.h, z1.h ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v8i16_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: srhadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i32 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhaddu_v8i16( %s0, %s1) { ; SVE-LABEL: rhaddu_v8i16: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.h, z2.h, #1 ; SVE-NEXT: sub z0.h, z0.h, z1.h ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v8i16: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: urhadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i32 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i32 1) %result = trunc %s to ret %result } define @rhadds_v4i8( %s0, %s1) { ; SVE-LABEL: rhadds_v4i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.s ; SVE-NEXT: sxtb z0.s, p0/m, z0.s ; SVE-NEXT: sxtb z1.s, p0/m, z1.s ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.s, z1.s, z0.s ; SVE-NEXT: asr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v4i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: sxtb z1.s, p0/m, z1.s ; SVE2-NEXT: sxtb z0.s, p0/m, z0.s ; SVE2-NEXT: srhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i16 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhadds_v4i8_lsh( %s0, %s1) { ; CHECK-LABEL: rhadds_v4i8_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: sxtb z0.s, p0/m, z0.s ; CHECK-NEXT: sxtb z1.s, p0/m, z1.s ; CHECK-NEXT: subr z0.b, z0.b, #255 // =0xff ; CHECK-NEXT: sub z0.s, z1.s, z0.s ; CHECK-NEXT: and z0.s, z0.s, #0xffff ; CHECK-NEXT: lsr z0.s, z0.s, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i16 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhaddu_v4i8( %s0, %s1) { ; SVE-LABEL: rhaddu_v4i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z0.s, z0.s, #0xff ; SVE-NEXT: and z1.s, z1.s, #0xff ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.s, z1.s, z0.s ; SVE-NEXT: lsr z0.s, z0.s, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v4i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.s, z1.s, #0xff ; SVE2-NEXT: and z0.s, z0.s, #0xff ; SVE2-NEXT: ptrue p0.s ; SVE2-NEXT: urhadd z0.s, p0/m, z0.s, z1.s ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i16 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhadds_v8i8( %s0, %s1) { ; SVE-LABEL: rhadds_v8i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: ptrue p0.h ; SVE-NEXT: sxtb z0.h, p0/m, z0.h ; SVE-NEXT: sxtb z1.h, p0/m, z1.h ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.h, z1.h, z0.h ; SVE-NEXT: asr z0.h, z0.h, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v8i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: sxtb z1.h, p0/m, z1.h ; SVE2-NEXT: sxtb z0.h, p0/m, z0.h ; SVE2-NEXT: srhadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i16 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhadds_v8i8_lsh( %s0, %s1) { ; CHECK-LABEL: rhadds_v8i8_lsh: ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: ptrue p0.h ; CHECK-NEXT: sxtb z0.h, p0/m, z0.h ; CHECK-NEXT: sxtb z1.h, p0/m, z1.h ; CHECK-NEXT: subr z0.b, z0.b, #255 // =0xff ; CHECK-NEXT: sub z0.h, z1.h, z0.h ; CHECK-NEXT: lsr z0.h, z0.h, #1 ; CHECK-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i16 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhaddu_v8i8( %s0, %s1) { ; SVE-LABEL: rhaddu_v8i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: and z0.h, z0.h, #0xff ; SVE-NEXT: and z1.h, z1.h, #0xff ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.h, z1.h, z0.h ; SVE-NEXT: lsr z0.h, z0.h, #1 ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v8i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: and z1.h, z1.h, #0xff ; SVE2-NEXT: and z0.h, z0.h, #0xff ; SVE2-NEXT: ptrue p0.h ; SVE2-NEXT: urhadd z0.h, p0/m, z0.h, z1.h ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i16 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhadds_v16i8( %s0, %s1) { ; SVE-LABEL: rhadds_v16i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.b, z2.b, #1 ; SVE-NEXT: sub z0.b, z0.b, z1.b ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v16i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.b ; SVE2-NEXT: srhadd z0.b, p0/m, z0.b, z1.b ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i16 1) %add2 = add %add, %s1s %s = ashr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhadds_v16i8_lsh( %s0, %s1) { ; SVE-LABEL: rhadds_v16i8_lsh: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.b, z2.b, #1 ; SVE-NEXT: sub z0.b, z0.b, z1.b ; SVE-NEXT: ret ; ; SVE2-LABEL: rhadds_v16i8_lsh: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.b ; SVE2-NEXT: srhadd z0.b, p0/m, z0.b, z1.b ; SVE2-NEXT: ret entry: %s0s = sext %s0 to %s1s = sext %s1 to %add = add %s0s, splat (i16 1) %add2 = add %add, %s1s %s = lshr %add2, splat (i16 1) %result = trunc %s to ret %result } define @rhaddu_v16i8( %s0, %s1) { ; SVE-LABEL: rhaddu_v16i8: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: orr z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.b, z2.b, #1 ; SVE-NEXT: sub z0.b, z0.b, z1.b ; SVE-NEXT: ret ; ; SVE2-LABEL: rhaddu_v16i8: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.b ; SVE2-NEXT: urhadd z0.b, p0/m, z0.b, z1.b ; SVE2-NEXT: ret entry: %s0s = zext %s0 to %s1s = zext %s1 to %add = add nuw nsw %s0s, splat (i16 1) %add2 = add nuw nsw %add, %s1s %s = lshr %add2, splat (i16 1) %result = trunc %s to ret %result } define @haddu_v2i64_add( %s0, %s1) { ; SVE-LABEL: haddu_v2i64_add: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: lsr z1.d, z2.d, #1 ; SVE-NEXT: add z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: haddu_v2i64_add: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: uhadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %add = add nuw nsw %s0, %s1 %avg = lshr %add, splat (i64 1) ret %avg } define @hadds_v2i64_add( %s0, %s1) { ; SVE-LABEL: hadds_v2i64_add: ; SVE: // %bb.0: // %entry ; SVE-NEXT: eor z2.d, z0.d, z1.d ; SVE-NEXT: and z0.d, z0.d, z1.d ; SVE-NEXT: asr z1.d, z2.d, #1 ; SVE-NEXT: add z0.d, z0.d, z1.d ; SVE-NEXT: ret ; ; SVE2-LABEL: hadds_v2i64_add: ; SVE2: // %bb.0: // %entry ; SVE2-NEXT: ptrue p0.d ; SVE2-NEXT: shadd z0.d, p0/m, z0.d, z1.d ; SVE2-NEXT: ret entry: %add = add nuw nsw %s0, %s1 %avg = ashr %add, splat (i64 1) ret %avg } define void @zext_mload_avgflooru(ptr %p1, ptr %p2, %mask) { ; SVE-LABEL: zext_mload_avgflooru: ; SVE: // %bb.0: ; SVE-NEXT: ld1b { z0.h }, p0/z, [x0] ; SVE-NEXT: ld1b { z1.h }, p0/z, [x1] ; SVE-NEXT: add z0.h, z0.h, z1.h ; SVE-NEXT: lsr z0.h, z0.h, #1 ; SVE-NEXT: st1h { z0.h }, p0, [x0] ; SVE-NEXT: ret ; ; SVE2-LABEL: zext_mload_avgflooru: ; SVE2: // %bb.0: ; SVE2-NEXT: ld1b { z0.h }, p0/z, [x0] ; SVE2-NEXT: ld1b { z1.h }, p0/z, [x1] ; SVE2-NEXT: ptrue p1.h ; SVE2-NEXT: uhadd z0.h, p1/m, z0.h, z1.h ; SVE2-NEXT: st1h { z0.h }, p0, [x0] ; SVE2-NEXT: ret %ld1 = call @llvm.masked.load(ptr %p1, i32 16, %mask, zeroinitializer) %ld2 = call @llvm.masked.load(ptr %p2, i32 16, %mask, zeroinitializer) %and = and %ld1, %ld2 %xor = xor %ld1, %ld2 %shift = lshr %xor, splat(i8 1) %avg = add %and, %shift %avgext = zext %avg to call void @llvm.masked.store.nxv8i16( %avgext, ptr %p1, i32 16, %mask) ret void } define void @zext_mload_avgceilu(ptr %p1, ptr %p2, %mask) { ; SVE-LABEL: zext_mload_avgceilu: ; SVE: // %bb.0: ; SVE-NEXT: ld1b { z0.h }, p0/z, [x0] ; SVE-NEXT: ld1b { z1.h }, p0/z, [x1] ; SVE-NEXT: subr z0.b, z0.b, #255 // =0xff ; SVE-NEXT: sub z0.h, z1.h, z0.h ; SVE-NEXT: lsr z0.h, z0.h, #1 ; SVE-NEXT: st1b { z0.h }, p0, [x0] ; SVE-NEXT: ret ; ; SVE2-LABEL: zext_mload_avgceilu: ; SVE2: // %bb.0: ; SVE2-NEXT: ld1b { z0.h }, p0/z, [x0] ; SVE2-NEXT: ld1b { z1.h }, p0/z, [x1] ; SVE2-NEXT: ptrue p1.h ; SVE2-NEXT: urhadd z0.h, p1/m, z0.h, z1.h ; SVE2-NEXT: st1b { z0.h }, p0, [x0] ; SVE2-NEXT: ret %ld1 = call @llvm.masked.load(ptr %p1, i32 16, %mask, zeroinitializer) %ld2 = call @llvm.masked.load(ptr %p2, i32 16, %mask, zeroinitializer) %zext1 = zext %ld1 to %zext2 = zext %ld2 to %add1 = add nuw nsw %zext1, splat(i16 1) %add2 = add nuw nsw %add1, %zext2 %shift = lshr %add2, splat(i16 1) %trunc = trunc %shift to call void @llvm.masked.store.nxv8i8( %trunc, ptr %p1, i32 16, %mask) ret void }