• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -S -memcpyopt -enable-memcpyopt-memoryssa=0 | FileCheck %s
3; RUN: opt < %s -S -memcpyopt -enable-memcpyopt-memoryssa=1 -verify-memoryssa | FileCheck %s
4
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8@b = common dso_local local_unnamed_addr global i32 0, align 4
9@a = common dso_local local_unnamed_addr global i32 0, align 4
10
11declare dso_local i32 @f1()
12
13; Do not crash due to store first in BB.
14define dso_local void @f2() {
15; CHECK-LABEL: @f2(
16; CHECK-NEXT:  for.end:
17; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* @b, align 4
18; CHECK-NEXT:    ret void
19; CHECK:       for.body:
20; CHECK-NEXT:    store i32 [[TMP1:%.*]], i32* @a, align 4
21; CHECK-NEXT:    [[CALL:%.*]] = call i32 @f1()
22; CHECK-NEXT:    [[CMP:%.*]] = icmp sge i32 [[CALL]], 0
23; CHECK-NEXT:    [[TMP1]] = load i32, i32* @b, align 4
24; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
25;
26for.end:
27  %0 = load i32, i32* @b, align 4
28  ret void
29
30for.body:
31  store i32 %1, i32* @a, align 4
32  %call = call i32 @f1()
33  %cmp = icmp sge i32 %call, 0
34  %1 = load i32, i32* @b, align 4
35  br label %for.body
36}
37
38; Do not crash due to call not before store in BB.
39define dso_local void @f3() {
40; CHECK-LABEL: @f3(
41; CHECK-NEXT:  for.end:
42; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* @b, align 4
43; CHECK-NEXT:    ret void
44; CHECK:       for.body:
45; CHECK-NEXT:    [[T:%.*]] = add i32 [[T2:%.*]], 1
46; CHECK-NEXT:    store i32 [[TMP1:%.*]], i32* @a, align 4
47; CHECK-NEXT:    [[CALL:%.*]] = call i32 @f1()
48; CHECK-NEXT:    [[CMP:%.*]] = icmp sge i32 [[CALL]], 0
49; CHECK-NEXT:    [[TMP1]] = load i32, i32* @b, align 4
50; CHECK-NEXT:    [[T2]] = xor i32 [[T]], 5
51; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
52;
53for.end:
54  %0 = load i32, i32* @b, align 4
55  ret void
56
57for.body:
58  %t = add i32 %t2, 1
59  store i32 %1, i32* @a, align 4
60  %call = call i32 @f1()
61  %cmp = icmp sge i32 %call, 0
62  %1 = load i32, i32* @b, align 4
63  %t2 = xor i32 %t, 5
64  br label %for.body
65}
66