[PATCH] D84629: [LazyValueInfo] Let getEdgeValueLocal look into freeze instructions

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 09:47:26 PDT 2020


aqjune added a comment.

getEdgeValueLocal's change at `if (BranchInst *BI ...) { .. }` corresponds to the `simple` example.
For the `switch` example, `if (SwitchInst *SI ...) { ... }` branch calls `constantFoldUser`, which is newly updated.



================
Comment at: llvm/lib/Analysis/LazyValueInfo.cpp:1316
+          (isa<FreezeInst>(Val) &&
+           Condition == cast<FreezeInst>(Val)->getOperand(0)))
         return ValueLatticeElement::get(ConstantInt::get(
----------------
nikic wrote:
> efriedma wrote:
> > nikic wrote:
> > > Wouldn't we expect such a freeze to get dropped by InstSimplify/InstCombine anyway?
> > You mean, we should rewrite uses of a freeze in blocks where we know the operand of the freeze can't be undef/poison?  I guess that's something we should do.  I don't think instsimplify has the context necessary to do that sort of rewrite.
> You're right, if there are multiple uses and only some are dominated by the condition we currently don't handle it in InstCombine. The `@simple` case from the test would be handled though, because the freeze gets sunk.
Would it be the right direction if I implement this optimization in InstCombine instead?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84629/new/

https://reviews.llvm.org/D84629



More information about the llvm-commits mailing list