2019-10-03 05:13:07 +08:00
|
|
|
//=- AArch64.td - Define AArch64 Combine Rules ---------------*- tablegen -*-=//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
include "llvm/Target/GlobalISel/Combine.td"
|
|
|
|
|
2020-01-16 08:20:29 +08:00
|
|
|
def fconstant_to_constant : GICombineRule<
|
|
|
|
(defs root:$root),
|
|
|
|
(match (wip_match_opcode G_FCONSTANT):$root,
|
|
|
|
[{ return matchFConstantToConstant(*${root}, MRI); }]),
|
|
|
|
(apply [{ applyFConstantToConstant(*${root}); }])>;
|
|
|
|
|
2019-10-03 05:13:07 +08:00
|
|
|
def AArch64PreLegalizerCombinerHelper: GICombinerHelper<
|
2019-10-17 07:53:35 +08:00
|
|
|
"AArch64GenPreLegalizerCombinerHelper", [all_combines,
|
2020-01-16 08:20:29 +08:00
|
|
|
fconstant_to_constant]> {
|
2019-10-17 08:37:04 +08:00
|
|
|
let DisableRuleOption = "aarch64prelegalizercombiner-disable-rule";
|
[gicombiner] Allow generated combiners to store additional members
Summary:
Adds the ability to add members to a generated combiner via
a State base class. In the current AArch64PreLegalizerCombiner
this is used to make Helper available without having to
provide it to every call.
As part of this, split the command line processing into a
separate object so that it still only runs once even though
the generated combiner is constructed more frequently.
Depends on D81862
Reviewers: aditya_nandakumar, bogner, volkan, aemerson, paquette, arsenm
Reviewed By: arsenm
Subscribers: jvesely, wdng, nhaehnle, kristof.beyls, hiraditya, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D81863
2020-06-17 05:15:36 +08:00
|
|
|
let StateClass = "AArch64PreLegalizerCombinerHelperState";
|
|
|
|
let AdditionalArguments = [];
|
2019-10-17 08:37:04 +08:00
|
|
|
}
|
2020-05-22 09:05:37 +08:00
|
|
|
|
2020-06-03 02:13:56 +08:00
|
|
|
// Matchdata for combines which replace a G_SHUFFLE_VECTOR with a
|
|
|
|
// target-specific opcode.
|
|
|
|
def shuffle_matchdata : GIDefMatchData<"ShuffleVectorPseudo">;
|
|
|
|
|
|
|
|
def rev : GICombineRule<
|
|
|
|
(defs root:$root, shuffle_matchdata:$matchinfo),
|
|
|
|
(match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
|
|
|
|
[{ return matchREV(*${root}, MRI, ${matchinfo}); }]),
|
|
|
|
(apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
|
|
|
|
>;
|
|
|
|
|
2020-06-02 08:23:20 +08:00
|
|
|
def zip : GICombineRule<
|
2020-06-03 02:13:56 +08:00
|
|
|
(defs root:$root, shuffle_matchdata:$matchinfo),
|
2020-06-02 08:23:20 +08:00
|
|
|
(match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
|
|
|
|
[{ return matchZip(*${root}, MRI, ${matchinfo}); }]),
|
2020-06-03 00:30:04 +08:00
|
|
|
(apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
|
2020-06-02 08:23:20 +08:00
|
|
|
>;
|
|
|
|
|
2020-06-03 00:30:04 +08:00
|
|
|
def uzp : GICombineRule<
|
2020-06-03 02:13:56 +08:00
|
|
|
(defs root:$root, shuffle_matchdata:$matchinfo),
|
2020-06-03 00:30:04 +08:00
|
|
|
(match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
|
|
|
|
[{ return matchUZP(*${root}, MRI, ${matchinfo}); }]),
|
|
|
|
(apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
|
|
|
|
>;
|
|
|
|
|
[AArch64][GlobalISel] Move dup optimization into post-legalizer combiner
Since all of the other G_SHUFFLE_VECTOR transforms are going there, let's do
this with dup as well. This is nice, because it lets us split up the original
code into matching, register bank selection, and instruction selection.
- Create G_DUP, make it equivalent to AArch64dup
- Add a post-legalizer combine which is 90% a copy-and-paste from
tryOptVectorDup, except with shuffle matching closer to what SelectionDAG
does in `ShuffleVectorSDNode::isSplatMask`.
- Teach RegBankSelect about G_DUP. Since dup selection relies on the correct
register bank for FP/GPR dup selection, this is necessary.
- Kill `tryOptVectorDup`, since it's now entirely handled by G_DUP.
- Add testcases for the combine, RegBankSelect, and selection. The selection
test gives the same selection results as the old test.
Differential Revision: https://reviews.llvm.org/D81221
2020-06-05 08:08:36 +08:00
|
|
|
def dup: GICombineRule <
|
|
|
|
(defs root:$root, shuffle_matchdata:$matchinfo),
|
|
|
|
(match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
|
|
|
|
[{ return matchDup(*${root}, MRI, ${matchinfo}); }]),
|
|
|
|
(apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
|
|
|
|
>;
|
|
|
|
|
2020-06-05 02:07:47 +08:00
|
|
|
def trn : GICombineRule<
|
|
|
|
(defs root:$root, shuffle_matchdata:$matchinfo),
|
|
|
|
(match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
|
|
|
|
[{ return matchTRN(*${root}, MRI, ${matchinfo}); }]),
|
|
|
|
(apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
|
|
|
|
>;
|
|
|
|
|
2020-06-09 05:02:15 +08:00
|
|
|
def ext: GICombineRule <
|
|
|
|
(defs root:$root, shuffle_matchdata:$matchinfo),
|
|
|
|
(match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
|
|
|
|
[{ return matchEXT(*${root}, MRI, ${matchinfo}); }]),
|
|
|
|
(apply [{ applyEXT(*${root}, ${matchinfo}); }])
|
|
|
|
>;
|
|
|
|
|
2020-06-03 00:30:04 +08:00
|
|
|
// Combines which replace a G_SHUFFLE_VECTOR with a target-specific pseudo
|
|
|
|
// instruction.
|
2020-06-09 05:02:15 +08:00
|
|
|
def shuffle_vector_pseudos : GICombineGroup<[dup, rev, ext, zip, uzp, trn]>;
|
2020-06-03 00:30:04 +08:00
|
|
|
|
2020-09-22 06:03:29 +08:00
|
|
|
def vashr_vlshr_imm_matchdata : GIDefMatchData<"int64_t">;
|
|
|
|
def vashr_vlshr_imm : GICombineRule<
|
|
|
|
(defs root:$root, vashr_vlshr_imm_matchdata:$matchinfo),
|
|
|
|
(match (wip_match_opcode G_ASHR, G_LSHR):$root,
|
|
|
|
[{ return matchVAshrLshrImm(*${root}, MRI, ${matchinfo}); }]),
|
|
|
|
(apply [{ applyVAshrLshrImm(*${root}, MRI, ${matchinfo}); }])
|
|
|
|
>;
|
|
|
|
|
2020-10-21 04:17:39 +08:00
|
|
|
def adjust_icmp_imm_matchdata :
|
|
|
|
GIDefMatchData<"std::pair<uint64_t, CmpInst::Predicate>">;
|
|
|
|
def adjust_icmp_imm : GICombineRule <
|
|
|
|
(defs root:$root, adjust_icmp_imm_matchdata:$matchinfo),
|
|
|
|
(match (wip_match_opcode G_ICMP):$root,
|
|
|
|
[{ return matchAdjustICmpImmAndPred(*${root}, MRI, ${matchinfo}); }]),
|
|
|
|
(apply [{ applyAdjustICmpImmAndPred(*${root}, ${matchinfo}, B, Observer); }])
|
|
|
|
>;
|
|
|
|
|
|
|
|
def icmp_lowering : GICombineGroup<[adjust_icmp_imm]>;
|
|
|
|
|
2020-10-20 01:17:15 +08:00
|
|
|
// Post-legalization combines which should happen at all optimization levels.
|
|
|
|
// (E.g. ones that facilitate matching for the selector) For example, matching
|
|
|
|
// pseudos.
|
|
|
|
def AArch64PostLegalizerLoweringHelper
|
|
|
|
: GICombinerHelper<"AArch64GenPostLegalizerLoweringHelper",
|
2020-10-21 04:17:39 +08:00
|
|
|
[shuffle_vector_pseudos, vashr_vlshr_imm,
|
|
|
|
icmp_lowering]> {
|
2020-10-20 01:17:15 +08:00
|
|
|
let DisableRuleOption = "aarch64postlegalizerlowering-disable-rule";
|
|
|
|
}
|
2020-09-22 06:03:29 +08:00
|
|
|
|
2020-10-20 01:17:15 +08:00
|
|
|
// Post-legalization combines which are primarily optimizations.
|
2020-05-23 05:21:50 +08:00
|
|
|
def AArch64PostLegalizerCombinerHelper
|
|
|
|
: GICombinerHelper<"AArch64GenPostLegalizerCombinerHelper",
|
2020-08-14 16:37:49 +08:00
|
|
|
[copy_prop, erase_undef_store, combines_for_extload,
|
2020-10-20 01:17:15 +08:00
|
|
|
sext_trunc_sextload,
|
2020-08-07 01:40:46 +08:00
|
|
|
hoist_logic_op_with_same_opcode_hands,
|
2020-10-20 01:17:15 +08:00
|
|
|
and_trivial_mask, xor_of_and_with_same_reg]> {
|
2020-05-22 09:05:37 +08:00
|
|
|
let DisableRuleOption = "aarch64postlegalizercombiner-disable-rule";
|
|
|
|
}
|