[llvm] 9565457 - [InstCombine] add tests for icmp with 'or' ops; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 7 13:39:48 PDT 2021
Author: Sanjay Patel
Date: 2021-09-07T16:34:00-04:00
New Revision: 9565457aad3459339c9dbd5064a8a2708fc032a9
URL: https://github.com/llvm/llvm-project/commit/9565457aad3459339c9dbd5064a8a2708fc032a9
DIFF: https://github.com/llvm/llvm-project/commit/9565457aad3459339c9dbd5064a8a2708fc032a9.diff
LOG: [InstCombine] add tests for icmp with 'or' ops; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-or.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-or.ll b/llvm/test/Transforms/InstCombine/icmp-or.ll
index ac2274e86724..f7c03feb3eea 100644
--- a/llvm/test/Transforms/InstCombine/icmp-or.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-or.ll
@@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
+declare void @use(i8)
+
define i1 @set_low_bit_mask_eq(i8 %x) {
; CHECK-LABEL: @set_low_bit_mask_eq(
; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X:%.*]], -2
@@ -109,3 +111,97 @@ define i1 @set_low_bit_mask_sle(i8 %x) {
ret i1 %cmp
}
+define i1 @eq_const_mask(i8 %x, i8 %y) {
+; CHECK-LABEL: @eq_const_mask(
+; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 42
+; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 42
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %b0 = or i8 %x, 42
+ %b1 = or i8 %y, 42
+ %cmp = icmp eq i8 %b0, %b1
+ ret i1 %cmp
+}
+
+define <2 x i1> @ne_const_mask(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @ne_const_mask(
+; CHECK-NEXT: [[B0:%.*]] = or <2 x i8> [[X:%.*]], <i8 -106, i8 5>
+; CHECK-NEXT: [[B1:%.*]] = or <2 x i8> [[Y:%.*]], <i8 -106, i8 5>
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i8> [[B0]], [[B1]]
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %b0 = or <2 x i8> %x, <i8 150, i8 5>
+ %b1 = or <2 x i8> %y, <i8 150, i8 5>
+ %cmp = icmp ne <2 x i8> %b0, %b1
+ ret <2 x i1> %cmp
+}
+
+define i1 @eq_const_mask_not_equality(i8 %x, i8 %y) {
+; CHECK-LABEL: @eq_const_mask_not_equality(
+; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
+; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 5
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[B0]], [[B1]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %b0 = or i8 %x, 5
+ %b1 = or i8 %y, 5
+ %cmp = icmp sgt i8 %b0, %b1
+ ret i1 %cmp
+}
+
+define i1 @eq_const_mask_not_same(i8 %x, i8 %y) {
+; CHECK-LABEL: @eq_const_mask_not_same(
+; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
+; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 6
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %b0 = or i8 %x, 5
+ %b1 = or i8 %y, 6
+ %cmp = icmp eq i8 %b0, %b1
+ ret i1 %cmp
+}
+
+define i1 @eq_const_mask_wrong_opcode(i8 %x, i8 %y) {
+; CHECK-LABEL: @eq_const_mask_wrong_opcode(
+; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
+; CHECK-NEXT: [[B1:%.*]] = xor i8 [[Y:%.*]], 5
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %b0 = or i8 %x, 5
+ %b1 = xor i8 %y, 5
+ %cmp = icmp eq i8 %b0, %b1
+ ret i1 %cmp
+}
+
+define i1 @eq_const_mask_use1(i8 %x, i8 %y) {
+; CHECK-LABEL: @eq_const_mask_use1(
+; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
+; CHECK-NEXT: call void @use(i8 [[B0]])
+; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 5
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %b0 = or i8 %x, 5
+ call void @use(i8 %b0)
+ %b1 = or i8 %y, 5
+ %cmp = icmp eq i8 %b0, %b1
+ ret i1 %cmp
+}
+
+define i1 @eq_const_mask_use2(i8 %x, i8 %y) {
+; CHECK-LABEL: @eq_const_mask_use2(
+; CHECK-NEXT: [[B0:%.*]] = or i8 [[X:%.*]], 5
+; CHECK-NEXT: [[B1:%.*]] = or i8 [[Y:%.*]], 5
+; CHECK-NEXT: call void @use(i8 [[B1]])
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[B0]], [[B1]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %b0 = or i8 %x, 5
+ %b1 = or i8 %y, 5
+ call void @use(i8 %b1)
+ %cmp = icmp eq i8 %b0, %b1
+ ret i1 %cmp
+}
More information about the llvm-commits
mailing list