1 ; RUN: opt -alignment-from-assumptions -S < %s | FileCheck %s 2 ; RUN: opt -passes=alignment-from-assumptions -S < %s | FileCheck %s 3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 4 target triple = "x86_64-unknown-linux-gnu" 5 6 %type1 = type { %type2 } 7 %type2 = type { [4 x i8] } 8 9 ; Function Attrs: nounwind 10 declare void @llvm.assume(i1) #0 11 12 ; Function Attrs: nounwind readnone 13 declare i32 @llvm.bswap.i32(i32) #1 14 15 ; Function Attrs: nounwind uwtable 16 define void @test1() unnamed_addr #2 align 2 { 17 18 ; CHECK-LABEL: @test1 19 20 entry: 21 br i1 undef, label %if.then, label %if.end 22 23 if.then: ; preds = %entry 24 unreachable 25 26 if.end: ; preds = %entry 27 br i1 undef, label %return, label %if.end8 28 29 if.end8: ; preds = %if.end 30 br i1 undef, label %if.then13, label %if.end14 31 32 if.then13: ; preds = %if.end8 33 unreachable 34 35 if.end14: ; preds = %if.end8 36 br i1 undef, label %cond.false.i129, label %cond.end.i136 37 38 cond.false.i129: ; preds = %if.end14 39 unreachable 40 41 cond.end.i136: ; preds = %if.end14 42 br i1 undef, label %land.lhs.true.i, label %if.end.i145 43 44 land.lhs.true.i: ; preds = %cond.end.i136 45 br i1 undef, label %if.end.i145, label %if.then.i137 46 47 if.then.i137: ; preds = %land.lhs.true.i 48 br i1 undef, label %cond.false8.i, label %cond.end9.i 49 50 cond.false8.i: ; preds = %if.then.i137 51 unreachable 52 53 cond.end9.i: ; preds = %if.then.i137 54 br i1 undef, label %if.then23, label %if.end24 55 56 if.end.i145: ; preds = %land.lhs.true.i, %cond.end.i136 57 unreachable 58 59 if.then23: ; preds = %cond.end9.i 60 unreachable 61 62 if.end24: ; preds = %cond.end9.i 63 br i1 undef, label %for.end, label %for.body.lr.ph 64 65 for.body.lr.ph: ; preds = %if.end24 66 unreachable 67 68 for.end: ; preds = %if.end24 69 br i1 undef, label %if.end123, label %if.then121 70 71 if.then121: ; preds = %for.end 72 unreachable 73 74 if.end123: ; preds = %for.end 75 br i1 undef, label %if.end150, label %if.then126 76 77 if.then126: ; preds = %if.end123 78 %ptrint.i.i185 = ptrtoint %type1* undef to i64 79 %maskedptr.i.i186 = and i64 %ptrint.i.i185, 1 80 %maskcond.i.i187 = icmp eq i64 %maskedptr.i.i186, 0 81 tail call void @llvm.assume(i1 %maskcond.i.i187) #0 82 %ret.0..sroa_cast.i.i188 = bitcast %type1* undef to i32* 83 %ret.0.copyload.i.i189 = load i32, i32* %ret.0..sroa_cast.i.i188, align 2 84 85 ; CHECK: load {{.*}} align 2 86 87 %0 = tail call i32 @llvm.bswap.i32(i32 %ret.0.copyload.i.i189) #0 88 %conv131 = zext i32 %0 to i64 89 %add.ptr132 = getelementptr inbounds i8, i8* undef, i64 %conv131 90 %1 = bitcast i8* %add.ptr132 to %type1* 91 br i1 undef, label %if.end150, label %if.end.i173 92 93 if.end.i173: ; preds = %if.then126 94 br i1 undef, label %test1.exit, label %cond.false.i.i.i.i174 95 96 cond.false.i.i.i.i174: ; preds = %if.end.i173 97 unreachable 98 99 test1.exit: ; preds = %if.end.i173 100 br i1 undef, label %test1a.exit, label %if.end.i124 101 102 if.end.i124: ; preds = %test1.exit 103 unreachable 104 105 test1a.exit: ; preds = %test1.exit 106 br i1 undef, label %if.end150, label %for.body137.lr.ph 107 108 for.body137.lr.ph: ; preds = %test1a.exit 109 br label %for.body137 110 111 for.body137: ; preds = %test1b.exit, %for.body137.lr.ph 112 %ShndxTable.0309 = phi %type1* [ %1, %for.body137.lr.ph ], [ %incdec.ptr, %test1b.exit ] 113 %ret.0..sroa_cast.i.i106 = bitcast %type1* %ShndxTable.0309 to i32* 114 br i1 undef, label %for.body137.if.end146_crit_edge, label %if.then140 115 116 for.body137.if.end146_crit_edge: ; preds = %for.body137 117 %incdec.ptr = getelementptr inbounds %type1, %type1* %ShndxTable.0309, i64 1 118 br i1 undef, label %cond.false.i70, label %cond.end.i 119 120 if.then140: ; preds = %for.body137 121 %ret.0.copyload.i.i102 = load i32, i32* %ret.0..sroa_cast.i.i106, align 2 122 123 ; CHECK: load {{.*}} align 2 124 125 unreachable 126 127 cond.false.i70: ; preds = %for.body137.if.end146_crit_edge 128 unreachable 129 130 cond.end.i: ; preds = %for.body137.if.end146_crit_edge 131 br i1 undef, label %test1b.exit, label %cond.false.i.i 132 133 cond.false.i.i: ; preds = %cond.end.i 134 unreachable 135 136 test1b.exit: ; preds = %cond.end.i 137 br i1 undef, label %if.end150, label %for.body137 138 139 if.end150: ; preds = %test1b.exit, %test1a.exit, %if.then126, %if.end123 140 br i1 undef, label %for.end176, label %for.body155.lr.ph 141 142 for.body155.lr.ph: ; preds = %if.end150 143 unreachable 144 145 for.end176: ; preds = %if.end150 146 unreachable 147 148 return: ; preds = %if.end 149 ret void 150 } 151 152 attributes #0 = { nounwind } 153 attributes #1 = { nounwind readnone } 154 attributes #2 = { nounwind uwtable } 155 156