[PATCH] D71164: [InstCombine] Fix infinite loop due to bitcast <-> phi transforms

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 7 03:30:54 PST 2019


nikic created this revision.
nikic added reviewers: spatel, lebedev.ri, xbolva00.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Fix for https://bugs.llvm.org/show_bug.cgi?id=44245.

The optimizeBitCastFromPhi() and FoldPHIArgOpIntoPHI() end up fighting against each other, because optimizeBitCastFromPhi() assumes that bitcasts of loads will get folded. This doesn't happen here, because a dangling phi node prevents the one-use fold in https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp#L620-L628 from triggering.

This patch fixes the issue by adding the old phis to the IC worklist, so they actually get removed (instead of this happening on the next InstCombine iteration). I'm not very familiar with the overall InstCombine design, so not sure if this is a proper fix or just a workaround.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71164

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/test/Transforms/InstCombine/pr44245.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71164.232694.patch
Type: text/x-patch
Size: 6693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191207/e4c990a2/attachment.bin>


More information about the llvm-commits mailing list