[PATCH] D111675: [instcombine] propagate freeze through single use poison producing flag instruction

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 13:25:54 PDT 2021


reames created this revision.
reames added reviewers: aqjune, hyeongyukim, regehr, nlopes, fhahn, nikic.
Herald added subscribers: bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

If we have an instruction which produces poison only when flags are specified on the instruction, then we know that freezing the operands and dropping flags is equivalent to freezing the result.  If we know those flags don't result in any undefined behavior being executed, then there's no point in preserving the flags as we gain no knowledge by having them.

This patch extends the existing propagation logic which sinks freeze to single potential non-poison operands to allow dropping of flags when we know the freeze is the sole use of the instruction with poison flags.

The main value is that we tend to sink freezes towards the phi in IV cycles where the incoming value to the phi is the freeze of an IV increment.  This will in turn (in a future patch), let us fold the freeze through the phi into the loop preheader.  Motivated by eliminating need for CanonicalizeFreezeInLoops for the clearly profitable cases from onephi.ll test case in the test directory.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111675

Files:
  llvm/include/llvm/Analysis/ValueTracking.h
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/freeze.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111675.379164.patch
Type: text/x-patch
Size: 9348 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211012/8f1cb52e/attachment.bin>


More information about the llvm-commits mailing list