1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=gvn-hoist < %s | FileCheck %s
4 ; Make sure the two stores @B do not get hoisted past the load @B.
6 @A = external global i8
7 @B = external global ptr
9 define ptr @Foo(i1 %arg) {
10 ; CHECK-LABEL: define ptr @Foo(i1 %arg) {
11 ; CHECK-NEXT: store i8 0, ptr @A, align 1
12 ; CHECK-NEXT: br i1 %arg, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
14 ; CHECK-NEXT: store ptr null, ptr @B, align 8
15 ; CHECK-NEXT: ret ptr null
17 ; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr @B, align 8
18 ; CHECK-NEXT: store ptr null, ptr @B, align 8
19 ; CHECK-NEXT: ret ptr [[TMP1]]
22 br i1 %arg, label %if.then, label %if.else
25 store ptr null, ptr @B
30 store ptr null, ptr @B
34 ; Make sure the two stores @B do not get hoisted past the store @GlobalVar.
36 @GlobalVar = internal global i8 0
38 define ptr @Fun(i1 %arg) {
39 ; CHECK-LABEL: define ptr @Fun(i1 %arg) {
40 ; CHECK-NEXT: store i8 0, ptr @A, align 1
41 ; CHECK-NEXT: br i1 %arg, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
43 ; CHECK-NEXT: store ptr null, ptr @B, align 8
44 ; CHECK-NEXT: ret ptr null
46 ; CHECK-NEXT: store i8 0, ptr @GlobalVar, align 1
47 ; CHECK-NEXT: store ptr null, ptr @B, align 8
48 ; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr @B, align 8
49 ; CHECK-NEXT: ret ptr [[TMP1]]
52 br i1 %arg, label %if.then, label %if.else
55 store ptr null, ptr @B
59 store i8 0, ptr @GlobalVar
60 store ptr null, ptr @B