[llvm] bc032c7 - [InstCombine] add tests for div with shl operands; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 06:26:40 PDT 2022
Author: Sanjay Patel
Date: 2022-10-12T09:25:04-04:00
New Revision: bc032c7f53463fe1e0b2d3eab6c72299a184b6c1
URL: https://github.com/llvm/llvm-project/commit/bc032c7f53463fe1e0b2d3eab6c72299a184b6c1
DIFF: https://github.com/llvm/llvm-project/commit/bc032c7f53463fe1e0b2d3eab6c72299a184b6c1.diff
LOG: [InstCombine] add tests for div with shl operands; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/div-shift.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/div-shift.ll b/llvm/test/Transforms/InstCombine/div-shift.ll
index c266fa76247b..0100886a0350 100644
--- a/llvm/test/Transforms/InstCombine/div-shift.ll
+++ b/llvm/test/Transforms/InstCombine/div-shift.ll
@@ -741,3 +741,139 @@ define i8 @sdiv_lshr_mul_nsw(i8 %x, i8 %y, i8 %z) {
%div = sdiv i8 %s, %x
ret i8 %div
}
+
+define i8 @sdiv_shl_shl_nsw2_nuw(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @sdiv_shl_shl_nsw2_nuw(
+; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nuw nsw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nsw i8 %x, %z
+ %yz = shl nsw nuw i8 %y, %z
+ %d = sdiv i8 %xz, %yz
+ ret i8 %d
+}
+
+define i8 @sdiv_shl_shl_nsw2_nuw_exact_use(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @sdiv_shl_shl_nsw2_nuw_exact_use(
+; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: call void @use(i8 [[XZ]])
+; CHECK-NEXT: [[YZ:%.*]] = shl nuw nsw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = sdiv exact i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nsw i8 %x, %z
+ call void @use(i8 %xz)
+ %yz = shl nsw nuw i8 %y, %z
+ %d = sdiv exact i8 %xz, %yz
+ ret i8 %d
+}
+
+define i8 @sdiv_shl_shl_nsw_nuw2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @sdiv_shl_shl_nsw_nuw2(
+; CHECK-NEXT: [[XZ:%.*]] = shl nuw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nuw nsw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nuw i8 %x, %z
+ %yz = shl nsw nuw i8 %y, %z
+ %d = sdiv i8 %xz, %yz
+ ret i8 %d
+}
+
+define i8 @sdiv_shl_shl_nsw_nuw(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @sdiv_shl_shl_nsw_nuw(
+; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nuw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nsw i8 %x, %z
+ %yz = shl nuw i8 %y, %z
+ %d = sdiv i8 %xz, %yz
+ ret i8 %d
+}
+
+define i8 @sdiv_shl_shl_nuw_nsw2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @sdiv_shl_shl_nuw_nsw2(
+; CHECK-NEXT: [[XZ:%.*]] = shl nuw nsw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nsw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nuw nsw i8 %x, %z
+ %yz = shl nsw i8 %y, %z
+ %d = sdiv i8 %xz, %yz
+ ret i8 %d
+}
+
+define <2 x i8> @udiv_shl_shl_nuw2(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
+; CHECK-LABEL: @udiv_shl_shl_nuw2(
+; CHECK-NEXT: [[XZ:%.*]] = shl nuw <2 x i8> [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nuw <2 x i8> [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = udiv <2 x i8> [[XZ]], [[YZ]]
+; CHECK-NEXT: ret <2 x i8> [[D]]
+;
+ %xz = shl nuw <2 x i8> %x, %z
+ %yz = shl nuw <2 x i8> %y, %z
+ %d = udiv <2 x i8> %xz, %yz
+ ret <2 x i8> %d
+}
+
+define i8 @udiv_shl_shl_nuw2_exact_use2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_shl_shl_nuw2_exact_use2(
+; CHECK-NEXT: [[XZ:%.*]] = shl nuw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: call void @use(i8 [[XZ]])
+; CHECK-NEXT: [[YZ:%.*]] = shl nuw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: call void @use(i8 [[YZ]])
+; CHECK-NEXT: [[D:%.*]] = udiv exact i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nuw i8 %x, %z
+ call void @use(i8 %xz)
+ %yz = shl nuw i8 %y, %z
+ call void @use(i8 %yz)
+ %d = udiv exact i8 %xz, %yz
+ ret i8 %d
+}
+
+define i8 @udiv_shl_shl_nuw_nsw(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_shl_shl_nuw_nsw(
+; CHECK-NEXT: [[XZ:%.*]] = shl nuw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nsw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nuw i8 %x, %z
+ %yz = shl nsw i8 %y, %z
+ %d = udiv i8 %xz, %yz
+ ret i8 %d
+}
+
+define i8 @udiv_shl_shl_nsw_nuw(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_shl_shl_nsw_nuw(
+; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nuw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nsw i8 %x, %z
+ %yz = shl nuw i8 %y, %z
+ %d = udiv i8 %xz, %yz
+ ret i8 %d
+}
+
+define i8 @udiv_shl_shl_nuw_nsw2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_shl_shl_nuw_nsw2(
+; CHECK-NEXT: [[XZ:%.*]] = shl nuw nsw i8 [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[YZ:%.*]] = shl nsw i8 [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[XZ]], [[YZ]]
+; CHECK-NEXT: ret i8 [[D]]
+;
+ %xz = shl nuw nsw i8 %x, %z
+ %yz = shl nsw i8 %y, %z
+ %d = udiv i8 %xz, %yz
+ ret i8 %d
+}
More information about the llvm-commits
mailing list