diff --git a/llvm/test/CodeGen/AArch64/sve-extract-element.ll b/llvm/test/CodeGen/AArch64/sve-extract-element.ll --- a/llvm/test/CodeGen/AArch64/sve-extract-element.ll +++ b/llvm/test/CodeGen/AArch64/sve-extract-element.ll @@ -501,6 +501,23 @@ ret i1 %b } +define i1 @test_last_8xi1( %a) #0 { +; CHECK-LABEL: test_last_8xi1: +; CHECK: // %bb.0: +; CHECK-NEXT: cnth x8 +; CHECK-NEXT: mov z0.h, p0/z, #1 // =0x1 +; CHECK-NEXT: sub x8, x8, #1 +; CHECK-NEXT: whilels p0.h, xzr, x8 +; CHECK-NEXT: lastb w8, p0, z0.h +; CHECK-NEXT: and w0, w8, #0x1 +; CHECK-NEXT: ret + %vscale = call i64 @llvm.vscale.i64() + %shl = shl nuw nsw i64 %vscale, 3 + %idx = add nuw nsw i64 %shl, -1 + %bit = extractelement %a, i64 %idx + ret i1 %bit +} + define i1 @test_lanex_4xi1( %a, i32 %x) #0 { ; CHECK-LABEL: test_lanex_4xi1: ; CHECK: // %bb.0: @@ -527,4 +544,6 @@ ret i1 %b } +declare i64 @llvm.vscale.i64() + attributes #0 = { "target-features"="+sve" }