Current powerpc backend generates wrong code sequence if stack pointer has to realign if -fstack-clash-protection enabled. When probing dynamic stack allocation, current PREPARE_PROBED_ALLOCA takes NegSizeReg as input and returns FinalStackPtr. FinalStackPtr=StackPtr+ActualNegSize is calculated correctly, however code following PREPARE_PROBED_ALLOCA still uses value of NegSizeReg, which does not contain ActualNegSize if MaxAlign > TargetAlign, to calculate loop trip count and residual number of bytes.
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=46759
KillNegSizeReg only used once, I think we can inline it here. Also add some comments or move By introducing PREPARE_PROBED_ALLOCA_NEGSIZE_OPT... up here.