1 //===-- Thumb2SizeReduction.cpp - Thumb2 code size reduction pass -*- C++ -*-=//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "ARMBaseInstrInfo.h"
11 #include "ARMSubtarget.h"
12 #include "MCTargetDesc/ARMBaseInfo.h"
13 #include "Thumb2InstrInfo.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/PostOrderIterator.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/SmallSet.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/Statistic.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/CodeGen/MachineBasicBlock.h"
22 #include "llvm/CodeGen/MachineFunction.h"
23 #include "llvm/CodeGen/MachineFunctionPass.h"
24 #include "llvm/CodeGen/MachineInstr.h"
25 #include "llvm/CodeGen/MachineInstrBuilder.h"
26 #include "llvm/CodeGen/MachineOperand.h"
27 #include "llvm/CodeGen/TargetInstrInfo.h"
28 #include "llvm/IR/DebugLoc.h"
29 #include "llvm/IR/Function.h"
30 #include "llvm/MC/MCAsmInfo.h"
31 #include "llvm/MC/MCInstrDesc.h"
32 #include "llvm/Support/CommandLine.h"
33 #include "llvm/Support/Compiler.h"
34 #include "llvm/Support/Debug.h"
35 #include "llvm/Support/ErrorHandling.h"
36 #include "llvm/Support/raw_ostream.h"
45 #define DEBUG_TYPE "thumb2-reduce-size"
46 #define THUMB2_SIZE_REDUCE_NAME "Thumb2 instruction size reduce pass"
48 STATISTIC(NumNarrows
, "Number of 32-bit instrs reduced to 16-bit ones");
49 STATISTIC(Num2Addrs
, "Number of 32-bit instrs reduced to 2addr 16-bit ones");
50 STATISTIC(NumLdSts
, "Number of 32-bit load / store reduced to 16-bit ones");
52 static cl::opt
<int> ReduceLimit("t2-reduce-limit",
53 cl::init(-1), cl::Hidden
);
54 static cl::opt
<int> ReduceLimit2Addr("t2-reduce-limit2",
55 cl::init(-1), cl::Hidden
);
56 static cl::opt
<int> ReduceLimitLdSt("t2-reduce-limit3",
57 cl::init(-1), cl::Hidden
);
61 /// ReduceTable - A static table with information on mapping from wide
64 uint16_t WideOpc
; // Wide opcode
65 uint16_t NarrowOpc1
; // Narrow opcode to transform to
66 uint16_t NarrowOpc2
; // Narrow opcode when it's two-address
67 uint8_t Imm1Limit
; // Limit of immediate field (bits)
68 uint8_t Imm2Limit
; // Limit of immediate field when it's two-address
69 unsigned LowRegs1
: 1; // Only possible if low-registers are used
70 unsigned LowRegs2
: 1; // Only possible if low-registers are used (2addr)
71 unsigned PredCC1
: 2; // 0 - If predicated, cc is on and vice versa.
73 // 2 - Always set CPSR.
75 unsigned PartFlag
: 1; // 16-bit instruction does partial flag update
76 unsigned Special
: 1; // Needs to be dealt with specially
77 unsigned AvoidMovs
: 1; // Avoid movs with shifter operand (for Swift)
80 static const ReduceEntry ReduceTable
[] = {
81 // Wide, Narrow1, Narrow2, imm1,imm2, lo1, lo2, P/C,PF,S,AM
82 { ARM::t2ADCrr
, 0, ARM::tADC
, 0, 0, 0, 1, 0,0, 0,0,0 },
83 { ARM::t2ADDri
, ARM::tADDi3
, ARM::tADDi8
, 3, 8, 1, 1, 0,0, 0,1,0 },
84 { ARM::t2ADDrr
, ARM::tADDrr
, ARM::tADDhirr
, 0, 0, 1, 0, 0,1, 0,0,0 },
85 { ARM::t2ADDSri
,ARM::tADDi3
, ARM::tADDi8
, 3, 8, 1, 1, 2,2, 0,1,0 },
86 { ARM::t2ADDSrr
,ARM::tADDrr
, 0, 0, 0, 1, 0, 2,0, 0,1,0 },
87 { ARM::t2ANDrr
, 0, ARM::tAND
, 0, 0, 0, 1, 0,0, 1,0,0 },
88 { ARM::t2ASRri
, ARM::tASRri
, 0, 5, 0, 1, 0, 0,0, 1,0,1 },
89 { ARM::t2ASRrr
, 0, ARM::tASRrr
, 0, 0, 0, 1, 0,0, 1,0,1 },
90 { ARM::t2BICrr
, 0, ARM::tBIC
, 0, 0, 0, 1, 0,0, 1,0,0 },
91 //FIXME: Disable CMN, as CCodes are backwards from compare expectations
92 //{ ARM::t2CMNrr, ARM::tCMN, 0, 0, 0, 1, 0, 2,0, 0,0,0 },
93 { ARM::t2CMNzrr
, ARM::tCMNz
, 0, 0, 0, 1, 0, 2,0, 0,0,0 },
94 { ARM::t2CMPri
, ARM::tCMPi8
, 0, 8, 0, 1, 0, 2,0, 0,0,0 },
95 { ARM::t2CMPrr
, ARM::tCMPhir
, 0, 0, 0, 0, 0, 2,0, 0,1,0 },
96 { ARM::t2EORrr
, 0, ARM::tEOR
, 0, 0, 0, 1, 0,0, 1,0,0 },
97 // FIXME: adr.n immediate offset must be multiple of 4.
98 //{ ARM::t2LEApcrelJT,ARM::tLEApcrelJT, 0, 0, 0, 1, 0, 1,0, 0,0,0 },
99 { ARM::t2LSLri
, ARM::tLSLri
, 0, 5, 0, 1, 0, 0,0, 1,0,1 },
100 { ARM::t2LSLrr
, 0, ARM::tLSLrr
, 0, 0, 0, 1, 0,0, 1,0,1 },
101 { ARM::t2LSRri
, ARM::tLSRri
, 0, 5, 0, 1, 0, 0,0, 1,0,1 },
102 { ARM::t2LSRrr
, 0, ARM::tLSRrr
, 0, 0, 0, 1, 0,0, 1,0,1 },
103 { ARM::t2MOVi
, ARM::tMOVi8
, 0, 8, 0, 1, 0, 0,0, 1,0,0 },
104 { ARM::t2MOVi16
,ARM::tMOVi8
, 0, 8, 0, 1, 0, 0,0, 1,1,0 },
105 // FIXME: Do we need the 16-bit 'S' variant?
106 { ARM::t2MOVr
,ARM::tMOVr
, 0, 0, 0, 0, 0, 1,0, 0,0,0 },
107 { ARM::t2MUL
, 0, ARM::tMUL
, 0, 0, 0, 1, 0,0, 1,0,0 },
108 { ARM::t2MVNr
, ARM::tMVN
, 0, 0, 0, 1, 0, 0,0, 0,0,0 },
109 { ARM::t2ORRrr
, 0, ARM::tORR
, 0, 0, 0, 1, 0,0, 1,0,0 },
110 { ARM::t2REV
, ARM::tREV
, 0, 0, 0, 1, 0, 1,0, 0,0,0 },
111 { ARM::t2REV16
, ARM::tREV16
, 0, 0, 0, 1, 0, 1,0, 0,0,0 },
112 { ARM::t2REVSH
, ARM::tREVSH
, 0, 0, 0, 1, 0, 1,0, 0,0,0 },
113 { ARM::t2RORrr
, 0, ARM::tROR
, 0, 0, 0, 1, 0,0, 1,0,0 },
114 { ARM::t2RSBri
, ARM::tRSB
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
115 { ARM::t2RSBSri
,ARM::tRSB
, 0, 0, 0, 1, 0, 2,0, 0,1,0 },
116 { ARM::t2SBCrr
, 0, ARM::tSBC
, 0, 0, 0, 1, 0,0, 0,0,0 },
117 { ARM::t2SUBri
, ARM::tSUBi3
, ARM::tSUBi8
, 3, 8, 1, 1, 0,0, 0,0,0 },
118 { ARM::t2SUBrr
, ARM::tSUBrr
, 0, 0, 0, 1, 0, 0,0, 0,0,0 },
119 { ARM::t2SUBSri
,ARM::tSUBi3
, ARM::tSUBi8
, 3, 8, 1, 1, 2,2, 0,0,0 },
120 { ARM::t2SUBSrr
,ARM::tSUBrr
, 0, 0, 0, 1, 0, 2,0, 0,0,0 },
121 { ARM::t2SXTB
, ARM::tSXTB
, 0, 0, 0, 1, 0, 1,0, 0,1,0 },
122 { ARM::t2SXTH
, ARM::tSXTH
, 0, 0, 0, 1, 0, 1,0, 0,1,0 },
123 { ARM::t2TEQrr
, ARM::tEOR
, 0, 0, 0, 1, 0, 2,0, 0,1,0 },
124 { ARM::t2TSTrr
, ARM::tTST
, 0, 0, 0, 1, 0, 2,0, 0,0,0 },
125 { ARM::t2UXTB
, ARM::tUXTB
, 0, 0, 0, 1, 0, 1,0, 0,1,0 },
126 { ARM::t2UXTH
, ARM::tUXTH
, 0, 0, 0, 1, 0, 1,0, 0,1,0 },
128 // FIXME: Clean this up after splitting each Thumb load / store opcode
129 // into multiple ones.
130 { ARM::t2LDRi12
,ARM::tLDRi
, ARM::tLDRspi
, 5, 8, 1, 0, 0,0, 0,1,0 },
131 { ARM::t2LDRs
, ARM::tLDRr
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
132 { ARM::t2LDRBi12
,ARM::tLDRBi
, 0, 5, 0, 1, 0, 0,0, 0,1,0 },
133 { ARM::t2LDRBs
, ARM::tLDRBr
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
134 { ARM::t2LDRHi12
,ARM::tLDRHi
, 0, 5, 0, 1, 0, 0,0, 0,1,0 },
135 { ARM::t2LDRHs
, ARM::tLDRHr
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
136 { ARM::t2LDRSBs
,ARM::tLDRSB
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
137 { ARM::t2LDRSHs
,ARM::tLDRSH
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
138 { ARM::t2LDR_POST
,ARM::tLDMIA_UPD
,0, 0, 0, 1, 0, 0,0, 0,1,0 },
139 { ARM::t2STRi12
,ARM::tSTRi
, ARM::tSTRspi
, 5, 8, 1, 0, 0,0, 0,1,0 },
140 { ARM::t2STRs
, ARM::tSTRr
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
141 { ARM::t2STRBi12
,ARM::tSTRBi
, 0, 5, 0, 1, 0, 0,0, 0,1,0 },
142 { ARM::t2STRBs
, ARM::tSTRBr
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
143 { ARM::t2STRHi12
,ARM::tSTRHi
, 0, 5, 0, 1, 0, 0,0, 0,1,0 },
144 { ARM::t2STRHs
, ARM::tSTRHr
, 0, 0, 0, 1, 0, 0,0, 0,1,0 },
145 { ARM::t2STR_POST
,ARM::tSTMIA_UPD
,0, 0, 0, 1, 0, 0,0, 0,1,0 },
147 { ARM::t2LDMIA
, ARM::tLDMIA
, 0, 0, 0, 1, 1, 1,1, 0,1,0 },
148 { ARM::t2LDMIA_RET
,0, ARM::tPOP_RET
, 0, 0, 1, 1, 1,1, 0,1,0 },
149 { ARM::t2LDMIA_UPD
,ARM::tLDMIA_UPD
,ARM::tPOP
,0, 0, 1, 1, 1,1, 0,1,0 },
150 // ARM::t2STMIA (with no basereg writeback) has no Thumb1 equivalent.
151 // tSTMIA_UPD is a change in semantics which can only be used if the base
152 // register is killed. This difference is correctly handled elsewhere.
153 { ARM::t2STMIA
, ARM::tSTMIA_UPD
, 0, 0, 0, 1, 1, 1,1, 0,1,0 },
154 { ARM::t2STMIA_UPD
,ARM::tSTMIA_UPD
, 0, 0, 0, 1, 1, 1,1, 0,1,0 },
155 { ARM::t2STMDB_UPD
, 0, ARM::tPUSH
, 0, 0, 1, 1, 1,1, 0,1,0 }
158 class Thumb2SizeReduce
: public MachineFunctionPass
{
162 const Thumb2InstrInfo
*TII
;
163 const ARMSubtarget
*STI
;
165 Thumb2SizeReduce(std::function
<bool(const Function
&)> Ftor
= nullptr);
167 bool runOnMachineFunction(MachineFunction
&MF
) override
;
169 MachineFunctionProperties
getRequiredProperties() const override
{
170 return MachineFunctionProperties().set(
171 MachineFunctionProperties::Property::NoVRegs
);
174 StringRef
getPassName() const override
{
175 return THUMB2_SIZE_REDUCE_NAME
;
179 /// ReduceOpcodeMap - Maps wide opcode to index of entry in ReduceTable.
180 DenseMap
<unsigned, unsigned> ReduceOpcodeMap
;
182 bool canAddPseudoFlagDep(MachineInstr
*Use
, bool IsSelfLoop
);
184 bool VerifyPredAndCC(MachineInstr
*MI
, const ReduceEntry
&Entry
,
185 bool is2Addr
, ARMCC::CondCodes Pred
,
186 bool LiveCPSR
, bool &HasCC
, bool &CCDead
);
188 bool ReduceLoadStore(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
189 const ReduceEntry
&Entry
);
191 bool ReduceSpecial(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
192 const ReduceEntry
&Entry
, bool LiveCPSR
, bool IsSelfLoop
);
194 /// ReduceTo2Addr - Reduce a 32-bit instruction to a 16-bit two-address
196 bool ReduceTo2Addr(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
197 const ReduceEntry
&Entry
, bool LiveCPSR
,
200 /// ReduceToNarrow - Reduce a 32-bit instruction to a 16-bit
201 /// non-two-address instruction.
202 bool ReduceToNarrow(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
203 const ReduceEntry
&Entry
, bool LiveCPSR
,
206 /// ReduceMI - Attempt to reduce MI, return true on success.
207 bool ReduceMI(MachineBasicBlock
&MBB
, MachineInstr
*MI
, bool LiveCPSR
,
208 bool IsSelfLoop
, bool SkipPrologueEpilogue
);
210 /// ReduceMBB - Reduce width of instructions in the specified basic block.
211 bool ReduceMBB(MachineBasicBlock
&MBB
, bool SkipPrologueEpilogue
);
216 // Last instruction to define CPSR in the current block.
217 MachineInstr
*CPSRDef
;
218 // Was CPSR last defined by a high latency instruction?
219 // When CPSRDef is null, this refers to CPSR defs in predecessors.
220 bool HighLatencyCPSR
;
223 // The flags leaving this block have high latency.
224 bool HighLatencyCPSR
= false;
225 // Has this block been visited yet?
226 bool Visited
= false;
231 SmallVector
<MBBInfo
, 8> BlockInfo
;
233 std::function
<bool(const Function
&)> PredicateFtor
;
236 char Thumb2SizeReduce::ID
= 0;
238 } // end anonymous namespace
240 INITIALIZE_PASS(Thumb2SizeReduce
, DEBUG_TYPE
, THUMB2_SIZE_REDUCE_NAME
, false,
243 Thumb2SizeReduce::Thumb2SizeReduce(std::function
<bool(const Function
&)> Ftor
)
244 : MachineFunctionPass(ID
), PredicateFtor(std::move(Ftor
)) {
245 OptimizeSize
= MinimizeSize
= false;
246 for (unsigned i
= 0, e
= std::size(ReduceTable
); i
!= e
; ++i
) {
247 unsigned FromOpc
= ReduceTable
[i
].WideOpc
;
248 if (!ReduceOpcodeMap
.insert(std::make_pair(FromOpc
, i
)).second
)
249 llvm_unreachable("Duplicated entries?");
253 static bool HasImplicitCPSRDef(const MCInstrDesc
&MCID
) {
254 return is_contained(MCID
.implicit_defs(), ARM::CPSR
);
257 // Check for a likely high-latency flag def.
258 static bool isHighLatencyCPSR(MachineInstr
*Def
) {
259 switch(Def
->getOpcode()) {
267 /// canAddPseudoFlagDep - For A9 (and other out-of-order) implementations,
268 /// the 's' 16-bit instruction partially update CPSR. Abort the
269 /// transformation to avoid adding false dependency on last CPSR setting
270 /// instruction which hurts the ability for out-of-order execution engine
271 /// to do register renaming magic.
272 /// This function checks if there is a read-of-write dependency between the
273 /// last instruction that defines the CPSR and the current instruction. If there
274 /// is, then there is no harm done since the instruction cannot be retired
275 /// before the CPSR setting instruction anyway.
276 /// Note, we are not doing full dependency analysis here for the sake of compile
277 /// time. We're not looking for cases like:
279 /// r1 = add.w r0, ...
282 /// In this case it would have been ok to narrow the mul.w to muls since there
283 /// are indirect RAW dependency between the muls and the mul.w
285 Thumb2SizeReduce::canAddPseudoFlagDep(MachineInstr
*Use
, bool FirstInSelfLoop
) {
286 // Disable the check for -Oz (aka OptimizeForSizeHarder).
287 if (MinimizeSize
|| !STI
->avoidCPSRPartialUpdate())
291 // If this BB loops back to itself, conservatively avoid narrowing the
292 // first instruction that does partial flag update.
293 return HighLatencyCPSR
|| FirstInSelfLoop
;
295 SmallSet
<unsigned, 2> Defs
;
296 for (const MachineOperand
&MO
: CPSRDef
->operands()) {
297 if (!MO
.isReg() || MO
.isUndef() || MO
.isUse())
299 Register Reg
= MO
.getReg();
300 if (Reg
== 0 || Reg
== ARM::CPSR
)
305 for (const MachineOperand
&MO
: Use
->operands()) {
306 if (!MO
.isReg() || MO
.isUndef() || MO
.isDef())
308 Register Reg
= MO
.getReg();
313 // If the current CPSR has high latency, try to avoid the false dependency.
317 // tMOVi8 usually doesn't start long dependency chains, and there are a lot
318 // of them, so always shrink them when CPSR doesn't have high latency.
319 if (Use
->getOpcode() == ARM::t2MOVi
||
320 Use
->getOpcode() == ARM::t2MOVi16
)
323 // No read-after-write dependency. The narrowing will add false dependency.
328 Thumb2SizeReduce::VerifyPredAndCC(MachineInstr
*MI
, const ReduceEntry
&Entry
,
329 bool is2Addr
, ARMCC::CondCodes Pred
,
330 bool LiveCPSR
, bool &HasCC
, bool &CCDead
) {
331 if ((is2Addr
&& Entry
.PredCC2
== 0) ||
332 (!is2Addr
&& Entry
.PredCC1
== 0)) {
333 if (Pred
== ARMCC::AL
) {
334 // Not predicated, must set CPSR.
336 // Original instruction was not setting CPSR, but CPSR is not
337 // currently live anyway. It's ok to set it. The CPSR def is
347 // Predicated, must not set CPSR.
351 } else if ((is2Addr
&& Entry
.PredCC2
== 2) ||
352 (!is2Addr
&& Entry
.PredCC1
== 2)) {
353 /// Old opcode has an optional def of CPSR.
356 // If old opcode does not implicitly define CPSR, then it's not ok since
357 // these new opcodes' CPSR def is not meant to be thrown away. e.g. CMP.
358 if (!HasImplicitCPSRDef(MI
->getDesc()))
362 // 16-bit instruction does not set CPSR.
370 static bool VerifyLowRegs(MachineInstr
*MI
) {
371 unsigned Opc
= MI
->getOpcode();
372 bool isPCOk
= (Opc
== ARM::t2LDMIA_RET
|| Opc
== ARM::t2LDMIA_UPD
);
373 bool isLROk
= (Opc
== ARM::t2STMDB_UPD
);
374 bool isSPOk
= isPCOk
|| isLROk
;
375 for (unsigned i
= 0, e
= MI
->getNumOperands(); i
!= e
; ++i
) {
376 const MachineOperand
&MO
= MI
->getOperand(i
);
377 if (!MO
.isReg() || MO
.isImplicit())
379 Register Reg
= MO
.getReg();
380 if (Reg
== 0 || Reg
== ARM::CPSR
)
382 if (isPCOk
&& Reg
== ARM::PC
)
384 if (isLROk
&& Reg
== ARM::LR
)
386 if (Reg
== ARM::SP
) {
389 if (i
== 1 && (Opc
== ARM::t2LDRi12
|| Opc
== ARM::t2STRi12
))
390 // Special case for these ldr / str with sp as base register.
393 if (!isARMLowRegister(Reg
))
400 Thumb2SizeReduce::ReduceLoadStore(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
401 const ReduceEntry
&Entry
) {
402 if (ReduceLimitLdSt
!= -1 && ((int)NumLdSts
>= ReduceLimitLdSt
))
406 bool HasImmOffset
= false;
407 bool HasShift
= false;
408 bool HasOffReg
= true;
409 bool isLdStMul
= false;
410 unsigned Opc
= Entry
.NarrowOpc1
;
411 unsigned OpNum
= 3; // First 'rest' of operands.
412 uint8_t ImmLimit
= Entry
.Imm1Limit
;
414 switch (Entry
.WideOpc
) {
416 llvm_unreachable("Unexpected Thumb2 load / store opcode!");
419 if (MI
->getOperand(1).getReg() == ARM::SP
) {
420 Opc
= Entry
.NarrowOpc2
;
421 ImmLimit
= Entry
.Imm2Limit
;
450 case ARM::t2LDR_POST
:
451 case ARM::t2STR_POST
: {
455 if (!MI
->hasOneMemOperand() ||
456 (*MI
->memoperands_begin())->getAlign() < Align(4))
459 // We're creating a completely different type of load/store - LDM from LDR.
460 // For this reason we can't reuse the logic at the end of this function; we
461 // have to implement the MI building here.
462 bool IsStore
= Entry
.WideOpc
== ARM::t2STR_POST
;
463 Register Rt
= MI
->getOperand(IsStore
? 1 : 0).getReg();
464 Register Rn
= MI
->getOperand(IsStore
? 0 : 1).getReg();
465 unsigned Offset
= MI
->getOperand(3).getImm();
466 unsigned PredImm
= MI
->getOperand(4).getImm();
467 Register PredReg
= MI
->getOperand(5).getReg();
468 assert(isARMLowRegister(Rt
));
469 assert(isARMLowRegister(Rn
));
474 // Add the 16-bit load / store instruction.
475 DebugLoc dl
= MI
->getDebugLoc();
476 auto MIB
= BuildMI(MBB
, MI
, dl
, TII
->get(Entry
.NarrowOpc1
))
477 .addReg(Rn
, RegState::Define
)
481 .addReg(Rt
, IsStore
? 0 : RegState::Define
);
483 // Transfer memoperands.
484 MIB
.setMemRefs(MI
->memoperands());
486 // Transfer MI flags.
487 MIB
.setMIFlags(MI
->getFlags());
489 // Kill the old instruction.
490 MI
->eraseFromBundle();
495 Register BaseReg
= MI
->getOperand(0).getReg();
496 assert(isARMLowRegister(BaseReg
));
498 // For the non-writeback version (this one), the base register must be
499 // one of the registers being loaded.
501 for (const MachineOperand
&MO
: llvm::drop_begin(MI
->operands(), 3)) {
502 if (MO
.getReg() == BaseReg
) {
516 // t2STMIA is reduced to tSTMIA_UPD which has writeback. We can only do this
517 // if the base register is killed, as then it doesn't matter what its value
518 // is after the instruction.
519 if (!MI
->getOperand(0).isKill())
522 // If the base register is in the register list and isn't the lowest
523 // numbered register (i.e. it's in operand 4 onwards) then with writeback
524 // the stored value is unknown, so we can't convert to tSTMIA_UPD.
525 Register BaseReg
= MI
->getOperand(0).getReg();
526 for (const MachineOperand
&MO
: llvm::drop_begin(MI
->operands(), 4))
527 if (MO
.getReg() == BaseReg
)
532 case ARM::t2LDMIA_RET
: {
533 Register BaseReg
= MI
->getOperand(1).getReg();
534 if (BaseReg
!= ARM::SP
)
536 Opc
= Entry
.NarrowOpc2
; // tPOP_RET
541 case ARM::t2LDMIA_UPD
:
542 case ARM::t2STMIA_UPD
:
543 case ARM::t2STMDB_UPD
: {
546 Register BaseReg
= MI
->getOperand(1).getReg();
547 if (BaseReg
== ARM::SP
&&
548 (Entry
.WideOpc
== ARM::t2LDMIA_UPD
||
549 Entry
.WideOpc
== ARM::t2STMDB_UPD
)) {
550 Opc
= Entry
.NarrowOpc2
; // tPOP or tPUSH
552 } else if (!isARMLowRegister(BaseReg
) ||
553 (Entry
.WideOpc
!= ARM::t2LDMIA_UPD
&&
554 Entry
.WideOpc
!= ARM::t2STMIA_UPD
)) {
563 unsigned OffsetReg
= 0;
564 bool OffsetKill
= false;
565 bool OffsetInternal
= false;
567 OffsetReg
= MI
->getOperand(2).getReg();
568 OffsetKill
= MI
->getOperand(2).isKill();
569 OffsetInternal
= MI
->getOperand(2).isInternalRead();
571 if (MI
->getOperand(3).getImm())
572 // Thumb1 addressing mode doesn't support shift.
576 unsigned OffsetImm
= 0;
578 OffsetImm
= MI
->getOperand(2).getImm();
579 unsigned MaxOffset
= ((1 << ImmLimit
) - 1) * Scale
;
581 if ((OffsetImm
& (Scale
- 1)) || OffsetImm
> MaxOffset
)
582 // Make sure the immediate field fits.
586 // Add the 16-bit load / store instruction.
587 DebugLoc dl
= MI
->getDebugLoc();
588 MachineInstrBuilder MIB
= BuildMI(MBB
, MI
, dl
, TII
->get(Opc
));
590 // tSTMIA_UPD takes a defining register operand. We've already checked that
591 // the register is killed, so mark it as dead here.
592 if (Entry
.WideOpc
== ARM::t2STMIA
)
593 MIB
.addReg(MI
->getOperand(0).getReg(), RegState::Define
| RegState::Dead
);
596 MIB
.add(MI
->getOperand(0));
597 MIB
.add(MI
->getOperand(1));
600 MIB
.addImm(OffsetImm
/ Scale
);
602 assert((!HasShift
|| OffsetReg
) && "Invalid so_reg load / store address!");
605 MIB
.addReg(OffsetReg
, getKillRegState(OffsetKill
) |
606 getInternalReadRegState(OffsetInternal
));
609 // Transfer the rest of operands.
610 for (const MachineOperand
&MO
: llvm::drop_begin(MI
->operands(), OpNum
))
613 // Transfer memoperands.
614 MIB
.setMemRefs(MI
->memoperands());
616 // Transfer MI flags.
617 MIB
.setMIFlags(MI
->getFlags());
619 LLVM_DEBUG(dbgs() << "Converted 32-bit: " << *MI
620 << " to 16-bit: " << *MIB
);
628 Thumb2SizeReduce::ReduceSpecial(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
629 const ReduceEntry
&Entry
,
630 bool LiveCPSR
, bool IsSelfLoop
) {
631 unsigned Opc
= MI
->getOpcode();
632 if (Opc
== ARM::t2ADDri
) {
633 // If the source register is SP, try to reduce to tADDrSPi, otherwise
634 // it's a normal reduce.
635 if (MI
->getOperand(1).getReg() != ARM::SP
) {
636 if (ReduceTo2Addr(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
))
638 return ReduceToNarrow(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
);
640 // Try to reduce to tADDrSPi.
641 unsigned Imm
= MI
->getOperand(2).getImm();
642 // The immediate must be in range, the destination register must be a low
643 // reg, the predicate must be "always" and the condition flags must not
645 if (Imm
& 3 || Imm
> 1020)
647 if (!isARMLowRegister(MI
->getOperand(0).getReg()))
649 if (MI
->getOperand(3).getImm() != ARMCC::AL
)
651 const MCInstrDesc
&MCID
= MI
->getDesc();
652 if (MCID
.hasOptionalDef() &&
653 MI
->getOperand(MCID
.getNumOperands()-1).getReg() == ARM::CPSR
)
656 MachineInstrBuilder MIB
=
657 BuildMI(MBB
, MI
, MI
->getDebugLoc(),
658 TII
->get(ARM::tADDrSPi
))
659 .add(MI
->getOperand(0))
660 .add(MI
->getOperand(1))
661 .addImm(Imm
/ 4) // The tADDrSPi has an implied scale by four.
662 .add(predOps(ARMCC::AL
));
664 // Transfer MI flags.
665 MIB
.setMIFlags(MI
->getFlags());
667 LLVM_DEBUG(dbgs() << "Converted 32-bit: " << *MI
668 << " to 16-bit: " << *MIB
);
675 if (Entry
.LowRegs1
&& !VerifyLowRegs(MI
))
678 if (MI
->mayLoadOrStore())
679 return ReduceLoadStore(MBB
, MI
, Entry
);
684 case ARM::t2ADDSrr
: {
686 if (getInstrPredicate(*MI
, PredReg
) == ARMCC::AL
) {
690 if (ReduceTo2Addr(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
))
694 return ReduceToNarrow(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
);
705 if (MI
->getOperand(2).getImm() == 0)
706 return ReduceToNarrow(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
);
709 // Can convert only 'pure' immediate operands, not immediates obtained as
710 // globals' addresses.
711 if (MI
->getOperand(1).isImm())
712 return ReduceToNarrow(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
);
715 // Try to reduce to the lo-reg only version first. Why there are two
716 // versions of the instruction is a mystery.
717 // It would be nice to just have two entries in the main table that
718 // are prioritized, but the table assumes a unique entry for each
719 // source insn opcode. So for now, we hack a local entry record to use.
720 static const ReduceEntry NarrowEntry
=
721 { ARM::t2CMPrr
,ARM::tCMPr
, 0, 0, 0, 1, 1,2, 0, 0,1,0 };
722 if (ReduceToNarrow(MBB
, MI
, NarrowEntry
, LiveCPSR
, IsSelfLoop
))
724 return ReduceToNarrow(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
);
728 // Can only convert to eors if we're not in an IT block.
729 if (getInstrPredicate(*MI
, PredReg
) != ARMCC::AL
)
731 // TODO if Operand 0 is not killed but Operand 1 is, then we could write
733 if (MI
->getOperand(0).isKill())
734 return ReduceToNarrow(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
);
741 Thumb2SizeReduce::ReduceTo2Addr(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
742 const ReduceEntry
&Entry
,
743 bool LiveCPSR
, bool IsSelfLoop
) {
744 if (ReduceLimit2Addr
!= -1 && ((int)Num2Addrs
>= ReduceLimit2Addr
))
747 if (!OptimizeSize
&& Entry
.AvoidMovs
&& STI
->avoidMOVsShifterOperand())
748 // Don't issue movs with shifter operand for some CPUs unless we
749 // are optimizing for size.
752 Register Reg0
= MI
->getOperand(0).getReg();
753 Register Reg1
= MI
->getOperand(1).getReg();
754 // t2MUL is "special". The tied source operand is second, not first.
755 if (MI
->getOpcode() == ARM::t2MUL
) {
756 // MULS can be slower than MUL
757 if (!MinimizeSize
&& STI
->avoidMULS())
759 Register Reg2
= MI
->getOperand(2).getReg();
760 // Early exit if the regs aren't all low regs.
761 if (!isARMLowRegister(Reg0
) || !isARMLowRegister(Reg1
)
762 || !isARMLowRegister(Reg2
))
765 // If the other operand also isn't the same as the destination, we
769 // Try to commute the operands to make it a 2-address instruction.
770 MachineInstr
*CommutedMI
= TII
->commuteInstruction(*MI
);
774 } else if (Reg0
!= Reg1
) {
775 // Try to commute the operands to make it a 2-address instruction.
776 unsigned CommOpIdx1
= 1;
777 unsigned CommOpIdx2
= TargetInstrInfo::CommuteAnyOperandIndex
;
778 if (!TII
->findCommutedOpIndices(*MI
, CommOpIdx1
, CommOpIdx2
) ||
779 MI
->getOperand(CommOpIdx2
).getReg() != Reg0
)
781 MachineInstr
*CommutedMI
=
782 TII
->commuteInstruction(*MI
, false, CommOpIdx1
, CommOpIdx2
);
786 if (Entry
.LowRegs2
&& !isARMLowRegister(Reg0
))
788 if (Entry
.Imm2Limit
) {
789 unsigned Imm
= MI
->getOperand(2).getImm();
790 unsigned Limit
= (1 << Entry
.Imm2Limit
) - 1;
794 Register Reg2
= MI
->getOperand(2).getReg();
795 if (Entry
.LowRegs2
&& !isARMLowRegister(Reg2
))
799 // Check if it's possible / necessary to transfer the predicate.
800 const MCInstrDesc
&NewMCID
= TII
->get(Entry
.NarrowOpc2
);
802 ARMCC::CondCodes Pred
= getInstrPredicate(*MI
, PredReg
);
803 bool SkipPred
= false;
804 if (Pred
!= ARMCC::AL
) {
805 if (!NewMCID
.isPredicable())
806 // Can't transfer predicate, fail.
809 SkipPred
= !NewMCID
.isPredicable();
814 const MCInstrDesc
&MCID
= MI
->getDesc();
815 if (MCID
.hasOptionalDef()) {
816 unsigned NumOps
= MCID
.getNumOperands();
817 HasCC
= (MI
->getOperand(NumOps
-1).getReg() == ARM::CPSR
);
818 if (HasCC
&& MI
->getOperand(NumOps
-1).isDead())
821 if (!VerifyPredAndCC(MI
, Entry
, true, Pred
, LiveCPSR
, HasCC
, CCDead
))
824 // Avoid adding a false dependency on partial flag update by some 16-bit
825 // instructions which has the 's' bit set.
826 if (Entry
.PartFlag
&& NewMCID
.hasOptionalDef() && HasCC
&&
827 canAddPseudoFlagDep(MI
, IsSelfLoop
))
830 // Add the 16-bit instruction.
831 DebugLoc dl
= MI
->getDebugLoc();
832 MachineInstrBuilder MIB
= BuildMI(MBB
, MI
, dl
, NewMCID
);
833 MIB
.add(MI
->getOperand(0));
834 if (NewMCID
.hasOptionalDef())
835 MIB
.add(HasCC
? t1CondCodeOp(CCDead
) : condCodeOp());
837 // Transfer the rest of operands.
838 unsigned NumOps
= MCID
.getNumOperands();
839 for (unsigned i
= 1, e
= MI
->getNumOperands(); i
!= e
; ++i
) {
840 if (i
< NumOps
&& MCID
.operands()[i
].isOptionalDef())
842 if (SkipPred
&& MCID
.operands()[i
].isPredicate())
844 MIB
.add(MI
->getOperand(i
));
847 // Transfer MI flags.
848 MIB
.setMIFlags(MI
->getFlags());
850 LLVM_DEBUG(dbgs() << "Converted 32-bit: " << *MI
851 << " to 16-bit: " << *MIB
);
859 Thumb2SizeReduce::ReduceToNarrow(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
860 const ReduceEntry
&Entry
,
861 bool LiveCPSR
, bool IsSelfLoop
) {
862 if (ReduceLimit
!= -1 && ((int)NumNarrows
>= ReduceLimit
))
865 if (!OptimizeSize
&& Entry
.AvoidMovs
&& STI
->avoidMOVsShifterOperand())
866 // Don't issue movs with shifter operand for some CPUs unless we
867 // are optimizing for size.
870 unsigned Limit
= ~0U;
872 Limit
= (1 << Entry
.Imm1Limit
) - 1;
874 const MCInstrDesc
&MCID
= MI
->getDesc();
875 for (unsigned i
= 0, e
= MCID
.getNumOperands(); i
!= e
; ++i
) {
876 if (MCID
.operands()[i
].isPredicate())
878 const MachineOperand
&MO
= MI
->getOperand(i
);
880 Register Reg
= MO
.getReg();
881 if (!Reg
|| Reg
== ARM::CPSR
)
883 if (Entry
.LowRegs1
&& !isARMLowRegister(Reg
))
885 } else if (MO
.isImm() && !MCID
.operands()[i
].isPredicate()) {
886 if (((unsigned)MO
.getImm()) > Limit
)
891 // Check if it's possible / necessary to transfer the predicate.
892 const MCInstrDesc
&NewMCID
= TII
->get(Entry
.NarrowOpc1
);
894 ARMCC::CondCodes Pred
= getInstrPredicate(*MI
, PredReg
);
895 bool SkipPred
= false;
896 if (Pred
!= ARMCC::AL
) {
897 if (!NewMCID
.isPredicable())
898 // Can't transfer predicate, fail.
901 SkipPred
= !NewMCID
.isPredicable();
906 if (MCID
.hasOptionalDef()) {
907 unsigned NumOps
= MCID
.getNumOperands();
908 HasCC
= (MI
->getOperand(NumOps
-1).getReg() == ARM::CPSR
);
909 if (HasCC
&& MI
->getOperand(NumOps
-1).isDead())
912 if (!VerifyPredAndCC(MI
, Entry
, false, Pred
, LiveCPSR
, HasCC
, CCDead
))
915 // Avoid adding a false dependency on partial flag update by some 16-bit
916 // instructions which has the 's' bit set.
917 if (Entry
.PartFlag
&& NewMCID
.hasOptionalDef() && HasCC
&&
918 canAddPseudoFlagDep(MI
, IsSelfLoop
))
921 // Add the 16-bit instruction.
922 DebugLoc dl
= MI
->getDebugLoc();
923 MachineInstrBuilder MIB
= BuildMI(MBB
, MI
, dl
, NewMCID
);
925 // TEQ is special in that it doesn't define a register but we're converting
926 // it into an EOR which does. So add the first operand as a def and then
928 if (MCID
.getOpcode() == ARM::t2TEQrr
) {
929 MIB
.add(MI
->getOperand(0));
930 MIB
->getOperand(0).setIsKill(false);
931 MIB
->getOperand(0).setIsDef(true);
932 MIB
->getOperand(0).setIsDead(true);
934 if (NewMCID
.hasOptionalDef())
935 MIB
.add(HasCC
? t1CondCodeOp(CCDead
) : condCodeOp());
936 MIB
.add(MI
->getOperand(0));
938 MIB
.add(MI
->getOperand(0));
939 if (NewMCID
.hasOptionalDef())
940 MIB
.add(HasCC
? t1CondCodeOp(CCDead
) : condCodeOp());
943 // Transfer the rest of operands.
944 unsigned NumOps
= MCID
.getNumOperands();
945 for (unsigned i
= 1, e
= MI
->getNumOperands(); i
!= e
; ++i
) {
946 if (i
< NumOps
&& MCID
.operands()[i
].isOptionalDef())
948 if ((MCID
.getOpcode() == ARM::t2RSBSri
||
949 MCID
.getOpcode() == ARM::t2RSBri
||
950 MCID
.getOpcode() == ARM::t2SXTB
||
951 MCID
.getOpcode() == ARM::t2SXTH
||
952 MCID
.getOpcode() == ARM::t2UXTB
||
953 MCID
.getOpcode() == ARM::t2UXTH
) && i
== 2)
954 // Skip the zero immediate operand, it's now implicit.
956 bool isPred
= (i
< NumOps
&& MCID
.operands()[i
].isPredicate());
957 if (SkipPred
&& isPred
)
959 const MachineOperand
&MO
= MI
->getOperand(i
);
960 if (MO
.isReg() && MO
.isImplicit() && MO
.getReg() == ARM::CPSR
)
961 // Skip implicit def of CPSR. Either it's modeled as an optional
962 // def now or it's already an implicit def on the new instruction.
966 if (!MCID
.isPredicable() && NewMCID
.isPredicable())
967 MIB
.add(predOps(ARMCC::AL
));
969 // Transfer MI flags.
970 MIB
.setMIFlags(MI
->getFlags());
972 LLVM_DEBUG(dbgs() << "Converted 32-bit: " << *MI
973 << " to 16-bit: " << *MIB
);
980 static bool UpdateCPSRDef(MachineInstr
&MI
, bool LiveCPSR
, bool &DefCPSR
) {
982 for (const MachineOperand
&MO
: MI
.operands()) {
983 if (!MO
.isReg() || MO
.isUndef() || MO
.isUse())
985 if (MO
.getReg() != ARM::CPSR
)
993 return HasDef
|| LiveCPSR
;
996 static bool UpdateCPSRUse(MachineInstr
&MI
, bool LiveCPSR
) {
997 for (const MachineOperand
&MO
: MI
.operands()) {
998 if (!MO
.isReg() || MO
.isUndef() || MO
.isDef())
1000 if (MO
.getReg() != ARM::CPSR
)
1002 assert(LiveCPSR
&& "CPSR liveness tracking is wrong!");
1012 bool Thumb2SizeReduce::ReduceMI(MachineBasicBlock
&MBB
, MachineInstr
*MI
,
1013 bool LiveCPSR
, bool IsSelfLoop
,
1014 bool SkipPrologueEpilogue
) {
1015 unsigned Opcode
= MI
->getOpcode();
1016 DenseMap
<unsigned, unsigned>::iterator OPI
= ReduceOpcodeMap
.find(Opcode
);
1017 if (OPI
== ReduceOpcodeMap
.end())
1019 if (SkipPrologueEpilogue
&& (MI
->getFlag(MachineInstr::FrameSetup
) ||
1020 MI
->getFlag(MachineInstr::FrameDestroy
)))
1022 const ReduceEntry
&Entry
= ReduceTable
[OPI
->second
];
1024 // Don't attempt normal reductions on "special" cases for now.
1026 return ReduceSpecial(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
);
1028 // Try to transform to a 16-bit two-address instruction.
1029 if (Entry
.NarrowOpc2
&&
1030 ReduceTo2Addr(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
))
1033 // Try to transform to a 16-bit non-two-address instruction.
1034 if (Entry
.NarrowOpc1
&&
1035 ReduceToNarrow(MBB
, MI
, Entry
, LiveCPSR
, IsSelfLoop
))
1041 bool Thumb2SizeReduce::ReduceMBB(MachineBasicBlock
&MBB
,
1042 bool SkipPrologueEpilogue
) {
1043 bool Modified
= false;
1045 // Yes, CPSR could be livein.
1046 bool LiveCPSR
= MBB
.isLiveIn(ARM::CPSR
);
1047 MachineInstr
*BundleMI
= nullptr;
1050 HighLatencyCPSR
= false;
1052 // Check predecessors for the latest CPSRDef.
1053 for (auto *Pred
: MBB
.predecessors()) {
1054 const MBBInfo
&PInfo
= BlockInfo
[Pred
->getNumber()];
1055 if (!PInfo
.Visited
) {
1056 // Since blocks are visited in RPO, this must be a back-edge.
1059 if (PInfo
.HighLatencyCPSR
) {
1060 HighLatencyCPSR
= true;
1065 // If this BB loops back to itself, conservatively avoid narrowing the
1066 // first instruction that does partial flag update.
1067 bool IsSelfLoop
= MBB
.isSuccessor(&MBB
);
1068 MachineBasicBlock::instr_iterator MII
= MBB
.instr_begin(),E
= MBB
.instr_end();
1069 MachineBasicBlock::instr_iterator NextMII
;
1070 for (; MII
!= E
; MII
= NextMII
) {
1071 NextMII
= std::next(MII
);
1073 MachineInstr
*MI
= &*MII
;
1074 if (MI
->isBundle()) {
1078 if (MI
->isDebugInstr())
1081 LiveCPSR
= UpdateCPSRUse(*MI
, LiveCPSR
);
1083 // Does NextMII belong to the same bundle as MI?
1084 bool NextInSameBundle
= NextMII
!= E
&& NextMII
->isBundledWithPred();
1086 if (ReduceMI(MBB
, MI
, LiveCPSR
, IsSelfLoop
, SkipPrologueEpilogue
)) {
1088 MachineBasicBlock::instr_iterator I
= std::prev(NextMII
);
1090 // Removing and reinserting the first instruction in a bundle will break
1091 // up the bundle. Fix the bundling if it was broken.
1092 if (NextInSameBundle
&& !NextMII
->isBundledWithPred())
1093 NextMII
->bundleWithPred();
1096 if (BundleMI
&& !NextInSameBundle
&& MI
->isInsideBundle()) {
1097 // FIXME: Since post-ra scheduler operates on bundles, the CPSR kill
1098 // marker is only on the BUNDLE instruction. Process the BUNDLE
1099 // instruction as we finish with the bundled instruction to work around
1100 // the inconsistency.
1101 if (BundleMI
->killsRegister(ARM::CPSR
, /*TRI=*/nullptr))
1103 MachineOperand
*MO
=
1104 BundleMI
->findRegisterDefOperand(ARM::CPSR
, /*TRI=*/nullptr);
1105 if (MO
&& !MO
->isDead())
1107 MO
= BundleMI
->findRegisterUseOperand(ARM::CPSR
, /*TRI=*/nullptr);
1108 if (MO
&& !MO
->isKill())
1112 bool DefCPSR
= false;
1113 LiveCPSR
= UpdateCPSRDef(*MI
, LiveCPSR
, DefCPSR
);
1115 // Calls don't really set CPSR.
1117 HighLatencyCPSR
= false;
1119 } else if (DefCPSR
) {
1120 // This is the last CPSR defining instruction.
1122 HighLatencyCPSR
= isHighLatencyCPSR(CPSRDef
);
1127 MBBInfo
&Info
= BlockInfo
[MBB
.getNumber()];
1128 Info
.HighLatencyCPSR
= HighLatencyCPSR
;
1129 Info
.Visited
= true;
1133 bool Thumb2SizeReduce::runOnMachineFunction(MachineFunction
&MF
) {
1134 if (PredicateFtor
&& !PredicateFtor(MF
.getFunction()))
1137 STI
= &MF
.getSubtarget
<ARMSubtarget
>();
1138 if (STI
->isThumb1Only() || STI
->prefers32BitThumb())
1141 TII
= static_cast<const Thumb2InstrInfo
*>(STI
->getInstrInfo());
1143 // Optimizing / minimizing size? Minimizing size implies optimizing for size.
1144 OptimizeSize
= MF
.getFunction().hasOptSize();
1145 MinimizeSize
= STI
->hasMinSize();
1148 BlockInfo
.resize(MF
.getNumBlockIDs());
1150 // Visit blocks in reverse post-order so LastCPSRDef is known for all
1152 ReversePostOrderTraversal
<MachineFunction
*> RPOT(&MF
);
1153 bool Modified
= false;
1154 bool NeedsWinCFI
= MF
.getTarget().getMCAsmInfo()->usesWindowsCFI() &&
1155 MF
.getFunction().needsUnwindTableEntry();
1156 for (MachineBasicBlock
*MBB
: RPOT
)
1157 Modified
|= ReduceMBB(*MBB
, /*SkipPrologueEpilogue=*/NeedsWinCFI
);
1161 /// createThumb2SizeReductionPass - Returns an instance of the Thumb2 size
1163 FunctionPass
*llvm::createThumb2SizeReductionPass(
1164 std::function
<bool(const Function
&)> Ftor
) {
1165 return new Thumb2SizeReduce(std::move(Ftor
));