[PATCH] D147596: Add baseline tests for icmp(Positive1 * X * Y + Positive2)

Jun Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 01:52:28 PDT 2023


junaire created this revision.
junaire added reviewers: RKSimon, spatel, nikic, goldstein.w.n, bcl5980.
Herald added a subscriber: StephenFan.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Signed-off-by: Jun Zhang <jun at junz.org>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147596

Files:
  llvm/test/Transforms/InstCombine/icmp.ll


Index: llvm/test/Transforms/InstCombine/icmp.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp.ll
+++ llvm/test/Transforms/InstCombine/icmp.ll
@@ -4627,3 +4627,61 @@
   %r = icmp ne i8 %a, 0
   ret i1 %r
 }
+
+define i1 @mul_constant_add_constant_sge(i8 %a, i8 %b) {
+; CHECK-LABEL: @mul_constant_add_constant_sge(
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw i8 [[A:%.*]], 42
+; CHECK-NEXT:    [[MUL1:%.*]] = mul nsw i8 [[MUL]], [[B:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 [[MUL1]], -1
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %mul = mul nsw i8 %a, 42
+  %mul1 = mul nsw i8 %mul, %b
+  %add = or i8 %mul1, 24
+  %cmp = icmp sge i8 %add, 0
+  ret i1 %cmp
+}
+
+define i1 @mul_constant_add_constant_sgt(i8 %a, i8 %b) {
+; CHECK-LABEL: @mul_constant_add_constant_sgt(
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw i8 [[A:%.*]], 42
+; CHECK-NEXT:    [[MUL1:%.*]] = mul nsw i8 [[MUL]], [[B:%.*]]
+; CHECK-NEXT:    [[ADD:%.*]] = or i8 [[MUL1]], 24
+; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 [[ADD]], 0
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %mul = mul nsw i8 %a, 42
+  %mul1 = mul nsw i8 %mul, %b
+  %add = or i8 %mul1, 24
+  %cmp = icmp sgt i8 %add, 0
+  ret i1 %cmp
+}
+
+define i1 @mul_constant_add_constant_sle(i8 %a, i8 %b) {
+; CHECK-LABEL: @mul_constant_add_constant_sle(
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw i8 [[A:%.*]], 42
+; CHECK-NEXT:    [[MUL1:%.*]] = mul nsw i8 [[MUL]], [[B:%.*]]
+; CHECK-NEXT:    [[ADD:%.*]] = or i8 [[MUL1]], 24
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i8 [[ADD]], 1
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %mul = mul nsw i8 %a, 42
+  %mul1 = mul nsw i8 %mul, %b
+  %add = or i8 %mul1, 24
+  %cmp = icmp sle i8 %add, 0
+  ret i1 %cmp
+}
+
+define i1 @mul_constant_add_constant_slt(i8 %a, i8 %b) {
+; CHECK-LABEL: @mul_constant_add_constant_slt(
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw i8 [[A:%.*]], 42
+; CHECK-NEXT:    [[MUL1:%.*]] = mul nsw i8 [[MUL]], [[B:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i8 [[MUL1]], 0
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %mul = mul nsw i8 %a, 42
+  %mul1 = mul nsw i8 %mul, %b
+  %add = or i8 %mul1, 24
+  %cmp = icmp slt i8 %add, 0
+  ret i1 %cmp
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147596.511017.patch
Type: text/x-patch
Size: 2183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230405/a14f1d4d/attachment.bin>


More information about the llvm-commits mailing list