[llvm] 692db74 - [ValueTracking] Precommit test for #118406
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 4 14:03:52 PST 2025
Author: Andreas Jonson
Date: 2025-02-04T22:53:33+01:00
New Revision: 692db7403b4ad10311b7e8c85a0fc7de5bc32017
URL: https://github.com/llvm/llvm-project/commit/692db7403b4ad10311b7e8c85a0fc7de5bc32017
DIFF: https://github.com/llvm/llvm-project/commit/692db7403b4ad10311b7e8c85a0fc7de5bc32017.diff
LOG: [ValueTracking] Precommit test for #118406
Added:
Modified:
llvm/test/Transforms/InstSimplify/assume-non-zero.ll
llvm/test/Transforms/InstSimplify/compare.ll
llvm/test/Transforms/InstSimplify/shr-nop.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/assume-non-zero.ll b/llvm/test/Transforms/InstSimplify/assume-non-zero.ll
index 9176b8101da659..22bdf374487dab 100644
--- a/llvm/test/Transforms/InstSimplify/assume-non-zero.ll
+++ b/llvm/test/Transforms/InstSimplify/assume-non-zero.ll
@@ -231,3 +231,17 @@ define i1 @nonnull17_unknown(i8 %x) {
%q = icmp ne i8 %x, 0
ret i1 %q
}
+
+define i1 @nonnull_trunc_true(i8 %x) {
+; CHECK-LABEL: @nonnull_trunc_true(
+; CHECK-NEXT: [[A:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT: call void @llvm.assume(i1 [[A]])
+; CHECK-NEXT: [[Q:%.*]] = icmp ne i8 [[X]], 0
+; CHECK-NEXT: ret i1 [[Q]]
+;
+ %a = trunc i8 %x to i1
+ call void @llvm.assume(i1 %a)
+ %q = icmp ne i8 %x, 0
+ ret i1 %q
+}
+
diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll
index 222b25836e053a..4192a59dc71340 100644
--- a/llvm/test/Transforms/InstSimplify/compare.ll
+++ b/llvm/test/Transforms/InstSimplify/compare.ll
@@ -3450,6 +3450,21 @@ define i1 @icmp_ult_vscale_false(i8 %x, i8 %y) {
ret i1 %cmp
}
+define i1 @icmp_eq_false_by_trunc(i8 %x) {
+; CHECK-LABEL: @icmp_eq_false_by_trunc(
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[TRUNC]], true
+; CHECK-NEXT: call void @llvm.assume(i1 [[NOT]])
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X]], 1
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %trunc = trunc i8 %x to i1
+ %not = xor i1 %trunc, true
+ call void @llvm.assume(i1 %not)
+ %cmp = icmp eq i8 %x, 1
+ ret i1 %cmp
+}
+
declare i64 @llvm.vscale.i64()
; TODO: Add coverage for global aliases, link once, etc..
diff --git a/llvm/test/Transforms/InstSimplify/shr-nop.ll b/llvm/test/Transforms/InstSimplify/shr-nop.ll
index 29fe222faaae3e..4b9292aab4bb3e 100644
--- a/llvm/test/Transforms/InstSimplify/shr-nop.ll
+++ b/llvm/test/Transforms/InstSimplify/shr-nop.ll
@@ -381,6 +381,19 @@ define i32 @exact_lshr_lowbit(i32 %shiftval) {
ret i32 %shr
}
+define i8 @exact_lshr_lowbit_set_assume_trunc(i8 %x) {
+; CHECK-LABEL: @exact_lshr_lowbit_set_assume_trunc(
+; CHECK-NEXT: [[COND:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT: call void @llvm.assume(i1 [[COND]])
+; CHECK-NEXT: [[SHR:%.*]] = lshr exact i8 [[X]], 1
+; CHECK-NEXT: ret i8 [[SHR]]
+;
+ %cond = trunc i8 %x to i1
+ call void @llvm.assume(i1 %cond)
+ %shr = lshr exact i8 %x, 1
+ ret i8 %shr
+}
+
define i32 @exact_ashr_lowbit(i32 %shiftval) {
; CHECK-LABEL: @exact_ashr_lowbit(
; CHECK-NEXT: ret i32 7
More information about the llvm-commits
mailing list