1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=dse -S %s | FileCheck %s
4 declare ptr @_Znwm() local_unnamed_addr #0
6 ; Function Attrs: argmemonly nounwind willreturn writeonly
7 declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1
9 define ptr @test1(i1 %c, i64 %N) {
10 ; CHECK-LABEL: @test1(
12 ; CHECK-NEXT: br i1 [[C:%.*]], label [[COND_TRUE_I_I_I:%.*]], label [[COND_END_I_I_I:%.*]]
13 ; CHECK: cond.true.i.i.i:
14 ; CHECK-NEXT: ret ptr null
15 ; CHECK: cond.end.i.i.i:
16 ; CHECK-NEXT: [[ALLOC:%.*]] = tail call noalias nonnull ptr @_Znam() #[[ATTR2:[0-9]+]]
17 ; CHECK-NEXT: tail call void @llvm.memset.p0.i64(ptr nonnull align 8 [[ALLOC]], i8 0, i64 [[N:%.*]], i1 false) #[[ATTR3:[0-9]+]]
18 ; CHECK-NEXT: store i64 0, ptr [[ALLOC]], align 8
19 ; CHECK-NEXT: ret ptr [[ALLOC]]
22 br i1 %c, label %cond.true.i.i.i, label %cond.end.i.i.i
24 cond.true.i.i.i: ; preds = %entry
27 cond.end.i.i.i: ; preds = %entry
28 %alloc = tail call noalias nonnull ptr @_Znam() #2
29 tail call void @llvm.memset.p0.i64(ptr nonnull align 8 %alloc, i8 0, i64 %N, i1 false) #3
30 store i64 0, ptr %alloc, align 8
37 define ptr @test2(i1 %c, i64 %N) {
38 ; CHECK-LABEL: @test2(
40 ; CHECK-NEXT: br i1 [[C:%.*]], label [[CLEANUP_CONT104:%.*]], label [[IF_THEN:%.*]]
42 ; CHECK-NEXT: [[MUL:%.*]] = shl nuw nsw i64 [[N:%.*]], 3
43 ; CHECK-NEXT: [[ALLOC:%.*]] = call noalias nonnull ptr @_Znwm() #[[ATTR2]]
44 ; CHECK-NEXT: store i64 0, ptr [[ALLOC]], align 8
45 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr nonnull align 8 [[ALLOC]], i8 0, i64 [[MUL]], i1 false) #[[ATTR3]]
46 ; CHECK-NEXT: ret ptr [[ALLOC]]
47 ; CHECK: cleanup.cont104:
48 ; CHECK-NEXT: ret ptr null
51 br i1 %c, label %cleanup.cont104, label %if.then
53 if.then: ; preds = %entry
54 %mul = shl nuw nsw i64 %N, 3
55 %alloc = call noalias nonnull ptr @_Znwm() #2
56 store i64 0, ptr %alloc, align 8
57 call void @llvm.memset.p0.i64(ptr nonnull align 8 %alloc, i8 0, i64 %mul, i1 false) #3
60 cleanup.cont104: ; preds = %entry
64 attributes #0 = { "use-soft-float"="false" }
65 attributes #1 = { argmemonly nounwind willreturn writeonly }
66 attributes #2 = { builtin nounwind }
67 attributes #3 = { nounwind }