1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -S %s -o - | FileCheck %s --check-prefix=CHECK-DEC 3; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -force-hardware-loop-phi=true -S %s -o - | FileCheck %s --check-prefix=CHECK-PHI 4; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -force-nested-hardware-loop=true -S %s -o - | FileCheck %s --check-prefix=CHECK-NESTED 5; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -force-hardware-loop-guard=true -S %s -o - | FileCheck %s --check-prefix=CHECK-GUARD 6; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -force-hardware-loop-phi=true -force-hardware-loop-guard=true -S %s -o - | FileCheck %s --check-prefix=CHECK-PHIGUARD 7 8define void @while_lt(i32 %i, i32 %N, i32* nocapture %A) { 9; CHECK-DEC-LABEL: @while_lt( 10; CHECK-DEC-NEXT: entry: 11; CHECK-DEC-NEXT: [[CMP4:%.*]] = icmp ult i32 [[I:%.*]], [[N:%.*]] 12; CHECK-DEC-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 13; CHECK-DEC: while.body.preheader: 14; CHECK-DEC-NEXT: [[TMP0:%.*]] = sub i32 [[N]], [[I]] 15; CHECK-DEC-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP0]]) 16; CHECK-DEC-NEXT: br label [[WHILE_BODY:%.*]] 17; CHECK-DEC: while.body: 18; CHECK-DEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 19; CHECK-DEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 20; CHECK-DEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 21; CHECK-DEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 22; CHECK-DEC-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 23; CHECK-DEC-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 24; CHECK-DEC: while.end: 25; CHECK-DEC-NEXT: ret void 26; 27; CHECK-PHI-LABEL: @while_lt( 28; CHECK-PHI-NEXT: entry: 29; CHECK-PHI-NEXT: [[CMP4:%.*]] = icmp ult i32 [[I:%.*]], [[N:%.*]] 30; CHECK-PHI-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 31; CHECK-PHI: while.body.preheader: 32; CHECK-PHI-NEXT: [[TMP0:%.*]] = sub i32 [[N]], [[I]] 33; CHECK-PHI-NEXT: [[TMP1:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP0]]) 34; CHECK-PHI-NEXT: br label [[WHILE_BODY:%.*]] 35; CHECK-PHI: while.body: 36; CHECK-PHI-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 37; CHECK-PHI-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP1]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP3:%.*]], [[WHILE_BODY]] ] 38; CHECK-PHI-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 39; CHECK-PHI-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 40; CHECK-PHI-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 41; CHECK-PHI-NEXT: [[TMP3]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP2]], i32 1) 42; CHECK-PHI-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0 43; CHECK-PHI-NEXT: br i1 [[TMP4]], label [[WHILE_BODY]], label [[WHILE_END]] 44; CHECK-PHI: while.end: 45; CHECK-PHI-NEXT: ret void 46; 47; CHECK-NESTED-LABEL: @while_lt( 48; CHECK-NESTED-NEXT: entry: 49; CHECK-NESTED-NEXT: [[CMP4:%.*]] = icmp ult i32 [[I:%.*]], [[N:%.*]] 50; CHECK-NESTED-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 51; CHECK-NESTED: while.body.preheader: 52; CHECK-NESTED-NEXT: [[TMP0:%.*]] = sub i32 [[N]], [[I]] 53; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP0]]) 54; CHECK-NESTED-NEXT: br label [[WHILE_BODY:%.*]] 55; CHECK-NESTED: while.body: 56; CHECK-NESTED-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 57; CHECK-NESTED-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 58; CHECK-NESTED-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 59; CHECK-NESTED-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 60; CHECK-NESTED-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 61; CHECK-NESTED-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 62; CHECK-NESTED: while.end: 63; CHECK-NESTED-NEXT: ret void 64; 65; CHECK-GUARD-LABEL: @while_lt( 66; CHECK-GUARD-NEXT: entry: 67; CHECK-GUARD-NEXT: [[CMP4:%.*]] = icmp ult i32 [[I:%.*]], [[N:%.*]] 68; CHECK-GUARD-NEXT: [[TMP0:%.*]] = sub i32 [[N]], [[I]] 69; CHECK-GUARD-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 70; CHECK-GUARD: while.body.preheader: 71; CHECK-GUARD-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP0]]) 72; CHECK-GUARD-NEXT: br label [[WHILE_BODY:%.*]] 73; CHECK-GUARD: while.body: 74; CHECK-GUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 75; CHECK-GUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 76; CHECK-GUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 77; CHECK-GUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 78; CHECK-GUARD-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 79; CHECK-GUARD-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 80; CHECK-GUARD: while.end: 81; CHECK-GUARD-NEXT: ret void 82; 83; CHECK-PHIGUARD-LABEL: @while_lt( 84; CHECK-PHIGUARD-NEXT: entry: 85; CHECK-PHIGUARD-NEXT: [[CMP4:%.*]] = icmp ult i32 [[I:%.*]], [[N:%.*]] 86; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = sub i32 [[N]], [[I]] 87; CHECK-PHIGUARD-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 88; CHECK-PHIGUARD: while.body.preheader: 89; CHECK-PHIGUARD-NEXT: [[TMP1:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP0]]) 90; CHECK-PHIGUARD-NEXT: br label [[WHILE_BODY:%.*]] 91; CHECK-PHIGUARD: while.body: 92; CHECK-PHIGUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 93; CHECK-PHIGUARD-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP1]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP3:%.*]], [[WHILE_BODY]] ] 94; CHECK-PHIGUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 95; CHECK-PHIGUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 96; CHECK-PHIGUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 97; CHECK-PHIGUARD-NEXT: [[TMP3]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP2]], i32 1) 98; CHECK-PHIGUARD-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0 99; CHECK-PHIGUARD-NEXT: br i1 [[TMP4]], label [[WHILE_BODY]], label [[WHILE_END]] 100; CHECK-PHIGUARD: while.end: 101; CHECK-PHIGUARD-NEXT: ret void 102; 103; CHECK-REGDEC-LABEL: @while_lt( 104; CHECK-REGDEC-NEXT: entry: 105; CHECK-REGDEC-NEXT: [[CMP4:%.*]] = icmp ult i32 [[I:%.*]], [[N:%.*]] 106; CHECK-REGDEC-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 107; CHECK-REGDEC: while.body.preheader: 108; CHECK-REGDEC-NEXT: [[TMP0:%.*]] = sub i32 [[N]], [[I]] 109; CHECK-REGDEC-NEXT: [[TMP1:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP0]]) 110; CHECK-REGDEC-NEXT: br label [[WHILE_BODY:%.*]] 111; CHECK-REGDEC: while.body: 112; CHECK-REGDEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 113; CHECK-REGDEC-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP1]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP3:%.*]], [[WHILE_BODY]] ] 114; CHECK-REGDEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 115; CHECK-REGDEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 116; CHECK-REGDEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 117; CHECK-REGDEC-NEXT: [[TMP3]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP2]], i32 1) 118; CHECK-REGDEC-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0 119; CHECK-REGDEC-NEXT: br i1 [[TMP4]], label [[WHILE_BODY]], label [[WHILE_END]] 120; CHECK-REGDEC: while.end: 121; CHECK-REGDEC-NEXT: ret void 122entry: 123 %cmp4 = icmp ult i32 %i, %N 124 br i1 %cmp4, label %while.body, label %while.end 125 126while.body: 127 %i.addr.05 = phi i32 [ %inc, %while.body ], [ %i, %entry ] 128 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.addr.05 129 store i32 %i.addr.05, i32* %arrayidx, align 4 130 %inc = add nuw i32 %i.addr.05, 1 131 %exitcond = icmp eq i32 %inc, %N 132 br i1 %exitcond, label %while.end, label %while.body 133 134while.end: 135 ret void 136} 137 138define void @while_gt(i32 %i, i32 %N, i32* nocapture %A) { 139; CHECK-DEC-LABEL: @while_gt( 140; CHECK-DEC-NEXT: entry: 141; CHECK-DEC-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[I:%.*]], [[N:%.*]] 142; CHECK-DEC-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 143; CHECK-DEC: while.body.preheader: 144; CHECK-DEC-NEXT: [[TMP0:%.*]] = sub i32 [[I]], [[N]] 145; CHECK-DEC-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP0]]) 146; CHECK-DEC-NEXT: br label [[WHILE_BODY:%.*]] 147; CHECK-DEC: while.body: 148; CHECK-DEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 149; CHECK-DEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 150; CHECK-DEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 151; CHECK-DEC-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 152; CHECK-DEC-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 153; CHECK-DEC-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 154; CHECK-DEC: while.end: 155; CHECK-DEC-NEXT: ret void 156; 157; CHECK-PHI-LABEL: @while_gt( 158; CHECK-PHI-NEXT: entry: 159; CHECK-PHI-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[I:%.*]], [[N:%.*]] 160; CHECK-PHI-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 161; CHECK-PHI: while.body.preheader: 162; CHECK-PHI-NEXT: [[TMP0:%.*]] = sub i32 [[I]], [[N]] 163; CHECK-PHI-NEXT: [[TMP1:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP0]]) 164; CHECK-PHI-NEXT: br label [[WHILE_BODY:%.*]] 165; CHECK-PHI: while.body: 166; CHECK-PHI-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 167; CHECK-PHI-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP1]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP3:%.*]], [[WHILE_BODY]] ] 168; CHECK-PHI-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 169; CHECK-PHI-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 170; CHECK-PHI-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 171; CHECK-PHI-NEXT: [[TMP3]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP2]], i32 1) 172; CHECK-PHI-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0 173; CHECK-PHI-NEXT: br i1 [[TMP4]], label [[WHILE_BODY]], label [[WHILE_END]] 174; CHECK-PHI: while.end: 175; CHECK-PHI-NEXT: ret void 176; 177; CHECK-NESTED-LABEL: @while_gt( 178; CHECK-NESTED-NEXT: entry: 179; CHECK-NESTED-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[I:%.*]], [[N:%.*]] 180; CHECK-NESTED-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 181; CHECK-NESTED: while.body.preheader: 182; CHECK-NESTED-NEXT: [[TMP0:%.*]] = sub i32 [[I]], [[N]] 183; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP0]]) 184; CHECK-NESTED-NEXT: br label [[WHILE_BODY:%.*]] 185; CHECK-NESTED: while.body: 186; CHECK-NESTED-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 187; CHECK-NESTED-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 188; CHECK-NESTED-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 189; CHECK-NESTED-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 190; CHECK-NESTED-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 191; CHECK-NESTED-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 192; CHECK-NESTED: while.end: 193; CHECK-NESTED-NEXT: ret void 194; 195; CHECK-GUARD-LABEL: @while_gt( 196; CHECK-GUARD-NEXT: entry: 197; CHECK-GUARD-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[I:%.*]], [[N:%.*]] 198; CHECK-GUARD-NEXT: [[TMP0:%.*]] = sub i32 [[I]], [[N]] 199; CHECK-GUARD-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 200; CHECK-GUARD: while.body.preheader: 201; CHECK-GUARD-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP0]]) 202; CHECK-GUARD-NEXT: br label [[WHILE_BODY:%.*]] 203; CHECK-GUARD: while.body: 204; CHECK-GUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 205; CHECK-GUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 206; CHECK-GUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 207; CHECK-GUARD-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 208; CHECK-GUARD-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 209; CHECK-GUARD-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 210; CHECK-GUARD: while.end: 211; CHECK-GUARD-NEXT: ret void 212; 213; CHECK-PHIGUARD-LABEL: @while_gt( 214; CHECK-PHIGUARD-NEXT: entry: 215; CHECK-PHIGUARD-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[I:%.*]], [[N:%.*]] 216; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = sub i32 [[I]], [[N]] 217; CHECK-PHIGUARD-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 218; CHECK-PHIGUARD: while.body.preheader: 219; CHECK-PHIGUARD-NEXT: [[TMP1:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP0]]) 220; CHECK-PHIGUARD-NEXT: br label [[WHILE_BODY:%.*]] 221; CHECK-PHIGUARD: while.body: 222; CHECK-PHIGUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 223; CHECK-PHIGUARD-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP1]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP3:%.*]], [[WHILE_BODY]] ] 224; CHECK-PHIGUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 225; CHECK-PHIGUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 226; CHECK-PHIGUARD-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 227; CHECK-PHIGUARD-NEXT: [[TMP3]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP2]], i32 1) 228; CHECK-PHIGUARD-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0 229; CHECK-PHIGUARD-NEXT: br i1 [[TMP4]], label [[WHILE_BODY]], label [[WHILE_END]] 230; CHECK-PHIGUARD: while.end: 231; CHECK-PHIGUARD-NEXT: ret void 232; 233; CHECK-REGDEC-LABEL: @while_gt( 234; CHECK-REGDEC-NEXT: entry: 235; CHECK-REGDEC-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[I:%.*]], [[N:%.*]] 236; CHECK-REGDEC-NEXT: br i1 [[CMP4]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 237; CHECK-REGDEC: while.body.preheader: 238; CHECK-REGDEC-NEXT: [[TMP0:%.*]] = sub i32 [[I]], [[N]] 239; CHECK-REGDEC-NEXT: [[TMP1:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP0]]) 240; CHECK-REGDEC-NEXT: br label [[WHILE_BODY:%.*]] 241; CHECK-REGDEC: while.body: 242; CHECK-REGDEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 243; CHECK-REGDEC-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP1]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP3:%.*]], [[WHILE_BODY]] ] 244; CHECK-REGDEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 245; CHECK-REGDEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 246; CHECK-REGDEC-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 247; CHECK-REGDEC-NEXT: [[TMP3]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP2]], i32 1) 248; CHECK-REGDEC-NEXT: [[TMP4:%.*]] = icmp ne i32 [[TMP3]], 0 249; CHECK-REGDEC-NEXT: br i1 [[TMP4]], label [[WHILE_BODY]], label [[WHILE_END]] 250; CHECK-REGDEC: while.end: 251; CHECK-REGDEC-NEXT: ret void 252entry: 253 %cmp4 = icmp sgt i32 %i, %N 254 br i1 %cmp4, label %while.body, label %while.end 255 256while.body: 257 %i.addr.05 = phi i32 [ %dec, %while.body ], [ %i, %entry ] 258 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.addr.05 259 store i32 %i.addr.05, i32* %arrayidx, align 4 260 %dec = add nsw i32 %i.addr.05, -1 261 %cmp = icmp sgt i32 %dec, %N 262 br i1 %cmp, label %while.body, label %while.end 263 264while.end: 265 ret void 266} 267 268define void @while_gte(i32 %i, i32 %N, i32* nocapture %A) { 269; CHECK-DEC-LABEL: @while_gte( 270; CHECK-DEC-NEXT: entry: 271; CHECK-DEC-NEXT: [[CMP4:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]] 272; CHECK-DEC-NEXT: br i1 [[CMP4]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 273; CHECK-DEC: while.body.preheader: 274; CHECK-DEC-NEXT: [[TMP0:%.*]] = add i32 [[I]], 1 275; CHECK-DEC-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[N]] 276; CHECK-DEC-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP1]]) 277; CHECK-DEC-NEXT: br label [[WHILE_BODY:%.*]] 278; CHECK-DEC: while.body: 279; CHECK-DEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 280; CHECK-DEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 281; CHECK-DEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 282; CHECK-DEC-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 283; CHECK-DEC-NEXT: [[TMP2:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 284; CHECK-DEC-NEXT: br i1 [[TMP2]], label [[WHILE_BODY]], label [[WHILE_END]] 285; CHECK-DEC: while.end: 286; CHECK-DEC-NEXT: ret void 287; 288; CHECK-PHI-LABEL: @while_gte( 289; CHECK-PHI-NEXT: entry: 290; CHECK-PHI-NEXT: [[CMP4:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]] 291; CHECK-PHI-NEXT: br i1 [[CMP4]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 292; CHECK-PHI: while.body.preheader: 293; CHECK-PHI-NEXT: [[TMP0:%.*]] = add i32 [[I]], 1 294; CHECK-PHI-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[N]] 295; CHECK-PHI-NEXT: [[TMP2:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP1]]) 296; CHECK-PHI-NEXT: br label [[WHILE_BODY:%.*]] 297; CHECK-PHI: while.body: 298; CHECK-PHI-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 299; CHECK-PHI-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP2]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP4:%.*]], [[WHILE_BODY]] ] 300; CHECK-PHI-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 301; CHECK-PHI-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 302; CHECK-PHI-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 303; CHECK-PHI-NEXT: [[TMP4]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP3]], i32 1) 304; CHECK-PHI-NEXT: [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0 305; CHECK-PHI-NEXT: br i1 [[TMP5]], label [[WHILE_BODY]], label [[WHILE_END]] 306; CHECK-PHI: while.end: 307; CHECK-PHI-NEXT: ret void 308; 309; CHECK-NESTED-LABEL: @while_gte( 310; CHECK-NESTED-NEXT: entry: 311; CHECK-NESTED-NEXT: [[CMP4:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]] 312; CHECK-NESTED-NEXT: br i1 [[CMP4]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 313; CHECK-NESTED: while.body.preheader: 314; CHECK-NESTED-NEXT: [[TMP0:%.*]] = add i32 [[I]], 1 315; CHECK-NESTED-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[N]] 316; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP1]]) 317; CHECK-NESTED-NEXT: br label [[WHILE_BODY:%.*]] 318; CHECK-NESTED: while.body: 319; CHECK-NESTED-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 320; CHECK-NESTED-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 321; CHECK-NESTED-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 322; CHECK-NESTED-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 323; CHECK-NESTED-NEXT: [[TMP2:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 324; CHECK-NESTED-NEXT: br i1 [[TMP2]], label [[WHILE_BODY]], label [[WHILE_END]] 325; CHECK-NESTED: while.end: 326; CHECK-NESTED-NEXT: ret void 327; 328; CHECK-GUARD-LABEL: @while_gte( 329; CHECK-GUARD-NEXT: entry: 330; CHECK-GUARD-NEXT: [[CMP4:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]] 331; CHECK-GUARD-NEXT: br i1 [[CMP4]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 332; CHECK-GUARD: while.body.preheader: 333; CHECK-GUARD-NEXT: [[TMP0:%.*]] = add i32 [[I]], 1 334; CHECK-GUARD-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[N]] 335; CHECK-GUARD-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[TMP1]]) 336; CHECK-GUARD-NEXT: br label [[WHILE_BODY:%.*]] 337; CHECK-GUARD: while.body: 338; CHECK-GUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 339; CHECK-GUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 340; CHECK-GUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 341; CHECK-GUARD-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 342; CHECK-GUARD-NEXT: [[TMP2:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 343; CHECK-GUARD-NEXT: br i1 [[TMP2]], label [[WHILE_BODY]], label [[WHILE_END]] 344; CHECK-GUARD: while.end: 345; CHECK-GUARD-NEXT: ret void 346; 347; CHECK-PHIGUARD-LABEL: @while_gte( 348; CHECK-PHIGUARD-NEXT: entry: 349; CHECK-PHIGUARD-NEXT: [[CMP4:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]] 350; CHECK-PHIGUARD-NEXT: br i1 [[CMP4]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 351; CHECK-PHIGUARD: while.body.preheader: 352; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = add i32 [[I]], 1 353; CHECK-PHIGUARD-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[N]] 354; CHECK-PHIGUARD-NEXT: [[TMP2:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP1]]) 355; CHECK-PHIGUARD-NEXT: br label [[WHILE_BODY:%.*]] 356; CHECK-PHIGUARD: while.body: 357; CHECK-PHIGUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 358; CHECK-PHIGUARD-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP2]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP4:%.*]], [[WHILE_BODY]] ] 359; CHECK-PHIGUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 360; CHECK-PHIGUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 361; CHECK-PHIGUARD-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 362; CHECK-PHIGUARD-NEXT: [[TMP4]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP3]], i32 1) 363; CHECK-PHIGUARD-NEXT: [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0 364; CHECK-PHIGUARD-NEXT: br i1 [[TMP5]], label [[WHILE_BODY]], label [[WHILE_END]] 365; CHECK-PHIGUARD: while.end: 366; CHECK-PHIGUARD-NEXT: ret void 367; 368; CHECK-REGDEC-LABEL: @while_gte( 369; CHECK-REGDEC-NEXT: entry: 370; CHECK-REGDEC-NEXT: [[CMP4:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]] 371; CHECK-REGDEC-NEXT: br i1 [[CMP4]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 372; CHECK-REGDEC: while.body.preheader: 373; CHECK-REGDEC-NEXT: [[TMP0:%.*]] = add i32 [[I]], 1 374; CHECK-REGDEC-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[N]] 375; CHECK-REGDEC-NEXT: [[TMP2:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP1]]) 376; CHECK-REGDEC-NEXT: br label [[WHILE_BODY:%.*]] 377; CHECK-REGDEC: while.body: 378; CHECK-REGDEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[I]], [[WHILE_BODY_PREHEADER]] ] 379; CHECK-REGDEC-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP2]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP4:%.*]], [[WHILE_BODY]] ] 380; CHECK-REGDEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 381; CHECK-REGDEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 382; CHECK-REGDEC-NEXT: [[DEC]] = add nsw i32 [[I_ADDR_05]], -1 383; CHECK-REGDEC-NEXT: [[TMP4]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP3]], i32 1) 384; CHECK-REGDEC-NEXT: [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0 385; CHECK-REGDEC-NEXT: br i1 [[TMP5]], label [[WHILE_BODY]], label [[WHILE_END]] 386; CHECK-REGDEC: while.end: 387; CHECK-REGDEC-NEXT: ret void 388entry: 389 %cmp4 = icmp slt i32 %i, %N 390 br i1 %cmp4, label %while.end, label %while.body 391 392while.body: 393 %i.addr.05 = phi i32 [ %dec, %while.body ], [ %i, %entry ] 394 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.addr.05 395 store i32 %i.addr.05, i32* %arrayidx, align 4 396 %dec = add nsw i32 %i.addr.05, -1 397 %cmp = icmp sgt i32 %i.addr.05, %N 398 br i1 %cmp, label %while.body, label %while.end 399 400while.end: 401 ret void 402} 403 404define void @while_ne(i32 %N, i32* nocapture %A) { 405; CHECK-DEC-LABEL: @while_ne( 406; CHECK-DEC-NEXT: entry: 407; CHECK-DEC-NEXT: [[CMP:%.*]] = icmp ne i32 [[N:%.*]], 0 408; CHECK-DEC-NEXT: br i1 [[CMP]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 409; CHECK-DEC: while.body.preheader: 410; CHECK-DEC-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 411; CHECK-DEC-NEXT: br label [[WHILE_BODY:%.*]] 412; CHECK-DEC: while.body: 413; CHECK-DEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 414; CHECK-DEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 415; CHECK-DEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 416; CHECK-DEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 417; CHECK-DEC-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 418; CHECK-DEC-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[WHILE_END]] 419; CHECK-DEC: while.end: 420; CHECK-DEC-NEXT: ret void 421; 422; CHECK-PHI-LABEL: @while_ne( 423; CHECK-PHI-NEXT: entry: 424; CHECK-PHI-NEXT: [[CMP:%.*]] = icmp ne i32 [[N:%.*]], 0 425; CHECK-PHI-NEXT: br i1 [[CMP]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 426; CHECK-PHI: while.body.preheader: 427; CHECK-PHI-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 428; CHECK-PHI-NEXT: br label [[WHILE_BODY:%.*]] 429; CHECK-PHI: while.body: 430; CHECK-PHI-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 431; CHECK-PHI-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 432; CHECK-PHI-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 433; CHECK-PHI-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 434; CHECK-PHI-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 435; CHECK-PHI-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 436; CHECK-PHI-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 437; CHECK-PHI-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 438; CHECK-PHI: while.end: 439; CHECK-PHI-NEXT: ret void 440; 441; CHECK-NESTED-LABEL: @while_ne( 442; CHECK-NESTED-NEXT: entry: 443; CHECK-NESTED-NEXT: [[CMP:%.*]] = icmp ne i32 [[N:%.*]], 0 444; CHECK-NESTED-NEXT: br i1 [[CMP]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 445; CHECK-NESTED: while.body.preheader: 446; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 447; CHECK-NESTED-NEXT: br label [[WHILE_BODY:%.*]] 448; CHECK-NESTED: while.body: 449; CHECK-NESTED-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 450; CHECK-NESTED-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 451; CHECK-NESTED-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 452; CHECK-NESTED-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 453; CHECK-NESTED-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 454; CHECK-NESTED-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[WHILE_END]] 455; CHECK-NESTED: while.end: 456; CHECK-NESTED-NEXT: ret void 457; 458; CHECK-GUARD-LABEL: @while_ne( 459; CHECK-GUARD-NEXT: entry: 460; CHECK-GUARD-NEXT: [[CMP:%.*]] = icmp ne i32 [[N:%.*]], 0 461; CHECK-GUARD-NEXT: [[TMP0:%.*]] = call i1 @llvm.test.set.loop.iterations.i32(i32 [[N]]) 462; CHECK-GUARD-NEXT: br i1 [[TMP0]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 463; CHECK-GUARD: while.body.preheader: 464; CHECK-GUARD-NEXT: br label [[WHILE_BODY:%.*]] 465; CHECK-GUARD: while.body: 466; CHECK-GUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 467; CHECK-GUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 468; CHECK-GUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 469; CHECK-GUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 470; CHECK-GUARD-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 471; CHECK-GUARD-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 472; CHECK-GUARD: while.end: 473; CHECK-GUARD-NEXT: ret void 474; 475; CHECK-PHIGUARD-LABEL: @while_ne( 476; CHECK-PHIGUARD-NEXT: entry: 477; CHECK-PHIGUARD-NEXT: [[CMP:%.*]] = icmp ne i32 [[N:%.*]], 0 478; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = call i1 @llvm.test.set.loop.iterations.i32(i32 [[N]]) 479; CHECK-PHIGUARD-NEXT: br i1 [[TMP0]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 480; CHECK-PHIGUARD: while.body.preheader: 481; CHECK-PHIGUARD-NEXT: br label [[WHILE_BODY:%.*]] 482; CHECK-PHIGUARD: while.body: 483; CHECK-PHIGUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 484; CHECK-PHIGUARD-NEXT: [[TMP1:%.*]] = phi i32 [ [[N]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 485; CHECK-PHIGUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 486; CHECK-PHIGUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 487; CHECK-PHIGUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 488; CHECK-PHIGUARD-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 489; CHECK-PHIGUARD-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 490; CHECK-PHIGUARD-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 491; CHECK-PHIGUARD: while.end: 492; CHECK-PHIGUARD-NEXT: ret void 493; 494; CHECK-REGDEC-LABEL: @while_ne( 495; CHECK-REGDEC-NEXT: entry: 496; CHECK-REGDEC-NEXT: [[CMP:%.*]] = icmp ne i32 [[N:%.*]], 0 497; CHECK-REGDEC-NEXT: br i1 [[CMP]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 498; CHECK-REGDEC: while.body.preheader: 499; CHECK-REGDEC-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 500; CHECK-REGDEC-NEXT: br label [[WHILE_BODY:%.*]] 501; CHECK-REGDEC: while.body: 502; CHECK-REGDEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 503; CHECK-REGDEC-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 504; CHECK-REGDEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 505; CHECK-REGDEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 506; CHECK-REGDEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 507; CHECK-REGDEC-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 508; CHECK-REGDEC-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 509; CHECK-REGDEC-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 510; CHECK-REGDEC: while.end: 511; CHECK-REGDEC-NEXT: ret void 512entry: 513 %cmp = icmp ne i32 %N, 0 514 br i1 %cmp, label %while.body, label %while.end 515 516while.body: 517 %i.addr.05 = phi i32 [ %inc, %while.body ], [ 0, %entry ] 518 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.addr.05 519 store i32 %i.addr.05, i32* %arrayidx, align 4 520 %inc = add nuw i32 %i.addr.05, 1 521 %exitcond = icmp eq i32 %inc, %N 522 br i1 %exitcond, label %while.end, label %while.body 523 524while.end: 525 ret void 526} 527 528define void @while_eq(i32 %N, i32* nocapture %A) { 529; CHECK-DEC-LABEL: @while_eq( 530; CHECK-DEC-NEXT: entry: 531; CHECK-DEC-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 532; CHECK-DEC-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 533; CHECK-DEC: while.body.preheader: 534; CHECK-DEC-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 535; CHECK-DEC-NEXT: br label [[WHILE_BODY:%.*]] 536; CHECK-DEC: while.body: 537; CHECK-DEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 538; CHECK-DEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 539; CHECK-DEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 540; CHECK-DEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 541; CHECK-DEC-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 542; CHECK-DEC-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[WHILE_END]] 543; CHECK-DEC: while.end: 544; CHECK-DEC-NEXT: ret void 545; 546; CHECK-PHI-LABEL: @while_eq( 547; CHECK-PHI-NEXT: entry: 548; CHECK-PHI-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 549; CHECK-PHI-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 550; CHECK-PHI: while.body.preheader: 551; CHECK-PHI-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 552; CHECK-PHI-NEXT: br label [[WHILE_BODY:%.*]] 553; CHECK-PHI: while.body: 554; CHECK-PHI-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 555; CHECK-PHI-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 556; CHECK-PHI-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 557; CHECK-PHI-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 558; CHECK-PHI-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 559; CHECK-PHI-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 560; CHECK-PHI-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 561; CHECK-PHI-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 562; CHECK-PHI: while.end: 563; CHECK-PHI-NEXT: ret void 564; 565; CHECK-NESTED-LABEL: @while_eq( 566; CHECK-NESTED-NEXT: entry: 567; CHECK-NESTED-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 568; CHECK-NESTED-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 569; CHECK-NESTED: while.body.preheader: 570; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 571; CHECK-NESTED-NEXT: br label [[WHILE_BODY:%.*]] 572; CHECK-NESTED: while.body: 573; CHECK-NESTED-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 574; CHECK-NESTED-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 575; CHECK-NESTED-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 576; CHECK-NESTED-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 577; CHECK-NESTED-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 578; CHECK-NESTED-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[WHILE_END]] 579; CHECK-NESTED: while.end: 580; CHECK-NESTED-NEXT: ret void 581; 582; CHECK-GUARD-LABEL: @while_eq( 583; CHECK-GUARD-NEXT: entry: 584; CHECK-GUARD-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 585; CHECK-GUARD-NEXT: [[TMP0:%.*]] = call i1 @llvm.test.set.loop.iterations.i32(i32 [[N]]) 586; CHECK-GUARD-NEXT: br i1 [[TMP0]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 587; CHECK-GUARD: while.body.preheader: 588; CHECK-GUARD-NEXT: br label [[WHILE_BODY:%.*]] 589; CHECK-GUARD: while.body: 590; CHECK-GUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 591; CHECK-GUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 592; CHECK-GUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 593; CHECK-GUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 594; CHECK-GUARD-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 595; CHECK-GUARD-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 596; CHECK-GUARD: while.end: 597; CHECK-GUARD-NEXT: ret void 598; 599; CHECK-PHIGUARD-LABEL: @while_eq( 600; CHECK-PHIGUARD-NEXT: entry: 601; CHECK-PHIGUARD-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 602; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = call i1 @llvm.test.set.loop.iterations.i32(i32 [[N]]) 603; CHECK-PHIGUARD-NEXT: br i1 [[TMP0]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 604; CHECK-PHIGUARD: while.body.preheader: 605; CHECK-PHIGUARD-NEXT: br label [[WHILE_BODY:%.*]] 606; CHECK-PHIGUARD: while.body: 607; CHECK-PHIGUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 608; CHECK-PHIGUARD-NEXT: [[TMP1:%.*]] = phi i32 [ [[N]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 609; CHECK-PHIGUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 610; CHECK-PHIGUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 611; CHECK-PHIGUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 612; CHECK-PHIGUARD-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 613; CHECK-PHIGUARD-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 614; CHECK-PHIGUARD-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 615; CHECK-PHIGUARD: while.end: 616; CHECK-PHIGUARD-NEXT: ret void 617; 618; CHECK-REGDEC-LABEL: @while_eq( 619; CHECK-REGDEC-NEXT: entry: 620; CHECK-REGDEC-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 621; CHECK-REGDEC-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 622; CHECK-REGDEC: while.body.preheader: 623; CHECK-REGDEC-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 624; CHECK-REGDEC-NEXT: br label [[WHILE_BODY:%.*]] 625; CHECK-REGDEC: while.body: 626; CHECK-REGDEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 627; CHECK-REGDEC-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 628; CHECK-REGDEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 629; CHECK-REGDEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 630; CHECK-REGDEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 631; CHECK-REGDEC-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 632; CHECK-REGDEC-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 633; CHECK-REGDEC-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 634; CHECK-REGDEC: while.end: 635; CHECK-REGDEC-NEXT: ret void 636entry: 637 %cmp = icmp eq i32 %N, 0 638 br i1 %cmp, label %while.end, label %while.body 639 640while.body: 641 %i.addr.05 = phi i32 [ %inc, %while.body ], [ 0, %entry ] 642 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.addr.05 643 store i32 %i.addr.05, i32* %arrayidx, align 4 644 %inc = add nuw i32 %i.addr.05, 1 645 %exitcond = icmp eq i32 %inc, %N 646 br i1 %exitcond, label %while.end, label %while.body 647 648while.end: 649 ret void 650} 651 652define void @while_preheader_eq(i32 %N, i32* nocapture %A) { 653; CHECK-DEC-LABEL: @while_preheader_eq( 654; CHECK-DEC-NEXT: entry: 655; CHECK-DEC-NEXT: br label [[PREHEADER:%.*]] 656; CHECK-DEC: preheader: 657; CHECK-DEC-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 658; CHECK-DEC-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 659; CHECK-DEC: while.body.preheader: 660; CHECK-DEC-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 661; CHECK-DEC-NEXT: br label [[WHILE_BODY:%.*]] 662; CHECK-DEC: while.body: 663; CHECK-DEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 664; CHECK-DEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 665; CHECK-DEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 666; CHECK-DEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 667; CHECK-DEC-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 668; CHECK-DEC-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[WHILE_END]] 669; CHECK-DEC: while.end: 670; CHECK-DEC-NEXT: ret void 671; 672; CHECK-PHI-LABEL: @while_preheader_eq( 673; CHECK-PHI-NEXT: entry: 674; CHECK-PHI-NEXT: br label [[PREHEADER:%.*]] 675; CHECK-PHI: preheader: 676; CHECK-PHI-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 677; CHECK-PHI-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 678; CHECK-PHI: while.body.preheader: 679; CHECK-PHI-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 680; CHECK-PHI-NEXT: br label [[WHILE_BODY:%.*]] 681; CHECK-PHI: while.body: 682; CHECK-PHI-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 683; CHECK-PHI-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 684; CHECK-PHI-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 685; CHECK-PHI-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 686; CHECK-PHI-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 687; CHECK-PHI-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 688; CHECK-PHI-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 689; CHECK-PHI-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 690; CHECK-PHI: while.end: 691; CHECK-PHI-NEXT: ret void 692; 693; CHECK-NESTED-LABEL: @while_preheader_eq( 694; CHECK-NESTED-NEXT: entry: 695; CHECK-NESTED-NEXT: br label [[PREHEADER:%.*]] 696; CHECK-NESTED: preheader: 697; CHECK-NESTED-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 698; CHECK-NESTED-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 699; CHECK-NESTED: while.body.preheader: 700; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 701; CHECK-NESTED-NEXT: br label [[WHILE_BODY:%.*]] 702; CHECK-NESTED: while.body: 703; CHECK-NESTED-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 704; CHECK-NESTED-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 705; CHECK-NESTED-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 706; CHECK-NESTED-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 707; CHECK-NESTED-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 708; CHECK-NESTED-NEXT: br i1 [[TMP0]], label [[WHILE_BODY]], label [[WHILE_END]] 709; CHECK-NESTED: while.end: 710; CHECK-NESTED-NEXT: ret void 711; 712; CHECK-GUARD-LABEL: @while_preheader_eq( 713; CHECK-GUARD-NEXT: entry: 714; CHECK-GUARD-NEXT: br label [[PREHEADER:%.*]] 715; CHECK-GUARD: preheader: 716; CHECK-GUARD-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 717; CHECK-GUARD-NEXT: [[TMP0:%.*]] = call i1 @llvm.test.set.loop.iterations.i32(i32 [[N]]) 718; CHECK-GUARD-NEXT: br i1 [[TMP0]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 719; CHECK-GUARD: while.body.preheader: 720; CHECK-GUARD-NEXT: br label [[WHILE_BODY:%.*]] 721; CHECK-GUARD: while.body: 722; CHECK-GUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 723; CHECK-GUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 724; CHECK-GUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 725; CHECK-GUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 726; CHECK-GUARD-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 727; CHECK-GUARD-NEXT: br i1 [[TMP1]], label [[WHILE_BODY]], label [[WHILE_END]] 728; CHECK-GUARD: while.end: 729; CHECK-GUARD-NEXT: ret void 730; 731; CHECK-PHIGUARD-LABEL: @while_preheader_eq( 732; CHECK-PHIGUARD-NEXT: entry: 733; CHECK-PHIGUARD-NEXT: br label [[PREHEADER:%.*]] 734; CHECK-PHIGUARD: preheader: 735; CHECK-PHIGUARD-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 736; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = call i1 @llvm.test.set.loop.iterations.i32(i32 [[N]]) 737; CHECK-PHIGUARD-NEXT: br i1 [[TMP0]], label [[WHILE_BODY_PREHEADER:%.*]], label [[WHILE_END:%.*]] 738; CHECK-PHIGUARD: while.body.preheader: 739; CHECK-PHIGUARD-NEXT: br label [[WHILE_BODY:%.*]] 740; CHECK-PHIGUARD: while.body: 741; CHECK-PHIGUARD-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 742; CHECK-PHIGUARD-NEXT: [[TMP1:%.*]] = phi i32 [ [[N]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 743; CHECK-PHIGUARD-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 744; CHECK-PHIGUARD-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 745; CHECK-PHIGUARD-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 746; CHECK-PHIGUARD-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 747; CHECK-PHIGUARD-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 748; CHECK-PHIGUARD-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 749; CHECK-PHIGUARD: while.end: 750; CHECK-PHIGUARD-NEXT: ret void 751; 752; CHECK-REGDEC-LABEL: @while_preheader_eq( 753; CHECK-REGDEC-NEXT: entry: 754; CHECK-REGDEC-NEXT: br label [[PREHEADER:%.*]] 755; CHECK-REGDEC: preheader: 756; CHECK-REGDEC-NEXT: [[CMP:%.*]] = icmp eq i32 [[N:%.*]], 0 757; CHECK-REGDEC-NEXT: br i1 [[CMP]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 758; CHECK-REGDEC: while.body.preheader: 759; CHECK-REGDEC-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 760; CHECK-REGDEC-NEXT: br label [[WHILE_BODY:%.*]] 761; CHECK-REGDEC: while.body: 762; CHECK-REGDEC-NEXT: [[I_ADDR_05:%.*]] = phi i32 [ [[INC:%.*]], [[WHILE_BODY]] ], [ 0, [[WHILE_BODY_PREHEADER]] ] 763; CHECK-REGDEC-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_BODY_PREHEADER]] ], [ [[TMP2:%.*]], [[WHILE_BODY]] ] 764; CHECK-REGDEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[I_ADDR_05]] 765; CHECK-REGDEC-NEXT: store i32 [[I_ADDR_05]], i32* [[ARRAYIDX]], align 4 766; CHECK-REGDEC-NEXT: [[INC]] = add nuw i32 [[I_ADDR_05]], 1 767; CHECK-REGDEC-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 768; CHECK-REGDEC-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 769; CHECK-REGDEC-NEXT: br i1 [[TMP3]], label [[WHILE_BODY]], label [[WHILE_END]] 770; CHECK-REGDEC: while.end: 771; CHECK-REGDEC-NEXT: ret void 772entry: 773 br label %preheader 774 775preheader: 776 %cmp = icmp eq i32 %N, 0 777 br i1 %cmp, label %while.end, label %while.body 778 779while.body: 780 %i.addr.05 = phi i32 [ %inc, %while.body ], [ 0, %preheader ] 781 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.addr.05 782 store i32 %i.addr.05, i32* %arrayidx, align 4 783 %inc = add nuw i32 %i.addr.05, 1 784 %exitcond = icmp eq i32 %inc, %N 785 br i1 %exitcond, label %while.end, label %while.body 786 787while.end: 788 ret void 789} 790 791define void @nested(i32* nocapture %A, i32 %N) { 792; CHECK-DEC-LABEL: @nested( 793; CHECK-DEC-NEXT: entry: 794; CHECK-DEC-NEXT: [[CMP20:%.*]] = icmp eq i32 [[N:%.*]], 0 795; CHECK-DEC-NEXT: br i1 [[CMP20]], label [[WHILE_END7:%.*]], label [[WHILE_COND1_PREHEADER_US:%.*]] 796; CHECK-DEC: while.cond1.preheader.us: 797; CHECK-DEC-NEXT: [[I_021_US:%.*]] = phi i32 [ [[INC6_US:%.*]], [[WHILE_COND1_WHILE_END_CRIT_EDGE_US:%.*]] ], [ 0, [[ENTRY:%.*]] ] 798; CHECK-DEC-NEXT: [[MUL_US:%.*]] = mul i32 [[I_021_US]], [[N]] 799; CHECK-DEC-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 800; CHECK-DEC-NEXT: br label [[WHILE_BODY3_US:%.*]] 801; CHECK-DEC: while.body3.us: 802; CHECK-DEC-NEXT: [[J_019_US:%.*]] = phi i32 [ 0, [[WHILE_COND1_PREHEADER_US]] ], [ [[INC_US:%.*]], [[WHILE_BODY3_US]] ] 803; CHECK-DEC-NEXT: [[ADD_US:%.*]] = add i32 [[J_019_US]], [[MUL_US]] 804; CHECK-DEC-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[ADD_US]] 805; CHECK-DEC-NEXT: store i32 [[ADD_US]], i32* [[ARRAYIDX_US]], align 4 806; CHECK-DEC-NEXT: [[INC_US]] = add nuw i32 [[J_019_US]], 1 807; CHECK-DEC-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 808; CHECK-DEC-NEXT: br i1 [[TMP0]], label [[WHILE_BODY3_US]], label [[WHILE_COND1_WHILE_END_CRIT_EDGE_US]] 809; CHECK-DEC: while.cond1.while.end_crit_edge.us: 810; CHECK-DEC-NEXT: [[INC6_US]] = add nuw i32 [[I_021_US]], 1 811; CHECK-DEC-NEXT: [[EXITCOND23:%.*]] = icmp eq i32 [[INC6_US]], [[N]] 812; CHECK-DEC-NEXT: br i1 [[EXITCOND23]], label [[WHILE_END7]], label [[WHILE_COND1_PREHEADER_US]] 813; CHECK-DEC: while.end7: 814; CHECK-DEC-NEXT: ret void 815; 816; CHECK-PHI-LABEL: @nested( 817; CHECK-PHI-NEXT: entry: 818; CHECK-PHI-NEXT: [[CMP20:%.*]] = icmp eq i32 [[N:%.*]], 0 819; CHECK-PHI-NEXT: br i1 [[CMP20]], label [[WHILE_END7:%.*]], label [[WHILE_COND1_PREHEADER_US:%.*]] 820; CHECK-PHI: while.cond1.preheader.us: 821; CHECK-PHI-NEXT: [[I_021_US:%.*]] = phi i32 [ [[INC6_US:%.*]], [[WHILE_COND1_WHILE_END_CRIT_EDGE_US:%.*]] ], [ 0, [[ENTRY:%.*]] ] 822; CHECK-PHI-NEXT: [[MUL_US:%.*]] = mul i32 [[I_021_US]], [[N]] 823; CHECK-PHI-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 824; CHECK-PHI-NEXT: br label [[WHILE_BODY3_US:%.*]] 825; CHECK-PHI: while.body3.us: 826; CHECK-PHI-NEXT: [[J_019_US:%.*]] = phi i32 [ 0, [[WHILE_COND1_PREHEADER_US]] ], [ [[INC_US:%.*]], [[WHILE_BODY3_US]] ] 827; CHECK-PHI-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_COND1_PREHEADER_US]] ], [ [[TMP2:%.*]], [[WHILE_BODY3_US]] ] 828; CHECK-PHI-NEXT: [[ADD_US:%.*]] = add i32 [[J_019_US]], [[MUL_US]] 829; CHECK-PHI-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[ADD_US]] 830; CHECK-PHI-NEXT: store i32 [[ADD_US]], i32* [[ARRAYIDX_US]], align 4 831; CHECK-PHI-NEXT: [[INC_US]] = add nuw i32 [[J_019_US]], 1 832; CHECK-PHI-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 833; CHECK-PHI-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 834; CHECK-PHI-NEXT: br i1 [[TMP3]], label [[WHILE_BODY3_US]], label [[WHILE_COND1_WHILE_END_CRIT_EDGE_US]] 835; CHECK-PHI: while.cond1.while.end_crit_edge.us: 836; CHECK-PHI-NEXT: [[INC6_US]] = add nuw i32 [[I_021_US]], 1 837; CHECK-PHI-NEXT: [[EXITCOND23:%.*]] = icmp eq i32 [[INC6_US]], [[N]] 838; CHECK-PHI-NEXT: br i1 [[EXITCOND23]], label [[WHILE_END7]], label [[WHILE_COND1_PREHEADER_US]] 839; CHECK-PHI: while.end7: 840; CHECK-PHI-NEXT: ret void 841; 842; CHECK-NESTED-LABEL: @nested( 843; CHECK-NESTED-NEXT: entry: 844; CHECK-NESTED-NEXT: [[CMP20:%.*]] = icmp eq i32 [[N:%.*]], 0 845; CHECK-NESTED-NEXT: br i1 [[CMP20]], label [[WHILE_END7:%.*]], label [[WHILE_COND1_PREHEADER_US_PREHEADER:%.*]] 846; CHECK-NESTED: while.cond1.preheader.us.preheader: 847; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 848; CHECK-NESTED-NEXT: br label [[WHILE_COND1_PREHEADER_US:%.*]] 849; CHECK-NESTED: while.cond1.preheader.us: 850; CHECK-NESTED-NEXT: [[I_021_US:%.*]] = phi i32 [ [[INC6_US:%.*]], [[WHILE_COND1_WHILE_END_CRIT_EDGE_US:%.*]] ], [ 0, [[WHILE_COND1_PREHEADER_US_PREHEADER]] ] 851; CHECK-NESTED-NEXT: [[MUL_US:%.*]] = mul i32 [[I_021_US]], [[N]] 852; CHECK-NESTED-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 853; CHECK-NESTED-NEXT: br label [[WHILE_BODY3_US:%.*]] 854; CHECK-NESTED: while.body3.us: 855; CHECK-NESTED-NEXT: [[J_019_US:%.*]] = phi i32 [ 0, [[WHILE_COND1_PREHEADER_US]] ], [ [[INC_US:%.*]], [[WHILE_BODY3_US]] ] 856; CHECK-NESTED-NEXT: [[ADD_US:%.*]] = add i32 [[J_019_US]], [[MUL_US]] 857; CHECK-NESTED-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[ADD_US]] 858; CHECK-NESTED-NEXT: store i32 [[ADD_US]], i32* [[ARRAYIDX_US]], align 4 859; CHECK-NESTED-NEXT: [[INC_US]] = add nuw i32 [[J_019_US]], 1 860; CHECK-NESTED-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 861; CHECK-NESTED-NEXT: br i1 [[TMP0]], label [[WHILE_BODY3_US]], label [[WHILE_COND1_WHILE_END_CRIT_EDGE_US]] 862; CHECK-NESTED: while.cond1.while.end_crit_edge.us: 863; CHECK-NESTED-NEXT: [[INC6_US]] = add nuw i32 [[I_021_US]], 1 864; CHECK-NESTED-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 865; CHECK-NESTED-NEXT: br i1 [[TMP1]], label [[WHILE_COND1_PREHEADER_US]], label [[WHILE_END7]] 866; CHECK-NESTED: while.end7: 867; CHECK-NESTED-NEXT: ret void 868; 869; CHECK-GUARD-LABEL: @nested( 870; CHECK-GUARD-NEXT: entry: 871; CHECK-GUARD-NEXT: [[CMP20:%.*]] = icmp eq i32 [[N:%.*]], 0 872; CHECK-GUARD-NEXT: br i1 [[CMP20]], label [[WHILE_END7:%.*]], label [[WHILE_COND1_PREHEADER_US:%.*]] 873; CHECK-GUARD: while.cond1.preheader.us: 874; CHECK-GUARD-NEXT: [[I_021_US:%.*]] = phi i32 [ [[INC6_US:%.*]], [[WHILE_COND1_WHILE_END_CRIT_EDGE_US:%.*]] ], [ 0, [[ENTRY:%.*]] ] 875; CHECK-GUARD-NEXT: [[MUL_US:%.*]] = mul i32 [[I_021_US]], [[N]] 876; CHECK-GUARD-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]]) 877; CHECK-GUARD-NEXT: br label [[WHILE_BODY3_US:%.*]] 878; CHECK-GUARD: while.body3.us: 879; CHECK-GUARD-NEXT: [[J_019_US:%.*]] = phi i32 [ 0, [[WHILE_COND1_PREHEADER_US]] ], [ [[INC_US:%.*]], [[WHILE_BODY3_US]] ] 880; CHECK-GUARD-NEXT: [[ADD_US:%.*]] = add i32 [[J_019_US]], [[MUL_US]] 881; CHECK-GUARD-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[ADD_US]] 882; CHECK-GUARD-NEXT: store i32 [[ADD_US]], i32* [[ARRAYIDX_US]], align 4 883; CHECK-GUARD-NEXT: [[INC_US]] = add nuw i32 [[J_019_US]], 1 884; CHECK-GUARD-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1) 885; CHECK-GUARD-NEXT: br i1 [[TMP0]], label [[WHILE_BODY3_US]], label [[WHILE_COND1_WHILE_END_CRIT_EDGE_US]] 886; CHECK-GUARD: while.cond1.while.end_crit_edge.us: 887; CHECK-GUARD-NEXT: [[INC6_US]] = add nuw i32 [[I_021_US]], 1 888; CHECK-GUARD-NEXT: [[EXITCOND23:%.*]] = icmp eq i32 [[INC6_US]], [[N]] 889; CHECK-GUARD-NEXT: br i1 [[EXITCOND23]], label [[WHILE_END7]], label [[WHILE_COND1_PREHEADER_US]] 890; CHECK-GUARD: while.end7: 891; CHECK-GUARD-NEXT: ret void 892; 893; CHECK-PHIGUARD-LABEL: @nested( 894; CHECK-PHIGUARD-NEXT: entry: 895; CHECK-PHIGUARD-NEXT: [[CMP20:%.*]] = icmp eq i32 [[N:%.*]], 0 896; CHECK-PHIGUARD-NEXT: br i1 [[CMP20]], label [[WHILE_END7:%.*]], label [[WHILE_COND1_PREHEADER_US:%.*]] 897; CHECK-PHIGUARD: while.cond1.preheader.us: 898; CHECK-PHIGUARD-NEXT: [[I_021_US:%.*]] = phi i32 [ [[INC6_US:%.*]], [[WHILE_COND1_WHILE_END_CRIT_EDGE_US:%.*]] ], [ 0, [[ENTRY:%.*]] ] 899; CHECK-PHIGUARD-NEXT: [[MUL_US:%.*]] = mul i32 [[I_021_US]], [[N]] 900; CHECK-PHIGUARD-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 901; CHECK-PHIGUARD-NEXT: br label [[WHILE_BODY3_US:%.*]] 902; CHECK-PHIGUARD: while.body3.us: 903; CHECK-PHIGUARD-NEXT: [[J_019_US:%.*]] = phi i32 [ 0, [[WHILE_COND1_PREHEADER_US]] ], [ [[INC_US:%.*]], [[WHILE_BODY3_US]] ] 904; CHECK-PHIGUARD-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_COND1_PREHEADER_US]] ], [ [[TMP2:%.*]], [[WHILE_BODY3_US]] ] 905; CHECK-PHIGUARD-NEXT: [[ADD_US:%.*]] = add i32 [[J_019_US]], [[MUL_US]] 906; CHECK-PHIGUARD-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[ADD_US]] 907; CHECK-PHIGUARD-NEXT: store i32 [[ADD_US]], i32* [[ARRAYIDX_US]], align 4 908; CHECK-PHIGUARD-NEXT: [[INC_US]] = add nuw i32 [[J_019_US]], 1 909; CHECK-PHIGUARD-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 910; CHECK-PHIGUARD-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 911; CHECK-PHIGUARD-NEXT: br i1 [[TMP3]], label [[WHILE_BODY3_US]], label [[WHILE_COND1_WHILE_END_CRIT_EDGE_US]] 912; CHECK-PHIGUARD: while.cond1.while.end_crit_edge.us: 913; CHECK-PHIGUARD-NEXT: [[INC6_US]] = add nuw i32 [[I_021_US]], 1 914; CHECK-PHIGUARD-NEXT: [[EXITCOND23:%.*]] = icmp eq i32 [[INC6_US]], [[N]] 915; CHECK-PHIGUARD-NEXT: br i1 [[EXITCOND23]], label [[WHILE_END7]], label [[WHILE_COND1_PREHEADER_US]] 916; CHECK-PHIGUARD: while.end7: 917; CHECK-PHIGUARD-NEXT: ret void 918; 919; CHECK-REGDEC-LABEL: @nested( 920; CHECK-REGDEC-NEXT: entry: 921; CHECK-REGDEC-NEXT: [[CMP20:%.*]] = icmp eq i32 [[N:%.*]], 0 922; CHECK-REGDEC-NEXT: br i1 [[CMP20]], label [[WHILE_END7:%.*]], label [[WHILE_COND1_PREHEADER_US:%.*]] 923; CHECK-REGDEC: while.cond1.preheader.us: 924; CHECK-REGDEC-NEXT: [[I_021_US:%.*]] = phi i32 [ [[INC6_US:%.*]], [[WHILE_COND1_WHILE_END_CRIT_EDGE_US:%.*]] ], [ 0, [[ENTRY:%.*]] ] 925; CHECK-REGDEC-NEXT: [[MUL_US:%.*]] = mul i32 [[I_021_US]], [[N]] 926; CHECK-REGDEC-NEXT: [[TMP0:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[N]]) 927; CHECK-REGDEC-NEXT: br label [[WHILE_BODY3_US:%.*]] 928; CHECK-REGDEC: while.body3.us: 929; CHECK-REGDEC-NEXT: [[J_019_US:%.*]] = phi i32 [ 0, [[WHILE_COND1_PREHEADER_US]] ], [ [[INC_US:%.*]], [[WHILE_BODY3_US]] ] 930; CHECK-REGDEC-NEXT: [[TMP1:%.*]] = phi i32 [ [[TMP0]], [[WHILE_COND1_PREHEADER_US]] ], [ [[TMP2:%.*]], [[WHILE_BODY3_US]] ] 931; CHECK-REGDEC-NEXT: [[ADD_US:%.*]] = add i32 [[J_019_US]], [[MUL_US]] 932; CHECK-REGDEC-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i32 [[ADD_US]] 933; CHECK-REGDEC-NEXT: store i32 [[ADD_US]], i32* [[ARRAYIDX_US]], align 4 934; CHECK-REGDEC-NEXT: [[INC_US]] = add nuw i32 [[J_019_US]], 1 935; CHECK-REGDEC-NEXT: [[TMP2]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP1]], i32 1) 936; CHECK-REGDEC-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 937; CHECK-REGDEC-NEXT: br i1 [[TMP3]], label [[WHILE_BODY3_US]], label [[WHILE_COND1_WHILE_END_CRIT_EDGE_US]] 938; CHECK-REGDEC: while.cond1.while.end_crit_edge.us: 939; CHECK-REGDEC-NEXT: [[INC6_US]] = add nuw i32 [[I_021_US]], 1 940; CHECK-REGDEC-NEXT: [[EXITCOND23:%.*]] = icmp eq i32 [[INC6_US]], [[N]] 941; CHECK-REGDEC-NEXT: br i1 [[EXITCOND23]], label [[WHILE_END7]], label [[WHILE_COND1_PREHEADER_US]] 942; CHECK-REGDEC: while.end7: 943; CHECK-REGDEC-NEXT: ret void 944entry: 945 %cmp20 = icmp eq i32 %N, 0 946 br i1 %cmp20, label %while.end7, label %while.cond1.preheader.us 947 948while.cond1.preheader.us: 949 %i.021.us = phi i32 [ %inc6.us, %while.cond1.while.end_crit_edge.us ], [ 0, %entry ] 950 %mul.us = mul i32 %i.021.us, %N 951 br label %while.body3.us 952 953while.body3.us: 954 %j.019.us = phi i32 [ 0, %while.cond1.preheader.us ], [ %inc.us, %while.body3.us ] 955 %add.us = add i32 %j.019.us, %mul.us 956 %arrayidx.us = getelementptr inbounds i32, i32* %A, i32 %add.us 957 store i32 %add.us, i32* %arrayidx.us, align 4 958 %inc.us = add nuw i32 %j.019.us, 1 959 %exitcond = icmp eq i32 %inc.us, %N 960 br i1 %exitcond, label %while.cond1.while.end_crit_edge.us, label %while.body3.us 961 962while.cond1.while.end_crit_edge.us: 963 %inc6.us = add nuw i32 %i.021.us, 1 964 %exitcond23 = icmp eq i32 %inc6.us, %N 965 br i1 %exitcond23, label %while.end7, label %while.cond1.preheader.us 966 967while.end7: 968 ret void 969} 970