[LSR] Optimize unused IVs to final values in the exit block
authorZaara Syeda <syzaara@ca.ibm.com>
Thu, 7 Apr 2022 16:27:05 +0000 (12:27 -0400)
committerZaara Syeda <syzaara@ca.ibm.com>
Fri, 8 Apr 2022 15:16:37 +0000 (11:16 -0400)
commit07005440ae148d1eb102493a1148e2818fab21e0
tree98cf5585a8ab0fdc9b53be9c242c7c2012d82f76
parent476047bf8e720f3dc359cf75d1241e13f8ba2350
[LSR] Optimize unused IVs to final values in the exit block

Loop Strength Reduce sometimes optimizes away all uses of an induction variable
from a loop but leaves the IV increments. When the only remaining use of the IV
is the PHI in the exit block, this patch will call rewriteLoopExitValues to
replace the exit block PHI with the final value of the IV to skip the updates
in each loop iteration.

Differential Revision: https://reviews.llvm.org/D118808
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/Transforms/LoopStrengthReduce/remove_scev_indvars.ll [new file with mode: 0644]