[PATCH] D156238: [InstCombine] Generalize foldICmpWithMinMax

Yingwei Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 25 06:51:29 PDT 2023


dtcxzyw created this revision.
dtcxzyw added reviewers: nikic, efriedma, spatel.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
dtcxzyw requested review of this revision.
Herald added subscribers: llvm-commits, wangpc.
Herald added a project: LLVM.

This patch generalizes the fold of `icmp pred min/max(X, Y), Z` to address the issue https://github.com/llvm/llvm-project/issues/62898.

For example, we can fold `smin(X, Y) < Z` into `X < Z` when `Y > Z` is implied by constant folds/invariants/dom conditions.

Alive2 (with `--disable-undef-input` due to the limitation of --smt-to=10000): https://alive2.llvm.org/ce/z/rB7qLc
You can run the standalone translation validation tool `alive-tv` locally to verify these transformations.

  alive-tv transforms.ll --smt-to=600000 --exit-on-error


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156238

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/test/Transforms/InstCombine/smax-icmp.ll
  llvm/test/Transforms/InstCombine/smin-icmp.ll
  llvm/test/Transforms/InstCombine/umax-icmp.ll
  llvm/test/Transforms/InstCombine/umin-icmp.ll
  llvm/test/Transforms/LoopVectorize/X86/pr23997.ll
  llvm/test/Transforms/LoopVectorize/interleaved-accesses.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156238.543923.patch
Type: text/x-patch
Size: 40595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230725/2f5f89b9/attachment.bin>


More information about the llvm-commits mailing list