[PATCH] D44564: [InstSimplify] Look at the whole PHI graph when simplifying a PHI node

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 16 07:06:25 PDT 2018


john.brawn created this revision.
john.brawn added reviewers: mkazantsev, wmi, reames, dberlin, efriedma.
Herald added subscribers: tpr, javed.absar.

This patch currently isn't ready to commit, but posting it as a possible alternative approach to https://reviews.llvm.org/D44160.

Currently we only look at the incoming values to a PHI node to determine if it actually only has one possible value, but actually we should be looking at the entire graph rooted at that node as this lets us handle more cases.

This is specifically being done in order to improve alias analysis within GVN, as alias analysis uses GetUnderlyingObject which uses SimplifyInstruction, and GVN introduces phi graphs that SimplifyInstruction currently can't simplify (or rather, it can only handle them by iteratively simplifying each individual PHI node).

This patch currently has several test failures

  LLVM :: CodeGen/AMDGPU/nested-loop-conditions.ll
  LLVM :: CodeGen/PowerPC/expand-contiguous-isel.ll
  LLVM :: CodeGen/X86/ragreedy-hoist-spill.ll
  LLVM :: Transforms/CodeGenPrepare/X86/sink-addrmode-base.ll
  LLVM :: Transforms/CodeGenPrepare/X86/sink-addrmode-two-phi.ll
  LLVM :: Transforms/IndVarSimplify/2011-11-17-selfphi.ll
  LLVM :: Transforms/IndVarSimplify/no-iv-rewrite.ll

Some of these are tests that use phi nodes in too simple a way that now gets optimised away (as are several tests that this patch adjusts) but the IndVarSimplify failures are much harder to resolve. What's happening is:

- LoopSimplify calls SimplifyInstruction only on PHI nodes in the loop header
- Currently this does nothing in these tests, but now we eliminate the PHI but that leaves an unsimplified PHI node in the loop body
- IndVarSimplify now does nothing because it sees no induction variable
- So we are left with the unsimplified PHI that we didn't previously have

I'm not sure how to fix this. Making LoopSimplify simplify all of the PHI nodes in the loop fixes this test failure, but causes ~20 more.


Repository:
  rL LLVM

https://reviews.llvm.org/D44564

Files:
  lib/Analysis/InstructionSimplify.cpp
  test/Analysis/BasicAA/phi-aa.ll
  test/Transforms/GVN/pre-after-rle.ll
  test/Transforms/InstSimplify/phi.ll
  test/Transforms/LoopSimplify/pr28272.ll
  test/Transforms/LoopUnroll/rebuild_lcssa.ll
  test/Transforms/LoopVectorize/AArch64/pr36032.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44564.138694.patch
Type: text/x-patch
Size: 11818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180316/afa4b6fa/attachment.bin>


More information about the llvm-commits mailing list