[PATCH] D13862: Adding support for TargetLoweringBase::LibCall

A. Skrobov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 19 05:49:54 PDT 2015


tyomitch created this revision.
tyomitch added a reviewer: rengolin.
tyomitch added a subscriber: llvm-commits.
Herald added a subscriber: aemerson.

TargetLoweringBase::Expand is defined as "Try to expand this to other ops,
otherwise use a libcall." For ISD::UDIV and ISD::SDIV, the choice between
the two possibilities was defined in a rather convoluted way:

- if DIVREM is legal, expand to DIVREM
- if DIVREM has a custom lowering, expand to DIVREM
- if DIVREM libcall is defined and a remainder from the same division is
  computed elsewhere, expand to a DIVREM libcall
- else, expand to a DIV libcall

This had the undesirable effect that if both DIV and DIVREM are implemented
as libcalls, then ISD::UDIV and ISD::SDIV are expanded to the heavier DIVREM
libcall, even when the remainder isn't used.

The new code adds a new LegalizeAction, TargetLoweringBase::LibCall, so that
backends can directly control whether they prefer an expansion or a conversion
to a libcall. This makes the generic lowering code even more generic,
allowing its reuse in a wider range of target-specific configurations.

The useful effect is that ARM backend will now generate a call
to __aeabi_{i,u}div rather than __aeabi_{i,u}divmod in cases where
it doesn't need the remainder. There's no functional change outside
the ARM backend.

http://reviews.llvm.org/D13862

Files:
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/Target/ARM/ARMISelLowering.cpp
  test/CodeGen/ARM/divmod-eabi.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13862.37743.patch
Type: text/x-patch
Size: 29050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151019/88f8b222/attachment.bin>


More information about the llvm-commits mailing list