From ea6171c108c47c1ee486388adfa106e13e280e33 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 25 May 2022 14:22:56 -0400 Subject: [PATCH] [InstCombine] add tests for icmp with udiv operand; NFC This covers a generalization of one of the transforms suggested in #55695. --- .../Transforms/InstCombine/icmp-div-constant.ll | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/icmp-div-constant.ll b/llvm/test/Transforms/InstCombine/icmp-div-constant.ll index aab916c..ff587dc 100644 --- a/llvm/test/Transforms/InstCombine/icmp-div-constant.ll +++ b/llvm/test/Transforms/InstCombine/icmp-div-constant.ll @@ -196,3 +196,81 @@ exit: ret i32 %add } +define i1 @udiv_eq_umax(i8 %x, i8 %y) { +; CHECK-LABEL: @udiv_eq_umax( +; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], -1 +; CHECK-NEXT: ret i1 [[R]] +; + %d = udiv i8 %x, %y + %r = icmp eq i8 %d, 255 + ret i1 %r +} + +define <2 x i1> @udiv_ne_umax(<2 x i5> %x, <2 x i5> %y) { +; CHECK-LABEL: @udiv_ne_umax( +; CHECK-NEXT: [[D:%.*]] = udiv <2 x i5> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i5> [[D]], +; CHECK-NEXT: ret <2 x i1> [[R]] +; + %d = udiv <2 x i5> %x, %y + %r = icmp ne <2 x i5> %d, + ret <2 x i1> %r +} + +define i1 @udiv_eq_big(i8 %x, i8 %y) { +; CHECK-LABEL: @udiv_eq_big( +; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], -128 +; CHECK-NEXT: ret i1 [[R]] +; + %d = udiv i8 %x, %y + %r = icmp eq i8 %d, 128 + ret i1 %r +} + +define i1 @udiv_ne_big(i8 %x, i8 %y) { +; CHECK-LABEL: @udiv_ne_big( +; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[D]], -128 +; CHECK-NEXT: ret i1 [[R]] +; + %d = udiv i8 %x, %y + %r = icmp ne i8 %d, 128 + ret i1 %r +} + +define i1 @udiv_eq_not_big(i8 %x, i8 %y) { +; CHECK-LABEL: @udiv_eq_not_big( +; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], 127 +; CHECK-NEXT: ret i1 [[R]] +; + %d = udiv i8 %x, %y + %r = icmp eq i8 %d, 127 + ret i1 %r +} + +define i1 @udiv_slt_umax(i8 %x, i8 %y) { +; CHECK-LABEL: @udiv_slt_umax( +; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[D]], -1 +; CHECK-NEXT: ret i1 [[R]] +; + %d = udiv i8 %x, %y + %r = icmp slt i8 %d, 255 + ret i1 %r +} + +define i1 @udiv_eq_umax_use(i32 %x, i32 %y) { +; CHECK-LABEL: @udiv_eq_umax_use( +; CHECK-NEXT: [[D:%.*]] = udiv i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: call void @use(i32 [[D]]) +; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[D]], -1 +; CHECK-NEXT: ret i1 [[R]] +; + %d = udiv i32 %x, %y + call void @use(i32 %d) + %r = icmp eq i32 %d, -1 + ret i1 %r +} -- 2.7.4