1 ; RUN: opt -S -memcpyopt < %s | FileCheck %s
2 declare void @may_throw(i32* nocapture %x)
4 ; CHECK-LABEL: define void @test1(
5 define void @test1(i32* nocapture noalias dereferenceable(4) %x) {
7 %t = alloca i32, align 4
8 call void @may_throw(i32* nonnull %t)
9 %load = load i32, i32* %t, align 4
10 store i32 %load, i32* %x, align 4
11 ; CHECK: %[[t:.*]] = alloca i32, align 4
12 ; CHECK-NEXT: call void @may_throw(i32* {{.*}} %[[t]])
13 ; CHECK-NEXT: %[[load:.*]] = load i32, i32* %[[t]], align 4
14 ; CHECK-NEXT: store i32 %[[load]], i32* %x, align 4
18 declare void @always_throws()
20 ; CHECK-LABEL: define void @test2(
21 define void @test2(i32* nocapture noalias dereferenceable(4) %x) {
23 %t = alloca i32, align 4
24 call void @may_throw(i32* nonnull %t) nounwind
25 %load = load i32, i32* %t, align 4
26 call void @always_throws()
27 store i32 %load, i32* %x, align 4
28 ; CHECK: %[[t:.*]] = alloca i32, align 4
29 ; CHECK-NEXT: call void @may_throw(i32* {{.*}} %[[t]])
30 ; CHECK-NEXT: %[[load:.*]] = load i32, i32* %[[t]], align 4
31 ; CHECK-NEXT: call void @always_throws()
32 ; CHECK-NEXT: store i32 %[[load]], i32* %x, align 4