diff options
| author | Elizaveta Noskova <159026035+enoskova-sc@users.noreply.github.com> | 2025-09-24 11:46:18 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-24 11:46:18 +0300 |
| commit | 23d27d586f91b01cee2ba771af2f3385a2b70b07 (patch) | |
| tree | 37d91636799fb05ff3a26fe4ce1e65fd86a29909 /llvm/lib/Target/RISCV/RISCVISelLowering.cpp | |
| parent | 8cb03a05ff18834cc452277718fecd2e87b623f0 (diff) | |
[RISCV] Don't merge pseudo selects with stack adjustment instrs in between (#160105)
When we have sequence of select pseudo instructions with stack adjustment
instructions in between, we shouldn't apply the optimization, proposed by link
https://reviews.llvm.org/D59355. If optimization is applied,
function won't be marked `adjustsStack` during Finalize ISel pass.
Diffstat (limited to 'llvm/lib/Target/RISCV/RISCVISelLowering.cpp')
| -rw-r--r-- | llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 937213bfddfa..1ae5cb5730dc 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -22274,6 +22274,7 @@ static MachineBasicBlock *emitSelectPseudo(MachineInstr &MI, // - They are debug instructions. Otherwise, // - They do not have side-effects, do not access memory and their inputs do // not depend on the results of the select pseudo-instructions. + // - They don't adjust stack. // The TrueV/FalseV operands of the selects cannot depend on the result of // previous selects in the sequence. // These conditions could be further relaxed. See the X86 target for a @@ -22302,6 +22303,8 @@ static MachineBasicBlock *emitSelectPseudo(MachineInstr &MI, SelectDests.insert(MI.getOperand(0).getReg()); MachineInstr *LastSelectPseudo = &MI; + const RISCVInstrInfo &TII = *Subtarget.getInstrInfo(); + for (auto E = BB->end(), SequenceMBBI = MachineBasicBlock::iterator(MI); SequenceMBBI != E; ++SequenceMBBI) { if (SequenceMBBI->isDebugInstr()) @@ -22321,7 +22324,9 @@ static MachineBasicBlock *emitSelectPseudo(MachineInstr &MI, } if (SequenceMBBI->hasUnmodeledSideEffects() || SequenceMBBI->mayLoadOrStore() || - SequenceMBBI->usesCustomInsertionHook()) + SequenceMBBI->usesCustomInsertionHook() || + TII.isFrameInstr(*SequenceMBBI) || + SequenceMBBI->isStackAligningInlineAsm()) break; if (llvm::any_of(SequenceMBBI->operands(), [&](MachineOperand &MO) { return MO.isReg() && MO.isUse() && SelectDests.count(MO.getReg()); @@ -22329,7 +22334,6 @@ static MachineBasicBlock *emitSelectPseudo(MachineInstr &MI, break; } - const RISCVInstrInfo &TII = *Subtarget.getInstrInfo(); const BasicBlock *LLVM_BB = BB->getBasicBlock(); DebugLoc DL = MI.getDebugLoc(); MachineFunction::iterator I = ++BB->getIterator(); |
