From: Roman Lebedev Date: Sat, 14 Jul 2018 12:19:56 +0000 (+0000) Subject: [NFC][InstCombine] Add forgotten variable tests for foldICmpWithLowBitMaskedVal() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=695087654097c0ebbd5139fa3b422abbe8d7b76b;p=llvm [NFC][InstCombine] Add forgotten variable tests for foldICmpWithLowBitMaskedVal() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337094 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll b/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll index 693d9c98da5..f46bcdfc997 100644 --- a/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll +++ b/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll @@ -23,6 +23,18 @@ define i1 @p0(i8 %x) { ret i1 %ret } +define i1 @pv(i8 %x, i8 %y) { +; CHECK-LABEL: @pv( +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i8 [[TMP0]], [[X:%.*]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %tmp0, %x + %ret = icmp eq i8 %tmp1, %x + ret i1 %ret +} + ; ============================================================================ ; ; Vector tests ; ============================================================================ ; @@ -75,6 +87,52 @@ define i1 @c0() { ret i1 %ret } +; ============================================================================ ; +; Commutativity tests with variable +; ============================================================================ ; + +define i1 @cv0(i8 %y) { +; CHECK-LABEL: @cv0( +; CHECK-NEXT: [[X:%.*]] = call i8 @gen8() +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i8 [[X]], [[TMP0]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %x = call i8 @gen8() + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %x, %tmp0 ; swapped order + %ret = icmp eq i8 %tmp1, %x + ret i1 %ret +} + +define i1 @cv1(i8 %y) { +; CHECK-LABEL: @cv1( +; CHECK-NEXT: [[X:%.*]] = call i8 @gen8() +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i8 [[X]], [[TMP0]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %x = call i8 @gen8() + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %tmp0, %x + %ret = icmp eq i8 %x, %tmp1 ; swapped order + ret i1 %ret +} + +define i1 @cv2(i8 %y) { +; CHECK-LABEL: @cv2( +; CHECK-NEXT: [[X:%.*]] = call i8 @gen8() +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i8 [[X]], [[TMP0]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %x = call i8 @gen8() + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %x, %tmp0 ; swapped order + %ret = icmp eq i8 %x, %tmp1 ; swapped order + ret i1 %ret +} + ; ============================================================================ ; ; One-use tests. We don't care about multi-uses here. ; ============================================================================ ; diff --git a/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll b/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll index 84c872b6ba5..850266381e7 100644 --- a/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll +++ b/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll @@ -23,6 +23,18 @@ define i1 @p0(i8 %x) { ret i1 %ret } +define i1 @pv(i8 %x, i8 %y) { +; CHECK-LABEL: @pv( +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[TMP0]], [[X:%.*]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %tmp0, %x + %ret = icmp ne i8 %tmp1, %x + ret i1 %ret +} + ; ============================================================================ ; ; Vector tests ; ============================================================================ ; @@ -75,6 +87,52 @@ define i1 @c0() { ret i1 %ret } +; ============================================================================ ; +; Commutativity tests with variable +; ============================================================================ ; + +define i1 @cv0(i8 %y) { +; CHECK-LABEL: @cv0( +; CHECK-NEXT: [[X:%.*]] = call i8 @gen8() +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X]], [[TMP0]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %x = call i8 @gen8() + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %x, %tmp0 ; swapped order + %ret = icmp ne i8 %tmp1, %x + ret i1 %ret +} + +define i1 @cv1(i8 %y) { +; CHECK-LABEL: @cv1( +; CHECK-NEXT: [[X:%.*]] = call i8 @gen8() +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X]], [[TMP0]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %x = call i8 @gen8() + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %tmp0, %x + %ret = icmp ne i8 %x, %tmp1 ; swapped order + ret i1 %ret +} + +define i1 @cv2(i8 %y) { +; CHECK-LABEL: @cv2( +; CHECK-NEXT: [[X:%.*]] = call i8 @gen8() +; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X]], [[TMP0]] +; CHECK-NEXT: ret i1 [[TMP1]] +; + %x = call i8 @gen8() + %tmp0 = lshr i8 -1, %y + %tmp1 = and i8 %x, %tmp0 ; swapped order + %ret = icmp ne i8 %x, %tmp1 ; swapped order + ret i1 %ret +} + ; ============================================================================ ; ; One-use tests. We don't care about multi-uses here. ; ============================================================================ ;