[llvm] 8b9f42b - [instcombine] Autogen a test for ease of update
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 16:06:55 PST 2022
Author: Philip Reames
Date: 2022-02-22T16:02:27-08:00
New Revision: 8b9f42b61b33ec1493e6d71d0240da6dfc847be2
URL: https://github.com/llvm/llvm-project/commit/8b9f42b61b33ec1493e6d71d0240da6dfc847be2
DIFF: https://github.com/llvm/llvm-project/commit/8b9f42b61b33ec1493e6d71d0240da6dfc847be2.diff
LOG: [instcombine] Autogen a test for ease of update
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 ff5517641205..a9e10724805a 100644
--- a/llvm/test/Transforms/InstCombine/compare-alloca.ll
+++ b/llvm/test/Transforms/InstCombine/compare-alloca.ll
@@ -1,54 +1,72 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=instcombine -S %s | FileCheck %s
target datalayout = "p:32:32"
define i1 @alloca_argument_compare(i64* %arg) {
+; CHECK-LABEL: @alloca_argument_compare(
+; CHECK-NEXT: ret i1 false
+;
%alloc = alloca i64
%cmp = icmp eq i64* %arg, %alloc
ret i1 %cmp
- ; CHECK-LABEL: alloca_argument_compare
- ; CHECK: ret i1 false
}
define i1 @alloca_argument_compare_swapped(i64* %arg) {
+; CHECK-LABEL: @alloca_argument_compare_swapped(
+; CHECK-NEXT: ret i1 false
+;
%alloc = alloca i64
%cmp = icmp eq i64* %alloc, %arg
ret i1 %cmp
- ; CHECK-LABEL: alloca_argument_compare_swapped
- ; CHECK: ret i1 false
}
define i1 @alloca_argument_compare_ne(i64* %arg) {
+; CHECK-LABEL: @alloca_argument_compare_ne(
+; CHECK-NEXT: ret i1 true
+;
%alloc = alloca i64
%cmp = icmp ne i64* %arg, %alloc
ret i1 %cmp
- ; CHECK-LABEL: alloca_argument_compare_ne
- ; CHECK: ret i1 true
}
define i1 @alloca_argument_compare_derived_ptrs(i64* %arg, i64 %x) {
+; CHECK-LABEL: @alloca_argument_compare_derived_ptrs(
+; CHECK-NEXT: ret i1 false
+;
%alloc = alloca i64, i64 8
%p = getelementptr i64, i64* %arg, i64 %x
%q = getelementptr i64, i64* %alloc, i64 3
%cmp = icmp eq i64* %p, %q
ret i1 %cmp
- ; CHECK-LABEL: alloca_argument_compare_derived_ptrs
- ; CHECK: ret i1 false
}
declare void @escape(i64*)
define i1 @alloca_argument_compare_escaped_alloca(i64* %arg) {
+; CHECK-LABEL: @alloca_argument_compare_escaped_alloca(
+; CHECK-NEXT: [[ALLOC:%.*]] = alloca i64, align 8
+; CHECK-NEXT: call void @escape(i64* nonnull [[ALLOC]])
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64* [[ALLOC]], [[ARG:%.*]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
%alloc = alloca i64
call void @escape(i64* %alloc)
%cmp = icmp eq i64* %alloc, %arg
ret i1 %cmp
- ; CHECK-LABEL: alloca_argument_compare_escaped_alloca
- ; CHECK: %cmp = icmp eq i64* %alloc, %arg
- ; CHECK: ret i1 %cmp
}
declare void @check_compares(i1, i1)
define void @alloca_argument_compare_two_compares(i64* %p) {
+; CHECK-LABEL: @alloca_argument_compare_two_compares(
+; CHECK-NEXT: [[Q1:%.*]] = alloca [8 x i64], align 8
+; CHECK-NEXT: [[Q1_SUB:%.*]] = getelementptr inbounds [8 x i64], [8 x i64]* [[Q1]], i32 0, i32 0
+; CHECK-NEXT: [[R:%.*]] = getelementptr i64, i64* [[P:%.*]], i32 1
+; CHECK-NEXT: [[S:%.*]] = getelementptr inbounds [8 x i64], [8 x i64]* [[Q1]], i32 0, i32 2
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i64* [[Q1_SUB]], [[P]]
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i64* [[R]], [[S]]
+; CHECK-NEXT: call void @check_compares(i1 [[CMP1]], i1 [[CMP2]])
+; CHECK-NEXT: ret void
+;
%q = alloca i64, i64 8
%r = getelementptr i64, i64* %p, i64 1
%s = getelementptr i64, i64* %q, i64 2
@@ -57,24 +75,29 @@ define void @alloca_argument_compare_two_compares(i64* %p) {
call void @check_compares(i1 %cmp1, i1 %cmp2)
ret void
; We will only fold if there is a single cmp.
- ; CHECK-LABEL: alloca_argument_compare_two_compares
- ; CHECK: call void @check_compares(i1 %cmp1, i1 %cmp2)
}
define i1 @alloca_argument_compare_escaped_through_store(i64* %arg, i64** %ptr) {
+; CHECK-LABEL: @alloca_argument_compare_escaped_through_store(
+; CHECK-NEXT: [[ALLOC:%.*]] = alloca i64, align 8
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64* [[ALLOC]], [[ARG:%.*]]
+; CHECK-NEXT: [[P:%.*]] = getelementptr inbounds i64, i64* [[ALLOC]], i32 1
+; CHECK-NEXT: store i64* [[P]], i64** [[PTR:%.*]], align 4
+; CHECK-NEXT: ret i1 [[CMP]]
+;
%alloc = alloca i64
%cmp = icmp eq i64* %alloc, %arg
%p = getelementptr i64, i64* %alloc, i64 1
store i64* %p, i64** %ptr
ret i1 %cmp
- ; CHECK-LABEL: alloca_argument_compare_escaped_through_store
- ; CHECK: %cmp = icmp eq i64* %alloc, %arg
- ; CHECK: ret i1 %cmp
}
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
define i1 @alloca_argument_compare_benign_instrs(i8* %arg) {
+; CHECK-LABEL: @alloca_argument_compare_benign_instrs(
+; CHECK-NEXT: ret i1 false
+;
%alloc = alloca i8
call void @llvm.lifetime.start.p0i8(i64 1, i8* %alloc)
%cmp = icmp eq i8* %arg, %alloc
@@ -82,16 +105,16 @@ define i1 @alloca_argument_compare_benign_instrs(i8* %arg) {
store i8 %x, i8* %alloc
call void @llvm.lifetime.end.p0i8(i64 1, i8* %alloc)
ret i1 %cmp
- ; CHECK-LABEL: alloca_argument_compare_benign_instrs
- ; CHECK: ret i1 false
}
declare i64* @allocator()
define i1 @alloca_call_compare() {
+; CHECK-LABEL: @alloca_call_compare(
+; CHECK-NEXT: [[Q:%.*]] = call i64* @allocator()
+; CHECK-NEXT: ret i1 false
+;
%p = alloca i64
%q = call i64* @allocator()
%cmp = icmp eq i64* %p, %q
ret i1 %cmp
- ; CHECK-LABEL: alloca_call_compare
- ; CHECK: ret i1 false
}
More information about the llvm-commits
mailing list