diff --git a/llvm/lib/CodeGen/HardwareLoops.cpp b/llvm/lib/CodeGen/HardwareLoops.cpp --- a/llvm/lib/CodeGen/HardwareLoops.cpp +++ b/llvm/lib/CodeGen/HardwareLoops.cpp @@ -383,12 +383,12 @@ // loop counter and tests that is not zero? SCEVExpander SCEVE(SE, DL, "loopcnt"); + + ExitCount = SE.getAddExpr(ExitCount, SE.getOne(ExitCount->getType())); if (!ExitCount->getType()->isPointerTy() && ExitCount->getType() != CountType) ExitCount = SE.getZeroExtendExpr(ExitCount, CountType); - ExitCount = SE.getAddExpr(ExitCount, SE.getOne(CountType)); - // If we're trying to use the 'test and set' form of the intrinsic, we need // to replace a conditional branch that is controlling entry to the loop. It // is likely (guaranteed?) that the preheader has an unconditional branch to diff --git a/llvm/test/CodeGen/PowerPC/shrink-wrap.ll b/llvm/test/CodeGen/PowerPC/shrink-wrap.ll --- a/llvm/test/CodeGen/PowerPC/shrink-wrap.ll +++ b/llvm/test/CodeGen/PowerPC/shrink-wrap.ll @@ -32,9 +32,7 @@ ; CHECK: std ; CHECK: blt 0, .LBB0_3 ; CHECK: # %bb.1: -; CHECK-NEXT: addi ; CHECK-NEXT: clrldi -; CHECK-NEXT: addi ; CHECK-NEXT: mtctr ; CHECK-NEXT: li ; CHECK: .LBB0_2: