[PATCH] D56041: [PowerPC] Fix a bug when optimizing conditional branch in PPCPreEmitPeephole pass

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 21 17:25:59 PST 2018


wmi created this revision.
wmi added reviewers: inouehrs, hfinkel.
Herald added subscribers: jsji, kbarton, nemanjai.

PPCPreEmitPeephole will convert a BC to B when the conditional branch is based on a constant CR by CRSET or CRUNSET. This is added in https://reviews.llvm.org/rL343100.

When the conditional branch is known to be always taken, all branches will be removed and a new unconditional branch will be inserted. However, when SeenUse is false the original patch will not remove the branches, but still insert the new unconditional branch and update the successors, and create inconsistent IR. Compiling the synthetic testcase included can show the problem we run into.

It seems to me removing the patches should not depend on the value of SeenUse so I guess it is an oversight. The patch simply removes the SeenUse condition when adding branches into InstrsToErase set.


Repository:
  rL LLVM

https://reviews.llvm.org/D56041

Files:
  lib/Target/PowerPC/PPCPreEmitPeephole.cpp
  test/CodeGen/PowerPC/setcr_bc3.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56041.179394.patch
Type: text/x-patch
Size: 4116 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181222/a8a6d039/attachment.bin>


More information about the llvm-commits mailing list