[PATCH] D157030: InstCombine: Fold out scale-if-denormal pattern

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 13:34:57 PDT 2023


arsenm created this revision.
arsenm added reviewers: jcranmer-intel, foad, kpn, andrew.w.kaylor, cameron.mcinally, sepavloff, nlopes.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

Fold select (fcmp oeq x, 0), (fmul x, y), x => x

      

This cleans up a pattern left behind by denormal range checks under
denormals are zero.

      

The pattern starts out as something like:
x = x < smallest_normal ? x * K : x;

      

The comparison folds to an == 0 when the denormal mode treats input
denormals as zero. This makes library denormal checks free after
linked into DAZ enabled code.

      

alive2 is mostly happy with this, but there are some issues. First,
there are many reported failures in some of the negative tests that
happen to trigger some preexisting canonicalize introducing
combine. Second, alive2 is incorrectly asserting that denormals must
be flushed with the DAZ modes. It's allowed to drop a canonicalize.


https://reviews.llvm.org/D157030

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/fold-select-fmul-if-zero.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157030.546988.patch
Type: text/x-patch
Size: 22188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230803/3dbe23e0/attachment.bin>


More information about the llvm-commits mailing list