diff options
-rw-r--r-- | llvm/test/Transforms/InstCombine/sub-not.ll | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/sub-not.ll b/llvm/test/Transforms/InstCombine/sub-not.ll new file mode 100644 index 00000000000..ea7101bfe9d --- /dev/null +++ b/llvm/test/Transforms/InstCombine/sub-not.ll @@ -0,0 +1,110 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -instcombine -S | FileCheck %s + +declare void @use(i8) + +define i8 @sub_not(i8 %x, i8 %y) { +; CHECK-LABEL: @sub_not( +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = xor i8 [[S]], -1 +; CHECK-NEXT: ret i8 [[R]] +; + %s = sub i8 %x, %y + %r = xor i8 %s, -1 + ret i8 %r +} + +define i8 @sub_not_extra_use(i8 %x, i8 %y) { +; CHECK-LABEL: @sub_not_extra_use( +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = xor i8 [[S]], -1 +; CHECK-NEXT: call void @use(i8 [[S]]) +; CHECK-NEXT: ret i8 [[R]] +; + %s = sub i8 %x, %y + %r = xor i8 %s, -1 + call void @use(i8 %s) + ret i8 %r +} + +define <2 x i8> @sub_not_vec(<2 x i8> %x, <2 x i8> %y) { +; CHECK-LABEL: @sub_not_vec( +; CHECK-NEXT: [[S:%.*]] = sub <2 x i8> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[S]], <i8 -1, i8 undef> +; CHECK-NEXT: ret <2 x i8> [[R]] +; + %s = sub <2 x i8> %x, %y + %r = xor <2 x i8> %s, <i8 -1, i8 undef> + ret <2 x i8> %r +} + +define i8 @dec_sub(i8 %x, i8 %y) { +; CHECK-LABEL: @dec_sub( +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = add i8 [[S]], -1 +; CHECK-NEXT: ret i8 [[R]] +; + %s = sub i8 %x, %y + %r = add i8 %s, -1 + ret i8 %r +} + +define i8 @dec_sub_extra_use(i8 %x, i8 %y) { +; CHECK-LABEL: @dec_sub_extra_use( +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = add i8 [[S]], -1 +; CHECK-NEXT: call void @use(i8 [[S]]) +; CHECK-NEXT: ret i8 [[R]] +; + %s = sub i8 %x, %y + %r = add i8 %s, -1 + call void @use(i8 %s) + ret i8 %r +} + +define <2 x i8> @dec_sub_vec(<2 x i8> %x, <2 x i8> %y) { +; CHECK-LABEL: @dec_sub_vec( +; CHECK-NEXT: [[S:%.*]] = sub <2 x i8> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[S]], <i8 -1, i8 undef> +; CHECK-NEXT: ret <2 x i8> [[R]] +; + %s = sub <2 x i8> %x, %y + %r = add <2 x i8> %s, <i8 -1, i8 undef> + ret <2 x i8> %r +} + +define i8 @sub_inc(i8 %x, i8 %y) { +; CHECK-LABEL: @sub_inc( +; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], 1 +; CHECK-NEXT: [[R:%.*]] = sub i8 [[Y:%.*]], [[S]] +; CHECK-NEXT: ret i8 [[R]] +; + %s = add i8 %x, 1 + %r = sub i8 %y, %s + ret i8 %r +} + +define i8 @sub_inc_extra_use(i8 %x, i8 %y) { +; CHECK-LABEL: @sub_inc_extra_use( +; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], 1 +; CHECK-NEXT: [[R:%.*]] = sub i8 [[Y:%.*]], [[S]] +; CHECK-NEXT: call void @use(i8 [[S]]) +; CHECK-NEXT: ret i8 [[R]] +; + %s = add i8 %x, 1 + %r = sub i8 %y, %s + call void @use(i8 %s) + ret i8 %r +} + +define <2 x i8> @sub_inc_vec(<2 x i8> %x, <2 x i8> %y) { +; CHECK-LABEL: @sub_inc_vec( +; CHECK-NEXT: [[S:%.*]] = add <2 x i8> [[X:%.*]], <i8 undef, i8 1> +; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[Y:%.*]], [[S]] +; CHECK-NEXT: ret <2 x i8> [[R]] +; + %s = add <2 x i8> %x, <i8 undef, i8 1> + %r = sub <2 x i8> %y, %s + ret <2 x i8> %r +} + |