1 ; RUN: opt -S -gvn-hoist < %s | FileCheck %s 2 3 ; Make sure the two stores @B do not get hoisted past the load @B. 4 5 ; CHECK-LABEL: define i8* @Foo 6 ; CHECK: store 7 ; CHECK: store 8 ; CHECK: load 9 ; CHECK: store 10 11 @A = external global i8 12 @B = external global i8* 13 14 define i8* @Foo() { 15 store i8 0, i8* @A 16 br i1 undef, label %if.then, label %if.else 17 18 if.then: 19 store i8* null, i8** @B 20 ret i8* null 21 22 if.else: 23 %1 = load i8*, i8** @B 24 store i8* null, i8** @B 25 ret i8* %1 26 } 27 28 ; Make sure the two stores @B do not get hoisted past the store @GlobalVar. 29 30 ; CHECK-LABEL: define i8* @Fun 31 ; CHECK: store 32 ; CHECK: store 33 ; CHECK: store 34 ; CHECK: store 35 ; CHECK: load 36 37 @GlobalVar = internal global i8 0 38 39 define i8* @Fun() { 40 store i8 0, i8* @A 41 br i1 undef, label %if.then, label %if.else 42 43 if.then: 44 store i8* null, i8** @B 45 ret i8* null 46 47 if.else: 48 store i8 0, i8* @GlobalVar 49 store i8* null, i8** @B 50 %1 = load i8*, i8** @B 51 ret i8* %1 52 } 53