summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll58
-rw-r--r--llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll58
2 files changed, 116 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll b/llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll
index 693d9c98da5..f46bcdfc997 100644
--- a/llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll
+++ b/llvm/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
; ============================================================================ ;
@@ -76,6 +88,52 @@ define i1 @c0() {
}
; ============================================================================ ;
+; 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/llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll b/llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll
index 84c872b6ba5..850266381e7 100644
--- a/llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ne-to-icmp-ugt.ll
+++ b/llvm/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
; ============================================================================ ;
@@ -76,6 +88,52 @@ define i1 @c0() {
}
; ============================================================================ ;
+; 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.
; ============================================================================ ;
OpenPOWER on IntegriCloud