[PATCH] D82676: [CGP] Prevent optimizePhiType from iterating forever

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 26 12:36:01 PDT 2020


dmgreen created this revision.
dmgreen added reviewers: efriedma, craig.topper, SjoerdMeijer, tbosch, tpopp.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

The recently added optimizePhiType algorithm had no checks to make sure it didn't continually iterate backward and forth between float and int types. This means that given an input like store(phi(bitcast(load))), we could convert that back and forth to store(bitcast(phi(load))). This particular case would usually have been simplified to a different load type (folding the bitcast into the load) before CGP, but other cases can occur. The one that came up was phi(bitcast(phi)), where the two phi's of different types were bitcast between. That was not helped by a dead bitcast being kept around which could make conversion look profitable.

This adds an extra check of the bitcast Uses or Defs, to make sure that at least one is "grounded" and will not end up being converted back. It also makes sure that dead bitcasts are removed, and there is a minor change to include newly created Phi nodes in the Visited set so that they do not need to be revisited.


https://reviews.llvm.org/D82676

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/CodeGen/AArch64/convertphitype.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82676.273799.patch
Type: text/x-patch
Size: 10118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200626/70259805/attachment-0001.bin>


More information about the llvm-commits mailing list