1 ; ModuleID = 'PR1657.bc'
2 ; Do not promote getelementptr because it may exposes load from a null pointer
3 ; and store from a null pointer which are covered by
4 ; icmp eq %struct.decision* null, null condition.
5 ; RUN: opt < %s -licm -S | not grep promoted
6 %struct.decision = type { i8, %struct.decision* }
12 blah.i: ; preds = %cond_true.i, %entry
13 %tmp3.i = icmp eq %struct.decision* null, null ; <i1> [#uses=1]
14 br i1 %tmp3.i, label %clear_modes.exit, label %cond_true.i
16 cond_true.i: ; preds = %blah.i
17 %tmp1.i = getelementptr %struct.decision* null, i32 0, i32 0 ; <i8*> [#uses=1]
18 store i8 0, i8* %tmp1.i
21 clear_modes.exit: ; preds = %blah.i
22 call void @exit( i32 0 )
26 define i32 @f(i8* %ptr) {
30 loop.head: ; preds = %cond.true, %entry
31 %x = phi i8* [ %ptr, %entry ], [ %ptr.i, %cond.true ] ; <i8*> [#uses=1]
32 %tmp3.i = icmp ne i8* %ptr, %x ; <i1> [#uses=1]
33 br i1 %tmp3.i, label %cond.true, label %exit
35 cond.true: ; preds = %loop.head
36 %ptr.i = getelementptr i8* %ptr, i32 0 ; <i8*> [#uses=2]
37 store i8 0, i8* %ptr.i
40 exit: ; preds = %loop.head
44 define i32 @f2(i8* %p, i8* %q) {
48 loop.head: ; preds = %cond.true, %entry
49 %tmp3.i = icmp eq i8* null, %q ; <i1> [#uses=1]
50 br i1 %tmp3.i, label %exit, label %cond.true
52 cond.true: ; preds = %loop.head
53 %ptr.i = getelementptr i8* %p, i32 0 ; <i8*> [#uses=2]
54 store i8 0, i8* %ptr.i
57 exit: ; preds = %loop.head
61 declare void @exit(i32)