Skip to content

Commit ec150a9

Browse files
committed
[PhaseOrdering] Add test for memset DSE (NFC)
This checks for the interaction with #145474.
1 parent 794edd1 commit ec150a9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -O2 < %s | FileCheck %s
3+
4+
declare void @do_something(ptr %a)
5+
6+
; We want only one memset in the if block (rather than only one memset in
7+
; the entry block).
8+
define void @test(i1 %c) {
9+
; CHECK-LABEL: define void @test(
10+
; CHECK-SAME: i1 [[C:%.*]]) local_unnamed_addr {
11+
; CHECK-NEXT: [[A:%.*]] = alloca [32 x i8], align 1
12+
; CHECK-NEXT: br i1 [[C]], label %[[IF:.*]], label %[[COMMON_RET:.*]]
13+
; CHECK: [[COMMON_RET]]:
14+
; CHECK-NEXT: ret void
15+
; CHECK: [[IF]]:
16+
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) [[A]], i8 0, i64 32, i1 false)
17+
; CHECK-NEXT: call void @do_something(ptr nonnull [[A]])
18+
; CHECK-NEXT: br label %[[COMMON_RET]]
19+
;
20+
%a = alloca [32 x i8]
21+
call void @llvm.memset(ptr %a, i8 0, i64 32, i1 false)
22+
br i1 %c, label %if, label %else
23+
if:
24+
call void @llvm.memset(ptr %a, i8 0, i64 32, i1 false)
25+
call void @do_something(ptr %a)
26+
ret void
27+
28+
else:
29+
ret void
30+
}

0 commit comments

Comments
 (0)