[llvm] f267584 - [CVP] Add coverage for missing mul/shl nowrap variants
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 14 13:01:11 PDT 2022
Author: Philip Reames
Date: 2022-07-14T13:00:55-07:00
New Revision: f26758486399a542893addd83cd3a1056911d8bd
URL: https://github.com/llvm/llvm-project/commit/f26758486399a542893addd83cd3a1056911d8bd
DIFF: https://github.com/llvm/llvm-project/commit/f26758486399a542893addd83cd3a1056911d8bd.diff
LOG: [CVP] Add coverage for missing mul/shl nowrap variants
Added:
Modified:
llvm/test/Transforms/CorrelatedValuePropagation/mul.ll
llvm/test/Transforms/CorrelatedValuePropagation/shl.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll b/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll
index d81c1010f683e..3ac26f4507099 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll
@@ -173,3 +173,48 @@ bb:
exit:
ret i8 0
}
+
+define i1 @nuw_range1(i8 %b) {
+; CHECK-LABEL: @nuw_range1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], 1
+; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[C]], 4
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[MUL]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %c = add nuw nsw i8 %b, 1
+ %mul = mul nuw i8 %c, 4
+ %cmp = icmp eq i8 %mul, 0
+ ret i1 %cmp
+}
+
+define i1 @nuw_range2(i8 %b) {
+; CHECK-LABEL: @nuw_range2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], 3
+; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[C]], 4
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[MUL]], 2
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %c = add nuw nsw i8 %b, 3
+ %mul = mul nuw i8 %c, 4
+ %cmp = icmp ult i8 %mul, 2
+ ret i1 %cmp
+}
+
+define i1 @nsw_range1(i8 %b) {
+; CHECK-LABEL: @nsw_range1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], -3
+; CHECK-NEXT: [[MUL:%.*]] = mul nsw i8 [[C]], 4
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[C]], [[MUL]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %c = add nuw nsw i8 %b, -3
+ %mul = mul nsw i8 %c, 4
+ %cmp = icmp slt i8 %c, %mul
+ ret i1 %cmp
+}
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/shl.ll b/llvm/test/Transforms/CorrelatedValuePropagation/shl.ll
index 6a3001dc6b330..98113cbdae36a 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/shl.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/shl.ll
@@ -376,3 +376,48 @@ bb:
exit:
ret i8 0
}
+
+define i1 @nuw_range1(i8 %b) {
+; CHECK-LABEL: @nuw_range1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], 1
+; CHECK-NEXT: [[SHL:%.*]] = shl nuw i8 [[C]], 2
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[SHL]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %c = add nuw nsw i8 %b, 1
+ %shl = shl nuw i8 %c, 2
+ %cmp = icmp eq i8 %shl, 0
+ ret i1 %cmp
+}
+
+define i1 @nuw_range2(i8 %b) {
+; CHECK-LABEL: @nuw_range2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], 3
+; CHECK-NEXT: [[SHL:%.*]] = shl nuw i8 [[C]], 2
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[SHL]], 2
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %c = add nuw nsw i8 %b, 3
+ %shl = shl nuw i8 %c, 2
+ %cmp = icmp ult i8 %shl, 2
+ ret i1 %cmp
+}
+
+define i1 @nsw_range1(i8 %b) {
+; CHECK-LABEL: @nsw_range1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C:%.*]] = add nuw nsw i8 [[B:%.*]], -3
+; CHECK-NEXT: [[SHL:%.*]] = shl nsw i8 [[C]], 2
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[C]], [[SHL]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ %c = add nuw nsw i8 %b, -3
+ %shl = shl nsw i8 %c, 2
+ %cmp = icmp slt i8 %c, %shl
+ ret i1 %cmp
+}
More information about the llvm-commits
mailing list