[llvm] [DAGCombiner] Fold extract_vector(get_active_lane_mask(), 0) to get_active_lane_mask (PR #208978)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 04:24:40 PDT 2026
================
@@ -598,4 +598,106 @@ if.end:
ret void
}
+; Test combining of getActiveLaneMask with extract_vector(idx=0) operations.
+
+define void @test_8bit_mask_with_32bit_index_and_trip_count(i32 %i, i32 %n) #0 {
+; CHECK-SVE-LABEL: test_8bit_mask_with_32bit_index_and_trip_count:
+; CHECK-SVE: // %bb.0:
+; CHECK-SVE-NEXT: whilelo p0.h, w0, w1
+; CHECK-SVE-NEXT: // fake_use: $p0
+; CHECK-SVE-NEXT: ret
+;
+; CHECK-SVE2p1-SME2-LABEL: test_8bit_mask_with_32bit_index_and_trip_count:
+; CHECK-SVE2p1-SME2: // %bb.0:
+; CHECK-SVE2p1-SME2-NEXT: whilelo p0.h, w0, w1
+; CHECK-SVE2p1-SME2-NEXT: // fake_use: $p0
+; CHECK-SVE2p1-SME2-NEXT: ret
+ %r = call <vscale x 16 x i1> @llvm.get.active.lane.mask.nxv16i1.i32(i32 %i, i32 %n)
+ %v0 = call <vscale x 8 x i1> @llvm.vector.extract.nxv8i1.nxv16i1.i64(<vscale x 16 x i1> %r, i64 0)
+ call void (...) @llvm.fake.use(<vscale x 8 x i1> %v0)
----------------
paulwalker-arm wrote:
Are the calls to fake.use necessary? I'd rather we just return %v0 unless there's a good reason not to.
https://github.com/llvm/llvm-project/pull/208978
More information about the llvm-commits
mailing list