1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00
llvm-mirror/lib/Target/AArch64
Daniel Sanders 233ed83478 [globalisel] Add G_SEXT_INREG
Summary:
Targets often have instructions that can sign-extend certain cases faster
than the equivalent shift-left/arithmetic-shift-right. Such cases can be
identified by matching a shift-left/shift-right pair but there are some
issues with this in the context of combines. For example, suppose you can
sign-extend 8-bit up to 32-bit with a target extend instruction.
  %1:_(s32) = G_SHL %0:_(s32), i32 24 # (I've inlined the G_CONSTANT for brevity)
  %2:_(s32) = G_ASHR %1:_(s32), i32 24
  %3:_(s32) = G_ASHR %2:_(s32), i32 1
would reasonably combine to:
  %1:_(s32) = G_SHL %0:_(s32), i32 24
  %2:_(s32) = G_ASHR %1:_(s32), i32 25
which no longer matches the special case. If your shifts and extend are
equal cost, this would break even as a pair of shifts but if your shift is
more expensive than the extend then it's cheaper as:
  %2:_(s32) = G_SEXT_INREG %0:_(s32), i32 8
  %3:_(s32) = G_ASHR %2:_(s32), i32 1
It's possible to match the shift-pair in ISel and emit an extend and ashr.
However, this is far from the only way to break this shift pair and make
it hard to match the extends. Another example is that with the right
known-zeros, this:
  %1:_(s32) = G_SHL %0:_(s32), i32 24
  %2:_(s32) = G_ASHR %1:_(s32), i32 24
  %3:_(s32) = G_MUL %2:_(s32), i32 2
can become:
  %1:_(s32) = G_SHL %0:_(s32), i32 24
  %2:_(s32) = G_ASHR %1:_(s32), i32 23

All upstream targets have been configured to lower it to the current
G_SHL,G_ASHR pair but will likely want to make it legal in some cases to
handle their faster cases.

To follow-up: Provide a way to legalize based on the constant. At the
moment, I'm thinking that the best way to achieve this is to provide the
MI in LegalityQuery but that opens the door to breaking core principles
of the legalizer (legality is not context sensitive). That said, it's
worth noting that looking at other instructions and acting on that
information doesn't violate this principle in itself. It's only a
violation if, at the end of legalization, a pass that checks legality
without being able to see the context would say an instruction might not be
legal. That's a fairly subtle distinction so to give a concrete example,
saying %2 in:
  %1 = G_CONSTANT 16
  %2 = G_SEXT_INREG %0, %1
is legal is in violation of that principle if the legality of %2 depends
on %1 being constant and/or being 16. However, legalizing to either:
  %2 = G_SEXT_INREG %0, 16
or:
  %1 = G_CONSTANT 16
  %2:_(s32) = G_SHL %0, %1
  %3:_(s32) = G_ASHR %2, %1
depending on whether %1 is constant and 16 does not violate that principle
since both outputs are genuinely legal.

Reviewers: bogner, aditya_nandakumar, volkan, aemerson, paquette, arsenm

Subscribers: sdardis, jvesely, wdng, nhaehnle, rovka, kristof.beyls, javed.absar, hiraditya, jrtc27, atanasyan, Petar.Avramovic, llvm-commits

Tags: #llvm

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

