[PATCH] D84601: [InstCombine] Fold freeze into phi if one operand is not undef

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 27 00:35:49 PDT 2020


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM

As a possible followup: This code could be generalized a bit by using "constant && !constexpr" for non-freeze and "guaranteed-not-undef" (without any constant checks) for freeze, with some appropriate renames. This would basically change the transform from splitting into "constant" and "non-constant" inputs, into "foldable" and "non-foldable" inputs (where "foldable = constant" for most cases).



================
Comment at: llvm/test/Transforms/InstCombine/freeze-phi.ll:171
   ret i32 %y.fr
 }
----------------
aqjune wrote:
> nikic wrote:
> > Can you also add a test with an all-constant phi, in which case the freeze will get dropped completely? I believe the code also handles that case.
> Seems like InstSimplify already deals with the case: function `const` in this file has a phi with constants.
Oh right, that makes sense. In that case the whole phi is "guaranteed not undef", so we don't ever get here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84601





More information about the llvm-commits mailing list