[llvm] [LazyValueInfo] Support vector types in ICmp condition handling (PR #192900)

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 18:47:41 PDT 2026


================
@@ -219,6 +219,34 @@ define <2 x float> @sitofp(<2 x i8> %a) {
   ret <2 x float> %res
 }
 
+; The and is redundant when the icmp condition guarantees the value is in range.
+define <16 x i16> @select_and_icmp_vector(<16 x i16> noundef %x) {
+; CHECK-LABEL: define range(i16 0, 25) <16 x i16> @select_and_icmp_vector(
+; CHECK-SAME: <16 x i16> noundef [[X:%.*]]) {
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult <16 x i16> [[X]], splat (i16 8)
+; CHECK-NEXT:    [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i16> [[X]], <16 x i16> splat (i16 24)
+; CHECK-NEXT:    ret <16 x i16> [[SEL]]
+;
+  %and = and <16 x i16> %x, splat (i16 7)
+  %cmp = icmp ult <16 x i16> %x, splat (i16 8)
+  %sel = select <16 x i1> %cmp, <16 x i16> %and, <16 x i16> splat (i16 24)
+  ret <16 x i16> %sel
+}
+
+define <2 x i16> @select_and_icmp_nonsplat(<2 x i16> noundef %x) {
+; CHECK-LABEL: define range(i16 0, 31) <2 x i16> @select_and_icmp_nonsplat(
+; CHECK-SAME: <2 x i16> noundef [[X:%.*]]) {
+; CHECK-NEXT:    [[AND:%.*]] = and <2 x i16> [[X]], <i16 7, i16 15>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult <2 x i16> [[X]], <i16 4, i16 8>
+; CHECK-NEXT:    [[SEL:%.*]] = select <2 x i1> [[CMP]], <2 x i16> [[AND]], <2 x i16> <i16 24, i16 30>
+; CHECK-NEXT:    ret <2 x i16> [[SEL]]
+;
+  %and = and <2 x i16> %x, <i16 7, i16 15>
----------------
tclin914 wrote:

Addressed. Thanks

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


More information about the llvm-commits mailing list