llvm-svn: 368487
2019-08-09 21:11:20 +00:00
..
AsmParser [AArch64][SVE2] Rename bitperm feature to sve2-bitperm 2019-07-26 15:57:50 +00:00
Disassembler Revert CMake: Make most target symbols hidden by default 2019-06-11 03:21:13 +00:00
MCTargetDesc MC: AArch64: Add support for prel_g* relocation specifiers. 2019-07-18 16:54:33 +00:00
TargetInfo Revert CMake: Make most target symbols hidden by default 2019-06-11 03:21:13 +00:00
Utils AArch64: Add a tagged-globals backend feature. 2019-07-31 20:14:19 +00:00
AArch64.h Basic MTE stack tagging instrumentation. 2019-07-17 19:24:12 +00:00
AArch64.td AArch64: Add a tagged-globals backend feature. 2019-07-31 20:14:19 +00:00
AArch64A53Fix835769.cpp
AArch64A57FPLoadBalancing.cpp
AArch64AdvSIMDScalarPass.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
AArch64AsmPrinter.cpp [AArch64] Do not emit '#' before immediates in inline asm 2019-08-08 17:50:39 +00:00
AArch64BranchTargets.cpp
AArch64CallingConvention.cpp
AArch64CallingConvention.h
AArch64CallingConvention.td [AArch64] Implement initial SVE calling convention support 2019-08-05 13:44:10 +00:00
AArch64CallLowering.cpp GlobalISel: pack various parameters for lowerCall into a struct. 2019-08-09 08:26:38 +00:00
AArch64CallLowering.h GlobalISel: pack various parameters for lowerCall into a struct. 2019-08-09 08:26:38 +00:00
AArch64CleanupLocalDynamicTLSPass.cpp
AArch64CollectLOH.cpp
AArch64CompressJumpTables.cpp [AArch64] Fix scan-build null/uninitialized pointer warnings. NFCI. 2019-05-08 16:27:24 +00:00
AArch64CondBrTuning.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
AArch64ConditionalCompares.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
AArch64ConditionOptimizer.cpp
AArch64DeadRegisterDefinitionsPass.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
AArch64ExpandImm.cpp [AArch64] Prefer "mov" over "orr" to materialize constants. 2019-03-25 21:25:28 +00:00
AArch64ExpandImm.h [AArch64] Refactor floating point materialization. NFC 2019-03-18 18:23:23 +00:00
AArch64ExpandPseudoInsts.cpp [AArch64] NFC: Add generic StackOffset to describe scalable offsets. 2019-08-06 13:06:40 +00:00
AArch64FalkorHWPFFix.cpp CodeGen: Introduce a class for registers 2019-06-24 15:50:29 +00:00
AArch64FastISel.cpp SelectionDAG, MI, AArch64: Widen target flags fields/arguments from unsigned char to unsigned. 2019-07-31 20:14:09 +00:00
AArch64FrameLowering.cpp [AArch64] NFC: Add generic StackOffset to describe scalable offsets. 2019-08-06 13:06:40 +00:00
AArch64FrameLowering.h [AArch64] NFC: Add generic StackOffset to describe scalable offsets. 2019-08-06 13:06:40 +00:00
AArch64GenRegisterBankInfo.def [AArch64][GlobalISel] Overhaul legalization & isel or shifts to select immediate forms. 2019-07-03 01:49:06 +00:00
AArch64InstrAtomics.td
AArch64InstrFormats.td [AArch64][GlobalISel] Support the neg_addsub_shifted_imm32 pattern 2019-08-02 18:12:53 +00:00
AArch64InstrInfo.cpp [AArch64][WinCFI] Do not pair callee-save instructions in LoadStoreOptimizer 2019-08-07 12:41:38 +00:00
AArch64InstrInfo.h [AArch64] NFC: Add generic StackOffset to describe scalable offsets. 2019-08-06 13:06:40 +00:00
AArch64InstrInfo.td [AArch64] Add support for Transactional Memory Extension (TME) 2019-07-31 12:52:17 +00:00
AArch64InstructionSelector.cpp AArch64: support TLS on Darwin platforms in GlobalISel. 2019-08-09 09:32:38 +00:00
AArch64ISelDAGToDAG.cpp Basic codegen for MTE stack tagging. 2019-07-17 19:24:02 +00:00
AArch64ISelLowering.cpp [AArch64] Expand bcmp() for small block lengths 2019-08-05 18:09:14 +00:00
AArch64ISelLowering.h [Codegen] (X & (C l>>/<< Y)) ==/!= 0 --> ((X <</l>> Y) & C) ==/!= 0 fold 2019-07-24 22:57:22 +00:00
AArch64LegalizerInfo.cpp [globalisel] Add G_SEXT_INREG 2019-08-09 21:11:20 +00:00
AArch64LegalizerInfo.h [GlobalISel] Translate calls to memcpy et al to G_INTRINSIC_W_SIDE_EFFECTs and legalize later. 2019-07-19 00:24:45 +00:00
AArch64LoadStoreOptimizer.cpp [AArch64] Remove scan-build "Value stored during its initialization is never read" warnings. NFCI. 2019-05-08 16:29:39 +00:00
AArch64MachineFunctionInfo.h Basic codegen for MTE stack tagging. 2019-07-17 19:24:02 +00:00
AArch64MacroFusion.cpp
AArch64MacroFusion.h
AArch64MCInstLower.cpp AArch64: Add a tagged-globals backend feature. 2019-07-31 20:14:19 +00:00
AArch64MCInstLower.h
AArch64PBQPRegAlloc.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
AArch64PBQPRegAlloc.h
AArch64PerfectShuffle.h
AArch64PfmCounters.td
AArch64PreLegalizerCombiner.cpp [GISel]: Add GISelKnownBits analysis 2019-08-06 17:18:29 +00:00
AArch64PromoteConstant.cpp
AArch64RedundantCopyElimination.cpp CodeGen: Introduce a class for registers 2019-06-24 15:50:29 +00:00
AArch64RegisterBankInfo.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
AArch64RegisterBankInfo.h [AArch64][GlobalISel] Overhaul legalization & isel or shifts to select immediate forms. 2019-07-03 01:49:06 +00:00
AArch64RegisterBanks.td
AArch64RegisterInfo.cpp [AArch64] NFC: Add generic StackOffset to describe scalable offsets. 2019-08-06 13:06:40 +00:00
AArch64RegisterInfo.h CodeGen: Introduce a class for registers 2019-06-24 15:50:29 +00:00
AArch64RegisterInfo.td
AArch64SchedA53.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedA57.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedA57WriteRes.td
AArch64SchedCyclone.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedExynosM1.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedExynosM3.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedExynosM4.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedFalkor.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedFalkorDetails.td
AArch64SchedKryo.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedKryoDetails.td
AArch64SchedPredExynos.td [AArch64] Update for Exynos 2019-05-02 22:01:39 +00:00
AArch64SchedPredicates.td [AArch64] Update for Exynos 2019-05-02 22:01:39 +00:00
AArch64SchedThunderX2T99.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64SchedThunderX.td [AArch64][SVE2] Add SVE2 target features to backend and TargetParser 2019-05-13 10:10:24 +00:00
AArch64Schedule.td
AArch64SelectionDAGInfo.cpp Basic codegen for MTE stack tagging. 2019-07-17 19:24:02 +00:00
AArch64SelectionDAGInfo.h Basic codegen for MTE stack tagging. 2019-07-17 19:24:02 +00:00
AArch64SIMDInstrOpt.cpp
AArch64SpeculationHardening.cpp
AArch64StackOffset.h [AArch64] NFC: Add generic StackOffset to describe scalable offsets. 2019-08-06 13:06:40 +00:00
AArch64StackTagging.cpp Speculative fix for stack-tagging.ll failure. 2019-07-17 21:27:44 +00:00
AArch64StorePairSuppress.cpp [CodeGen] Add "const" to MachineInstr::mayAlias 2019-04-19 09:08:38 +00:00
AArch64Subtarget.cpp [AArch64] Set pref. func. align to 8 bytes on Neoverse E1 & Cortex-A65 2019-08-09 11:05:15 +00:00
AArch64Subtarget.h AArch64: Add a tagged-globals backend feature. 2019-07-31 20:14:19 +00:00
AArch64SVEInstrInfo.td [AArch64][SVE2] Load/store instruction fixes 2019-07-31 09:10:36 +00:00
AArch64SystemOperands.td [AArch64] Define ETE and TRBE system registers 2019-07-26 09:19:08 +00:00
AArch64TargetMachine.cpp Basic MTE stack tagging instrumentation. 2019-07-17 19:24:12 +00:00
AArch64TargetMachine.h
AArch64TargetObjectFile.cpp
AArch64TargetObjectFile.h
AArch64TargetTransformInfo.cpp [AArch64] Expand bcmp() for small block lengths 2019-08-05 18:09:14 +00:00
AArch64TargetTransformInfo.h [AArch64] Expand bcmp() for small block lengths 2019-08-05 18:09:14 +00:00
CMakeLists.txt Basic MTE stack tagging instrumentation. 2019-07-17 19:24:12 +00:00
LLVMBuild.txt [AArch64] Add dependency from AArch64CodeGen to TransformUtils to fix -DBUILD_SHARED_LIBS=on link error after D64173/r366361 2019-07-18 01:53:08 +00:00
SVEInstrFormats.td [AArch64][SVE2] Load/store instruction fixes 2019-07-31 09:10:36 +00:00