[PATCH] D51753: [DAGCombiner] try to convert pow(x, 1/3) to cbrt(x)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 6 14:16:49 PDT 2018


spatel created this revision.
spatel added reviewers: t.p.northover, efriedma, lebedev.ri, fhahn.
Herald added a subscriber: mcrosier.

This is a follow-up suggested in https://reviews.llvm.org/D51630 and originally proposed as an IR transform in https://reviews.llvm.org/D49040.

Copying the motivational statement by @evandro from that patch:
"This transformation helps some benchmarks in SPEC CPU2000 and CPU2006, such as 188.ammp, 447.dealII, 453.povray, and especially 300.twolf, as well as some proprietary benchmarks. Otherwise, no regressions on x86-64 or A64."

I'm proposing to add only the minimum support for a DAG node here. Since we don't have an LLVM IR intrinsic for cbrt, and there are no other DAG ways to create a FCBRT node yet, I don't think we need to worry about DAG builder, legalization, a strict variant, etc. We should be able to expand as needed when adding more functionality/transforms. For reference, these are transform suggestions currently listed in SimplifyLibCalls.cpp:

  //   * cbrt(expN(X))  -> expN(x/3)
  //   * cbrt(sqrt(x))  -> pow(x,1/6)
  //   * cbrt(cbrt(x))  -> pow(x,1/9)

Also, given that we bail out on long double for now, I don't think there will be any logical differences between platforms, but let me know if you'd like to see test coverage for other targets.


https://reviews.llvm.org/D51753

Files:
  include/llvm/CodeGen/ISDOpcodes.h
  include/llvm/IR/RuntimeLibcalls.def
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  test/CodeGen/X86/pow.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51753.164283.patch
Type: text/x-patch
Size: 8488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180906/46a92fe6/attachment.bin>


More information about the llvm-commits mailing list