[all-commits] [llvm/llvm-project] 9237fd: [CGP] Prevent optimizePhiType from iterating forever

David Green via All-commits all-commits at lists.llvm.org
Sun Sep 13 08:11:25 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9237fde48139400764377eb73e7e5d3bc5b7fffc
      https://github.com/llvm/llvm-project/commit/9237fde48139400764377eb73e7e5d3bc5b7fffc
  Author: David Green <david.green at arm.com>
  Date:   2020-09-13 (Sun, 13 Sep 2020)

  Changed paths:
    M llvm/lib/CodeGen/CodeGenPrepare.cpp
    M llvm/test/CodeGen/AArch64/convertphitype.ll

  Log Message:
  -----------
  [CGP] Prevent optimizePhiType from iterating forever

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.

Differential Revision: https://reviews.llvm.org/D82676




More information about the All-commits mailing list