Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvm/lib/Target/ARM/ARMFeatures.td
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,13 @@ def FeatureAvoidPartialCPSR : SubtargetFeature<"avoid-partial-cpsr",
"AvoidCPSRPartialUpdate", "true",
"Avoid CPSR partial update for OOO execution">;

/// FeatureAvoidMULS - If true, codegen would avoid using the MULS instruction,
/// prefering the thumb2 MUL which doesn't set flags.
def FeatureAvoidMULS : SubtargetFeature<"avoid-muls",
"AvoidMULS", "true",
"Avoid MULS instructions for M class cores">;


/// Disable +1 predication cost for instructions updating CPSR.
/// Enabled for Cortex-A57.
/// True if disable +1 predication cost for instructions updating CPSR. Enabled for Cortex-A57.
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/ARM/ARMProcessors.td
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def : ProcessorModel<"cortex-m33", CortexM4Model, [ARMv8mMainline,
FeatureHasSlowFPVFMx,
FeatureUseMISched,
FeatureHasNoBranchPredictor,
FeatureAvoidMULS,
FeatureFixCMSE_CVE_2021_35465]>;

def : ProcessorModel<"star-mc1", CortexM4Model, [ARMv8mMainline,
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@ Thumb2SizeReduce::ReduceTo2Addr(MachineBasicBlock &MBB, MachineInstr *MI,
Register Reg1 = MI->getOperand(1).getReg();
// t2MUL is "special". The tied source operand is second, not first.
if (MI->getOpcode() == ARM::t2MUL) {
// MULS can be slower than MUL
if (!MinimizeSize && STI->avoidMULS())
return false;
Register Reg2 = MI->getOperand(2).getReg();
// Early exit if the regs aren't all low regs.
if (!isARMLowRegister(Reg0) || !isARMLowRegister(Reg1)
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/Thumb2/avoidmuls.mir
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ body: |

...
# CHECK-LABEL: test
# CHECK: tMUL
# CHECK-NOT: t2MUL
# CHECK: t2MUL
# CHECK-NOT: tMUL
Loading