[llvm] 3232f3e - [InstCombine] Add additional alloca comparison tests (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 07:40:10 PST 2023
Author: Nikita Popov
Date: 2023-02-21T16:40:01+01:00
New Revision: 3232f3ed0af5b140f2f77bce702843d5d24ba634
URL: https://github.com/llvm/llvm-project/commit/3232f3ed0af5b140f2f77bce702843d5d24ba634
DIFF: https://github.com/llvm/llvm-project/commit/3232f3ed0af5b140f2f77bce702843d5d24ba634.diff
LOG: [InstCombine] Add additional alloca comparison tests (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/compare-alloca.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/compare-alloca.ll b/llvm/test/Transforms/InstCombine/compare-alloca.ll
index 4b5ab1bab9af5..6ba1850cba3bb 100644
--- a/llvm/test/Transforms/InstCombine/compare-alloca.ll
+++ b/llvm/test/Transforms/InstCombine/compare-alloca.ll
@@ -272,3 +272,37 @@ define i1 @consistent_nocapture_through_global() {
%cmp = icmp eq ptr %m, %lgp
ret i1 %cmp
}
+
+define void @select_alloca_unrelated_ptr(i1 %c, ptr %p, ptr %p2) {
+; CHECK-LABEL: @select_alloca_unrelated_ptr(
+; CHECK-NEXT: [[M:%.*]] = alloca i8, align 1
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq ptr [[M]], [[P:%.*]]
+; CHECK-NEXT: [[S:%.*]] = select i1 [[C:%.*]], ptr [[M]], ptr [[P2:%.*]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq ptr [[S]], [[P]]
+; CHECK-NEXT: call void @witness(i1 [[CMP1]], i1 [[CMP2]])
+; CHECK-NEXT: ret void
+;
+ %m = alloca i8
+ %cmp1 = icmp eq ptr %m, %p
+ %s = select i1 %c, ptr %m, ptr %p2
+ %cmp2 = icmp eq ptr %s, %p
+ call void @witness(i1 %cmp1, i1 %cmp2)
+ ret void
+}
+
+define void @alloca_offset_icmp(ptr %p, i32 %offset) {
+; CHECK-LABEL: @alloca_offset_icmp(
+; CHECK-NEXT: [[M:%.*]] = alloca [4 x i8], align 1
+; CHECK-NEXT: [[G:%.*]] = getelementptr i8, ptr [[M]], i32 [[OFFSET:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq ptr [[M]], [[P:%.*]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq ptr [[M]], [[G]]
+; CHECK-NEXT: call void @witness(i1 [[CMP1]], i1 [[CMP2]])
+; CHECK-NEXT: ret void
+;
+ %m = alloca [4 x i8]
+ %g = getelementptr i8, ptr %m, i32 %offset
+ %cmp1 = icmp eq ptr %m, %p
+ %cmp2 = icmp eq ptr %m, %g
+ call void @witness(i1 %cmp1, i1 %cmp2)
+ ret void
+}
More information about the llvm-commits
mailing list