; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s ; Verify that DAG combine rules for LD1 + sext/zext don't apply when the ; result of LD1 has multiple uses define @no_dag_combine_zext_sext( %pg, ; CHECK-LABEL: no_dag_combine_zext_sext: ; CHECK: // %bb.0: ; CHECK-NEXT: ld1b { z0.d }, p0/z, [z0.d, #16] ; CHECK-NEXT: st1b { z0.d }, p1, [x0] ; CHECK-NEXT: and z0.d, z0.d, #0xff ; CHECK-NEXT: ret %base, * %res_out, %pred) { %load = call @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64( %pg, %base, i64 16) %res1 = zext %load to %res2 = sext %load to call void @llvm.masked.store.nxv2i8( %load, *%res_out, i32 8, %pred) ret %res1 } define @no_dag_combine_sext( %pg, ; CHECK-LABEL: no_dag_combine_sext: ; CHECK: // %bb.0: ; CHECK-NEXT: ld1b { z1.d }, p0/z, [z0.d, #16] ; CHECK-NEXT: ptrue p2.d ; CHECK-NEXT: movprfx z0, z1 ; CHECK-NEXT: sxtb z0.d, p2/m, z1.d ; CHECK-NEXT: st1b { z1.d }, p1, [x0] ; CHECK-NEXT: ret %base, * %res_out, %pred) { %load = call @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64( %pg, %base, i64 16) %res = sext %load to call void @llvm.masked.store.nxv2i8( %load, *%res_out, i32 8, %pred) ret %res } define @no_dag_combine_zext( %pg, ; CHECK-LABEL: no_dag_combine_zext: ; CHECK: // %bb.0: ; CHECK-NEXT: ld1b { z0.d }, p0/z, [z0.d, #16] ; CHECK-NEXT: st1b { z0.d }, p1, [x0] ; CHECK-NEXT: and z0.d, z0.d, #0xff ; CHECK-NEXT: ret %base, * %res_out, %pred) { %load = call @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64( %pg, %base, i64 16) %res = zext %load to call void @llvm.masked.store.nxv2i8( %load, *%res_out, i32 8, %pred) ret %res } define @narrow_i64_gather_index_i8_zext(i8* %out, i8* %in, %d, i64 %ptr){ ; CHECK-LABEL: narrow_i64_gather_index_i8_zext: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: add x8, x1, x2 ; CHECK-NEXT: ld1b { z0.s }, p0/z, [x8, #3, mul vl] ; CHECK-NEXT: ld1b { z1.s }, p0/z, [x1, x2] ; CHECK-NEXT: ld1b { z2.s }, p0/z, [x8, #1, mul vl] ; CHECK-NEXT: ld1b { z3.s }, p0/z, [x8, #2, mul vl] ; CHECK-NEXT: ld1b { z0.s }, p0/z, [x1, z0.s, uxtw] ; CHECK-NEXT: ld1b { z3.s }, p0/z, [x1, z3.s, uxtw] ; CHECK-NEXT: ld1b { z1.s }, p0/z, [x1, z1.s, uxtw] ; CHECK-NEXT: ld1b { z2.s }, p0/z, [x1, z2.s, uxtw] ; CHECK-NEXT: uzp1 z0.h, z3.h, z0.h ; CHECK-NEXT: uzp1 z1.h, z1.h, z2.h ; CHECK-NEXT: uzp1 z0.b, z1.b, z0.b ; CHECK-NEXT: ret %1 = getelementptr inbounds i8, i8* %in, i64 %ptr %2 = bitcast i8* %1 to * %wide.load = load , * %2, align 1 %3 = zext %wide.load to %4 = getelementptr inbounds i8, i8* %in, %3 %wide.masked.gather = call @llvm.masked.gather.nxv16i8.nxv16p0( %4, i32 1, shufflevector ( insertelement ( poison, i1 true, i32 0), poison, zeroinitializer), undef) ret %wide.masked.gather } define @narrow_i64_gather_index_i8_sext(i8* %out, i8* %in, %d, i64 %ptr){ ; CHECK-LABEL: narrow_i64_gather_index_i8_sext: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: add x8, x1, x2 ; CHECK-NEXT: ld1sb { z0.s }, p0/z, [x8, #3, mul vl] ; CHECK-NEXT: ld1sb { z1.s }, p0/z, [x1, x2] ; CHECK-NEXT: ld1sb { z2.s }, p0/z, [x8, #1, mul vl] ; CHECK-NEXT: ld1sb { z3.s }, p0/z, [x8, #2, mul vl] ; CHECK-NEXT: ld1b { z0.s }, p0/z, [x1, z0.s, sxtw] ; CHECK-NEXT: ld1b { z3.s }, p0/z, [x1, z3.s, sxtw] ; CHECK-NEXT: ld1b { z1.s }, p0/z, [x1, z1.s, sxtw] ; CHECK-NEXT: ld1b { z2.s }, p0/z, [x1, z2.s, sxtw] ; CHECK-NEXT: uzp1 z0.h, z3.h, z0.h ; CHECK-NEXT: uzp1 z1.h, z1.h, z2.h ; CHECK-NEXT: uzp1 z0.b, z1.b, z0.b ; CHECK-NEXT: ret %1 = getelementptr inbounds i8, i8* %in, i64 %ptr %2 = bitcast i8* %1 to * %wide.load = load , * %2, align 1 %3 = sext %wide.load to %4 = getelementptr inbounds i8, i8* %in, %3 %wide.masked.gather = call @llvm.masked.gather.nxv16i8.nxv16p0( %4, i32 1, shufflevector ( insertelement ( poison, i1 true, i32 0), poison, zeroinitializer), undef) ret %wide.masked.gather } define @narrow_i64_gather_index_i16_zext(i16* %out, i16* %in, %d, i64 %ptr){ ; CHECK-LABEL: narrow_i64_gather_index_i16_zext: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: add x8, x1, x2, lsl #1 ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x1, x2, lsl #1] ; CHECK-NEXT: ld1h { z1.s }, p0/z, [x8, #1, mul vl] ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x1, z0.s, uxtw #1] ; CHECK-NEXT: ld1h { z1.s }, p0/z, [x1, z1.s, uxtw #1] ; CHECK-NEXT: uzp1 z0.h, z0.h, z1.h ; CHECK-NEXT: ret %1 = getelementptr inbounds i16, i16* %in, i64 %ptr %2 = bitcast i16* %1 to * %wide.load = load , * %2, align 1 %3 = zext %wide.load to %4 = getelementptr inbounds i16, i16* %in, %3 %wide.masked.gather = call @llvm.masked.gather.nxv8i16.nxv8p0( %4, i32 1, shufflevector ( insertelement ( poison, i1 true, i32 0), poison, zeroinitializer), undef) ret %wide.masked.gather } define @narrow_i64_gather_index_i16_sext(i16* %out, i16* %in, %d, i64 %ptr){ ; CHECK-LABEL: narrow_i64_gather_index_i16_sext: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: add x8, x1, x2, lsl #1 ; CHECK-NEXT: ld1sh { z0.s }, p0/z, [x1, x2, lsl #1] ; CHECK-NEXT: ld1sh { z1.s }, p0/z, [x8, #1, mul vl] ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x1, z0.s, sxtw #1] ; CHECK-NEXT: ld1h { z1.s }, p0/z, [x1, z1.s, sxtw #1] ; CHECK-NEXT: uzp1 z0.h, z0.h, z1.h ; CHECK-NEXT: ret %1 = getelementptr inbounds i16, i16* %in, i64 %ptr %2 = bitcast i16* %1 to * %wide.load = load , * %2, align 1 %3 = sext %wide.load to %4 = getelementptr inbounds i16, i16* %in, %3 %wide.masked.gather = call @llvm.masked.gather.nxv8i16.nxv8p0( %4, i32 1, shufflevector ( insertelement ( poison, i1 true, i32 0), poison, zeroinitializer), undef) ret %wide.masked.gather } define @no_narrow_i64_gather_index_i32(i32* %out, i32* %in, %d, i64 %ptr){ ; CHECK-LABEL: no_narrow_i64_gather_index_i32: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.s ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x1, x2, lsl #2] ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x1, z0.s, uxtw #2] ; CHECK-NEXT: ret %1 = getelementptr inbounds i32, i32* %in, i64 %ptr %2 = bitcast i32* %1 to * %wide.load = load , * %2, align 1 %3 = zext %wide.load to %4 = getelementptr inbounds i32, i32* %in, %3 %wide.masked.gather = call @llvm.masked.gather.nxv4i32.nxv4p0( %4, i32 1, shufflevector ( insertelement ( poison, i1 true, i32 0), poison, zeroinitializer), undef) ret %wide.masked.gather } define @no_narrow_i64_gather_index_i64(i64* %out, i64* %in, %d, i64 %ptr){ ; CHECK-LABEL: no_narrow_i64_gather_index_i64: ; CHECK: // %bb.0: ; CHECK-NEXT: ptrue p0.d ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x1, x2, lsl #3] ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x1, z0.d, lsl #3] ; CHECK-NEXT: ret %1 = getelementptr inbounds i64, i64* %in, i64 %ptr %2 = bitcast i64* %1 to * %wide.load = load , * %2, align 1 %3 = getelementptr inbounds i64, i64* %in, %wide.load %wide.masked.gather = call @llvm.masked.gather.nxv2i64.nxv2p0( %3, i32 1, shufflevector ( insertelement ( poison, i1 true, i32 0), poison, zeroinitializer), undef) ret %wide.masked.gather } declare @llvm.aarch64.sve.ld1.gather.scalar.offset.nxv2i8.nxv2i64(, , i64) declare void @llvm.masked.store.nxv2i8(, *, i32, ) declare @llvm.masked.gather.nxv16i8.nxv16p0(, i32, , ) declare @llvm.masked.gather.nxv8i16.nxv8p0(, i32, , ) declare @llvm.masked.gather.nxv4i32.nxv4p0(, i32, , ) declare @llvm.masked.gather.nxv2i64.nxv2p0(, i32, , )