diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-02-10 19:45:48 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-02-10 19:45:48 +0000 |
commit | c3f6cb95f9b5ae6c43730922bd4a06dfa13aec29 (patch) | |
tree | 0d9fd43b4c321babe31b2c0a2514b680e94b6351 /llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp | |
parent | 88e9ff62ee48a01ca2a23b0f8426973ceafd50cc (diff) | |
download | bcm5719-llvm-c3f6cb95f9b5ae6c43730922bd4a06dfa13aec29.tar.gz bcm5719-llvm-c3f6cb95f9b5ae6c43730922bd4a06dfa13aec29.zip |
[AArch64] Refactor is logic into a helper function. NFC.
llvm-svn: 260419
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp')
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp index d0de6d24fc9..b46f8293d52 100644 --- a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp +++ b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp @@ -1131,6 +1131,26 @@ bool AArch64LoadStoreOpt::findMatchingStore( return false; } +// Returns true if these two opcodes can be merged or paired. Otherwise, +// returns false. +static bool canMergeOpc(unsigned OpcA, unsigned OpcB, LdStPairFlags &Flags) { + // Opcodes match: nothing more to check. + if (OpcA == OpcB) + return true; + + // Try to match a sign-extended load/store with a zero-extended load/store. + bool IsValidLdStrOpc, PairIsValidLdStrOpc; + unsigned NonSExtOpc = getMatchingNonSExtOpcode(OpcA, &IsValidLdStrOpc); + assert(IsValidLdStrOpc && + "Given Opc should be a Load or Store with an immediate"); + // OpcA will be the first instruction in the pair. + if (NonSExtOpc == getMatchingNonSExtOpcode(OpcB, &PairIsValidLdStrOpc)) { + Flags.setSExtIdx(NonSExtOpc == (unsigned)OpcA ? 1 : 0); + return true; + } + return false; +} + /// Scan the instructions looking for a load/store that can be combined with the /// current instruction into a wider equivalent or a load/store pair. MachineBasicBlock::iterator @@ -1168,19 +1188,9 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I, // Now that we know this is a real instruction, count it. ++Count; - bool CanMergeOpc = Opc == MI->getOpcode(); Flags.setSExtIdx(-1); - if (!CanMergeOpc) { - bool IsValidLdStrOpc; - unsigned NonSExtOpc = getMatchingNonSExtOpcode(Opc, &IsValidLdStrOpc); - assert(IsValidLdStrOpc && - "Given Opc should be a Load or Store with an immediate"); - // Opc will be the first instruction in the pair. - Flags.setSExtIdx(NonSExtOpc == (unsigned)Opc ? 1 : 0); - CanMergeOpc = NonSExtOpc == getMatchingNonSExtOpcode(MI->getOpcode()); - } - - if (CanMergeOpc && getLdStOffsetOp(MI).isImm()) { + if (canMergeOpc(Opc, MI->getOpcode(), Flags) && + getLdStOffsetOp(MI).isImm()) { assert(MI->mayLoadOrStore() && "Expected memory operation."); // If we've found another instruction with the same opcode, check to see // if the base and offset are compatible with our starting instruction. |