[PATCH] D101375: [InstCombine] Add a few more patterns for folding select of select

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 27 09:17:51 PDT 2021


aqjune created this revision.
aqjune added reviewers: nikic, spatel, lebedev.ri.
Herald added a subscriber: hiraditya.
aqjune requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a patch that folds select of select to salvage some optimizations after select -> and/or folding is disabled.

  select (select a, true, b), c, false -> select a, c, false
  select c, (select a, true, b), false -> select c, a, false
    if c implies that b is false (isImpliedCondition).

https://alive2.llvm.org/ce/z/ANatjt, https://alive2.llvm.org/ce/z/rv8zTB

  sel (sel c, a, false), true, (sel !c, b, false) -> sel c, a, b
  sel (sel !c, a, false), true, (sel c, b, false) -> sel c, b, a

https://alive2.llvm.org/ce/z/U2kp-t, https://alive2.llvm.org/ce/z/bc88EE

See D101191 <https://reviews.llvm.org/D101191>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101375

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/select-safe-transforms.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101375.340872.patch
Type: text/x-patch
Size: 4558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210427/36952bda/attachment.bin>


More information about the llvm-commits mailing list