1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=memcpyopt -verify-memoryssa | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @b = common dso_local local_unnamed_addr global i32 0, align 4
8 @a = common dso_local local_unnamed_addr global i32 0, align 4
10 declare dso_local i32 @f1()
12 ; Do not crash due to store first in BB.
13 define dso_local void @f2() {
15 ; CHECK-NEXT: for.end:
16 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @b, align 4
17 ; CHECK-NEXT: ret void
19 ; CHECK-NEXT: store i32 [[TMP1:%.*]], ptr @a, align 4
20 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @f1()
21 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[CALL]], 0
22 ; CHECK-NEXT: [[TMP1]] = load i32, ptr @b, align 4
23 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
26 %0 = load i32, ptr @b, align 4
30 store i32 %1, ptr @a, align 4
31 %call = call i32 @f1()
32 %cmp = icmp sge i32 %call, 0
33 %1 = load i32, ptr @b, align 4
37 ; Do not crash due to call not before store in BB.
38 define dso_local void @f3() {
40 ; CHECK-NEXT: for.end:
41 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @b, align 4
42 ; CHECK-NEXT: ret void
44 ; CHECK-NEXT: [[T:%.*]] = add i32 [[T2:%.*]], 1
45 ; CHECK-NEXT: store i32 [[TMP1:%.*]], ptr @a, align 4
46 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @f1()
47 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[CALL]], 0
48 ; CHECK-NEXT: [[TMP1]] = load i32, ptr @b, align 4
49 ; CHECK-NEXT: [[T2]] = xor i32 [[T]], 5
50 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
53 %0 = load i32, ptr @b, align 4
58 store i32 %1, ptr @a, align 4
59 %call = call i32 @f1()
60 %cmp = icmp sge i32 %call, 0
61 %1 = load i32, ptr @b, align 4