[llvm] [SDAG] Lower range attribute to AssertZext (PR #95450)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 12:38:27 PDT 2024


================
@@ -34,6 +34,24 @@ define i64 @widen_assertzext(ptr %x) nounwind {
   ret i64 %d
 }
 
+define i64 @widen_assertzext_range_attr(ptr %x) nounwind {
+; CHECK-LABEL: widen_assertzext_range_attr:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    callq test2 at PLT
+; CHECK-NEXT:    movb $127, %al
+; CHECK-NEXT:    kmovw %eax, %k1
+; CHECK-NEXT:    vpexpandq %zmm0, %zmm0 {%k1} {z}
+; CHECK-NEXT:    vextracti32x4 $3, %zmm0, %xmm0
+; CHECK-NEXT:    vmovq %xmm0, %rax
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    vzeroupper
+; CHECK-NEXT:    retq
+  %e = call noundef range(i64 0, 2) <7 x i64> @test2()
+  %d = extractelement <7 x i64> %e, i32 6
+  ret i64 %d
+}
+
----------------
nikic wrote:

Not sure what you mean here, the test was modified when the noundef requirement was added.

But yes, please add a variant with range to something like llvm/test/CodeGen/AArch64/lower-range-metadata-func-call.ll, rather than this test. This test is for a legalization edge case, while what you want to show is that the AssertZExt improves codegen.

https://github.com/llvm/llvm-project/pull/95450


More information about the llvm-commits mailing list