; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s ; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t ; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it. ; WARN-NOT: warning define @sel_8_positive( %p) { ; CHECK-LABEL: sel_8_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.b, p0/z, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i8 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_16_positive( %p) { ; CHECK-LABEL: sel_16_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.h, p0/z, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_32_positive( %p) { ; CHECK-LABEL: sel_32_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.s, p0/z, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_64_positive( %p) { ; CHECK-LABEL: sel_64_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.d, p0/z, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_8_negative( %p) { ; CHECK-LABEL: sel_8_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.b, p0/z, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i8 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_16_negative( %p) { ; CHECK-LABEL: sel_16_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.h, p0/z, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_32_negative( %p) { ; CHECK-LABEL: sel_32_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.s, p0/z, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_64_negative( %p) { ; CHECK-LABEL: sel_64_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.d, p0/z, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_16_shifted( %p) { ; CHECK-LABEL: sel_16_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.h, p0/z, #512 // =0x200 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 512, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_32_shifted( %p) { ; CHECK-LABEL: sel_32_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.s, p0/z, #512 // =0x200 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 512, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_64_shifted( %p) { ; CHECK-LABEL: sel_64_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.d, p0/z, #512 // =0x200 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 512, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } ; TODO: We could actually use something like "cpy z0.b, p0/z, #-128". But it's ; a little tricky to prove correctness: we're using the predicate with the ; wrong width, so we'd have to prove the bits which would normally be unused ; are actually zero. define @sel_16_illegal_wrong_extension( %p) { ; CHECK-LABEL: sel_16_illegal_wrong_extension: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #128 ; CHECK-NEXT: mov z0.h, w8 ; CHECK-NEXT: mov z1.h, #0 // =0x0 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_32_illegal_wrong_extension( %p) { ; CHECK-LABEL: sel_32_illegal_wrong_extension: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #128 ; CHECK-NEXT: mov z0.s, w8 ; CHECK-NEXT: mov z1.s, #0 // =0x0 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_64_illegal_wrong_extension( %p) { ; CHECK-LABEL: sel_64_illegal_wrong_extension: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #128 ; CHECK-NEXT: mov z0.d, x8 ; CHECK-NEXT: mov z1.d, #0 // =0x0 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_16_illegal_shifted( %p) { ; CHECK-LABEL: sel_16_illegal_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #513 ; CHECK-NEXT: mov z0.h, w8 ; CHECK-NEXT: mov z1.h, #0 // =0x0 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 513, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_32_illegal_shifted( %p) { ; CHECK-LABEL: sel_32_illegal_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #513 ; CHECK-NEXT: mov z0.s, w8 ; CHECK-NEXT: mov z1.s, #0 // =0x0 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 513, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_64_illegal_shifted( %p) { ; CHECK-LABEL: sel_64_illegal_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #513 ; CHECK-NEXT: mov z0.d, x8 ; CHECK-NEXT: mov z1.d, #0 // =0x0 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 513, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, zeroinitializer ret %sel } define @sel_merge_8_positive( %p, %in) { ; CHECK-LABEL: sel_merge_8_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.b, p0/m, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i8 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_16_positive( %p, %in) { ; CHECK-LABEL: sel_merge_16_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.h, p0/m, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_32_positive( %p, %in) { ; CHECK-LABEL: sel_merge_32_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.s, p0/m, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_64_positive( %p, %in) { ; CHECK-LABEL: sel_merge_64_positive: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.d, p0/m, #3 // =0x3 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 3, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_8_negative( %p, %in) { ; CHECK-LABEL: sel_merge_8_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.b, p0/m, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i8 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_16_negative( %p, %in) { ; CHECK-LABEL: sel_merge_16_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.h, p0/m, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_32_negative( %p, %in) { ; CHECK-LABEL: sel_merge_32_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.s, p0/m, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_64_negative( %p, %in) { ; CHECK-LABEL: sel_merge_64_negative: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.d, p0/m, #-128 // =0xffffffffffffff80 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 -128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_8_zero( %p, %in) { ; CHECK-LABEL: sel_merge_8_zero: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.b, p0/m, #0 // =0x0 ; CHECK-NEXT: ret %sel = select %p, zeroinitializer, %in ret %sel } define @sel_merge_16_zero( %p, %in) { ; CHECK-LABEL: sel_merge_16_zero: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.h, p0/m, #0 // =0x0 ; CHECK-NEXT: ret %sel = select %p, zeroinitializer, %in ret %sel } define @sel_merge_32_zero( %p, %in) { ; CHECK-LABEL: sel_merge_32_zero: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.s, p0/m, #0 // =0x0 ; CHECK-NEXT: ret %sel = select %p, zeroinitializer, %in ret %sel } define @sel_merge_64_zero( %p, %in) { ; CHECK-LABEL: sel_merge_64_zero: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.d, p0/m, #0 // =0x0 ; CHECK-NEXT: ret %sel = select %p, zeroinitializer, %in ret %sel } define @sel_merge_16_shifted( %p, %in) { ; CHECK-LABEL: sel_merge_16_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.h, p0/m, #512 // =0x200 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 512, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_32_shifted( %p, %in) { ; CHECK-LABEL: sel_merge_32_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.s, p0/m, #512 // =0x200 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 512, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_64_shifted( %p, %in) { ; CHECK-LABEL: sel_merge_64_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov z0.d, p0/m, #512 // =0x200 ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 512, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } ; TODO: We could actually use something like "cpy z0.b, p0/m, #-128". But it's ; a little tricky to prove correctness: we're using the predicate with the ; wrong width, so we'd have to prove the bits which would normally be unused ; are actually zero. define @sel_merge_16_illegal_wrong_extension( %p, %in) { ; CHECK-LABEL: sel_merge_16_illegal_wrong_extension: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #128 ; CHECK-NEXT: mov z1.h, w8 ; CHECK-NEXT: mov z0.h, p0/m, z1.h ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_32_illegal_wrong_extension( %p, %in) { ; CHECK-LABEL: sel_merge_32_illegal_wrong_extension: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #128 ; CHECK-NEXT: mov z1.s, w8 ; CHECK-NEXT: mov z0.s, p0/m, z1.s ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_64_illegal_wrong_extension( %p, %in) { ; CHECK-LABEL: sel_merge_64_illegal_wrong_extension: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #128 ; CHECK-NEXT: mov z1.d, x8 ; CHECK-NEXT: mov z0.d, p0/m, z1.d ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 128, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_16_illegal_shifted( %p, %in) { ; CHECK-LABEL: sel_merge_16_illegal_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #513 ; CHECK-NEXT: mov z1.h, w8 ; CHECK-NEXT: mov z0.h, p0/m, z1.h ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i16 513, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_32_illegal_shifted( %p, %in) { ; CHECK-LABEL: sel_merge_32_illegal_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #513 ; CHECK-NEXT: mov z1.s, w8 ; CHECK-NEXT: mov z0.s, p0/m, z1.s ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i32 513, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel } define @sel_merge_64_illegal_shifted( %p, %in) { ; CHECK-LABEL: sel_merge_64_illegal_shifted: ; CHECK: // %bb.0: ; CHECK-NEXT: mov w8, #513 ; CHECK-NEXT: mov z1.d, x8 ; CHECK-NEXT: mov z0.d, p0/m, z1.d ; CHECK-NEXT: ret %vec = shufflevector insertelement ( undef, i64 513, i32 0), zeroinitializer, zeroinitializer %sel = select %p, %vec, %in ret %sel }