[llvm] dd5c534 - [InstCombine] Add tests for invert of lshr (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 06:55:37 PST 2023
Author: Nikita Popov
Date: 2023-12-01T15:55:26+01:00
New Revision: dd5c5349e1f3b495789a9f67e579121da3722db6
URL: https://github.com/llvm/llvm-project/commit/dd5c5349e1f3b495789a9f67e579121da3722db6
DIFF: https://github.com/llvm/llvm-project/commit/dd5c5349e1f3b495789a9f67e579121da3722db6.diff
LOG: [InstCombine] Add tests for invert of lshr (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/free-inversion.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/free-inversion.ll b/llvm/test/Transforms/InstCombine/free-inversion.ll
index ea5894597997bc1..c16310cf09631c5 100644
--- a/llvm/test/Transforms/InstCombine/free-inversion.ll
+++ b/llvm/test/Transforms/InstCombine/free-inversion.ll
@@ -6,6 +6,8 @@ declare i8 @llvm.umin.i8(i8, i8)
declare i8 @llvm.smax.i8(i8, i8)
declare i8 @llvm.umax.i8(i8, i8)
+declare void @llvm.assume(i1)
+
declare void @use.i8(i8)
define i8 @xor_1(i8 %a, i1 %c, i8 %x, i8 %y) {
@@ -492,3 +494,33 @@ define i8 @smax_both_freely_invertable_always(i8 %x, i8 %y) {
%r = call i8 @llvm.smax.i8(i8 %xx, i8 %yy)
ret i8 %r
}
+
+define i8 @lshr_nneg(i8 %x, i8 %y) {
+; CHECK-LABEL: @lshr_nneg(
+; CHECK-NEXT: [[NEG:%.*]] = icmp slt i8 [[X:%.*]], 0
+; CHECK-NEXT: call void @llvm.assume(i1 [[NEG]])
+; CHECK-NEXT: [[X_NOT:%.*]] = xor i8 [[X]], -1
+; CHECK-NEXT: [[SHR:%.*]] = lshr i8 [[X_NOT]], [[Y:%.*]]
+; CHECK-NEXT: [[SHR_NOT:%.*]] = xor i8 [[SHR]], -1
+; CHECK-NEXT: ret i8 [[SHR_NOT]]
+;
+ %neg = icmp slt i8 %x, 0
+ call void @llvm.assume(i1 %neg)
+ %x.not = xor i8 %x, -1
+ %shr = lshr i8 %x.not, %y
+ %shr.not = xor i8 %shr, -1
+ ret i8 %shr.not
+}
+
+define i8 @lshr_not_nneg(i8 %x, i8 %y) {
+; CHECK-LABEL: @lshr_not_nneg(
+; CHECK-NEXT: [[X_NOT:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT: [[SHR:%.*]] = lshr i8 [[X_NOT]], [[Y:%.*]]
+; CHECK-NEXT: [[SHR_NOT:%.*]] = xor i8 [[SHR]], -1
+; CHECK-NEXT: ret i8 [[SHR_NOT]]
+;
+ %x.not = xor i8 %x, -1
+ %shr = lshr i8 %x.not, %y
+ %shr.not = xor i8 %shr, -1
+ ret i8 %shr.not
+}
More information about the llvm-commits
mailing list