[SelectionDAG] Add expansion and promotion of [US]MUL_LOHI
authorNicolai Haehnle <nhaehnle@gmail.com>
Thu, 8 Dec 2016 14:08:14 +0000 (14:08 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Thu, 8 Dec 2016 14:08:14 +0000 (14:08 +0000)
commitf08dc90253f45a60c1a8304d9515006231940bef
treedb72c5b99b8f625b90979013d4abb5a1490eb928
parent3c67a08d1bbf4f03d735302e1ae533d1bda65e06
[SelectionDAG] Add expansion and promotion of [US]MUL_LOHI

Summary:
Most targets set the action for these nodes to Expand even though there
isn't actually any code for them in ExpandNode. Instead, targets simply
relied on the fact that no code generates these nodes as long as the
nodes aren't legal or custom.

However, generating these nodes can be useful e.g. for divide-by-constant
in wider integer types.

Expand of [US]MUL_LOHI will use MULH[US] when legal or custom, and
a sequence of half-width multiplications otherwise. Promote uses a wider
multiply.

This patch intends to not change the generated code, but indirect effects
are possible since expansions/promotions that were previously done in
DAGCombine may now be done in LegalizeDAG.

See D24822 for a change that actually uses the new expansion.

Reviewers: spatel, bkramer, venkatra, efriedma, hfinkel, ast, nadav, tstellarAMD

Subscribers: arsenm, jyknight, nemanjai, wdng, nhaehnle, llvm-commits

Differential Revision: https://reviews.llvm.org/D24956

llvm-svn: 289050
llvm/include/llvm/Target/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp