1; RUN: opt -S < %s -loop-unroll -unroll-count=4 | FileCheck %s 2; 3; Test induction variable simplify after loop unrolling. It should 4; expose nice opportunities for GVN. 5; 6; CHECK-NOT: while.body also ensures that loop unrolling (with SCEV) 7; removes unrolled loop exits given that 128 is a multiple of 4. 8 9target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" 10 11; PR10534: LoopUnroll not keeping canonical induction variable... 12; CHECK: while.body: 13; CHECK-NOT: while.body.1: 14; CHECK: %shr.1 = lshr i32 %bit_addr.addr.01, 5 15; CHECK: %arrayidx.1 = getelementptr inbounds i32, i32* %bitmap, i32 %shr.1 16; CHECK: %shr.2 = lshr i32 %bit_addr.addr.01, 5 17; CHECK: %arrayidx.2 = getelementptr inbounds i32, i32* %bitmap, i32 %shr.2 18; CHECK: %shr.3 = lshr i32 %bit_addr.addr.01, 5 19; CHECK: %arrayidx.3 = getelementptr inbounds i32, i32* %bitmap, i32 %shr.3 20define void @FlipBit(i32* nocapture %bitmap, i32 %bit_addr, i32 %nbits) nounwind { 21entry: 22 br label %while.body 23 24while.body: 25 %nbits.addr.02 = phi i32 [ 128, %entry ], [ %dec, %while.body ] 26 %bit_addr.addr.01 = phi i32 [ 0, %entry ], [ %inc, %while.body ] 27 %dec = add i32 %nbits.addr.02, -1 28 %shr = lshr i32 %bit_addr.addr.01, 5 29 %rem = and i32 %bit_addr.addr.01, 31 30 %shl = shl i32 1, %rem 31 %arrayidx = getelementptr inbounds i32, i32* %bitmap, i32 %shr 32 %tmp6 = load i32, i32* %arrayidx, align 4 33 %xor = xor i32 %tmp6, %shl 34 store i32 %xor, i32* %arrayidx, align 4 35 %inc = add i32 %bit_addr.addr.01, 1 36 %tobool = icmp eq i32 %dec, 0 37 br i1 %tobool, label %while.end, label %while.body 38 39while.end: 40 ret void 41} 42