From 02b53da6b65a4f39d9d8ea9412a5438532043e0d Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sun, 29 Jul 2018 18:07:28 +0000 Subject: [PATCH] [InstCombine] add tests for another sub-not variant; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338220 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/sub-not.ll | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/Transforms/InstCombine/sub-not.ll b/test/Transforms/InstCombine/sub-not.ll index c4fbbe22f4e..9335fdafcc1 100644 --- a/test/Transforms/InstCombine/sub-not.ll +++ b/test/Transforms/InstCombine/sub-not.ll @@ -108,3 +108,38 @@ define <2 x i8> @sub_inc_vec(<2 x i8> %x, <2 x i8> %y) { ret <2 x i8> %r } +define i8 @sub_dec(i8 %x, i8 %y) { +; CHECK-LABEL: @sub_dec( +; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], -1 +; CHECK-NEXT: [[R:%.*]] = sub i8 [[S]], [[Y:%.*]] +; CHECK-NEXT: ret i8 [[R]] +; + %s = add i8 %x, -1 + %r = sub i8 %s, %y + ret i8 %r +} + +define i8 @sub_dec_extra_use(i8 %x, i8 %y) { +; CHECK-LABEL: @sub_dec_extra_use( +; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], -1 +; CHECK-NEXT: [[R:%.*]] = sub i8 [[S]], [[Y:%.*]] +; CHECK-NEXT: call void @use(i8 [[S]]) +; CHECK-NEXT: ret i8 [[R]] +; + %s = add i8 %x, -1 + %r = sub i8 %s, %y + call void @use(i8 %s) + ret i8 %r +} + +define <2 x i8> @sub_dec_vec(<2 x i8> %x, <2 x i8> %y) { +; CHECK-LABEL: @sub_dec_vec( +; CHECK-NEXT: [[S:%.*]] = add <2 x i8> [[X:%.*]], +; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[S]], [[Y:%.*]] +; CHECK-NEXT: ret <2 x i8> [[R]] +; + %s = add <2 x i8> %x, + %r = sub <2 x i8> %s, %y + ret <2 x i8> %r +} + -- 2.11.0