[llvm] [PatternMatching] Add generic API for matching constants using custom conditions (PR #85676)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 20:51:13 PDT 2024
================
@@ -421,6 +442,28 @@ define <4 x i1> @lshr_by_const_cmp_sle_value(<4 x i32> %x) {
ret <4 x i1> %r
}
+define <4 x i1> @lshr_by_const_cmp_sle_value_non_splat(<4 x i32> %x) {
+; CHECK-LABEL: @lshr_by_const_cmp_sle_value_non_splat(
+; CHECK-NEXT: [[R:%.*]] = icmp sgt <4 x i32> [[X:%.*]], <i32 -1, i32 -1, i32 -1, i32 -1>
+; CHECK-NEXT: ret <4 x i1> [[R]]
+;
+ %v = lshr <4 x i32> %x, <i32 3, i32 3, i32 3, i32 5>
+ %r = icmp sle <4 x i32> %v, %x
+ ret <4 x i1> %r
+}
+
+
+define <4 x i1> @ashr_by_const_cmp_sge_value_non_splat(<4 x i32> %x) {
+; CHECK-LABEL: @ashr_by_const_cmp_sge_value_non_splat(
+; CHECK-NEXT: [[R:%.*]] = icmp slt <4 x i32> [[X:%.*]], <i32 1, i32 1, i32 1, i32 1>
+; CHECK-NEXT: ret <4 x i1> [[R]]
+;
+ %v = ashr <4 x i32> %x, <i32 1, i32 2, i32 3, i32 4>
+ %r = icmp sge <4 x i32> %v, %x
+ ret <4 x i1> %r
+}
----------------
goldsteinn wrote:
Already had non-splat negative tests (i.e `udiv_x_by_const_cmp_eq_value_neg`). In retrospect probably should have had those tests be scalars as they didn't really check the old logic, but we can use them here.
https://github.com/llvm/llvm-project/pull/85676
More information about the llvm-commits
mailing list