[PATCH] D106058: [DAG] Fold select(cond,binop(x,y),binop(x,z)) -> binop(x,select(cond,y,z))

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 05:05:26 PDT 2021


RKSimon created this revision.
RKSimon added reviewers: spatel, lebedev.ri, jholewinski, jlebar, craig.topper.
Herald added subscribers: ecnelises, pengfei, hiraditya.
RKSimon requested review of this revision.
Herald added a project: LLVM.

Similar to the folds performed in InstCombinerImpl::foldSelectOpOp, this attempts to push a select further up to help merge a pair of binops.

I'm primarily interested in select(cond,add(x,y),add(x,z)) folds to help expose pointer math (see https://bugs.llvm.org/show_bug.cgi?id=51069 etc.) but I've tried to use the more generic isBinOp() - this affects some NVPTX tests, which I think benefit (and would have been combined the same way in InstCombine) but if its affecting what is supposed to be tested then I'm happy to change the tests, restrict this to ISD::ADD or move it inside X86, if people think this is too generic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106058

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/NVPTX/fast-math.ll
  llvm/test/CodeGen/X86/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106058.358924.patch
Type: text/x-patch
Size: 5054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210715/2ff3b1d7/attachment.bin>


More information about the llvm-commits mailing list