1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes='move-auto-init' -verify-memoryssa | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 ; In that case, the store to %val happens before the fence and cannot go past
8 define void @foo(i32 %x) {
11 ; CHECK-NEXT: [[VAL:%.*]] = alloca i32, align 4
12 ; CHECK-NEXT: store i32 -1431655766, ptr [[VAL]], align 4, !annotation !0
13 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[X:%.*]], 0
14 ; CHECK-NEXT: fence acquire
15 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
17 ; CHECK-NEXT: call void @dump(ptr [[VAL]])
18 ; CHECK-NEXT: br label [[IF_END]]
20 ; CHECK-NEXT: ret void
23 %val = alloca i32, align 4
24 store i32 -1431655766, ptr %val, align 4, !annotation !0
25 %tobool = icmp ne i32 %x, 0
27 br i1 %tobool, label %if.then, label %if.end
29 if.then: ; preds = %entry
30 call void @dump(ptr %val)
33 if.end: ; preds = %if.then, %entry
37 ; In that case, the store to %val happens after the fence and it is moved within
38 ; the true branch as expected.
39 define void @bar(i32 %x) {
42 ; CHECK-NEXT: [[VAL:%.*]] = alloca i32, align 4
43 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[X:%.*]], 0
44 ; CHECK-NEXT: fence acquire
45 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
47 ; CHECK-NEXT: store i32 -1431655766, ptr [[VAL]], align 4, !annotation !0
48 ; CHECK-NEXT: call void @dump(ptr [[VAL]])
49 ; CHECK-NEXT: br label [[IF_END]]
51 ; CHECK-NEXT: ret void
54 %val = alloca i32, align 4
55 %tobool = icmp ne i32 %x, 0
57 store i32 -1431655766, ptr %val, align 4, !annotation !0
58 br i1 %tobool, label %if.then, label %if.end
60 if.then: ; preds = %entry
61 call void @dump(ptr %val)
64 if.end: ; preds = %if.then, %entry
68 declare void @dump(ptr)