@@ -2471,10 +2471,13 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
24712471 if (OtherOp.isImm ()) {
24722472 OtherOp.setImm (OtherOp.getImm () + Offset);
24732473 Offset = 0 ;
2474- }
24752474
2476- // If we can't fold the other operand, do another increment.
2477- if (!OtherOp.isImm () && MaterializedReg) {
2475+ if (MaterializedReg)
2476+ FIOp.ChangeToRegister (MaterializedReg, false );
2477+ else
2478+ FIOp.ChangeToImmediate (0 );
2479+ } else if (MaterializedReg) {
2480+ // If we can't fold the other operand, do another increment.
24782481 Register DstReg = DstOp.getReg ();
24792482
24802483 if (!TmpReg && MaterializedReg == FrameReg) {
@@ -2496,15 +2499,10 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
24962499 OtherOp.setIsKill (true );
24972500 OtherOp.setIsRenamable (true );
24982501 FIOp.ChangeToImmediate (Offset);
2499- } else if (!OtherOp.isImm () && !MaterializedReg) {
2500- FIOp.ChangeToImmediate (Offset);
25012502 } else {
2502- assert (Offset == 0 );
2503-
2504- if (MaterializedReg)
2505- FIOp.ChangeToRegister (MaterializedReg, false );
2506- else
2507- FIOp.ChangeToImmediate (0 );
2503+ // If we don't have any other offset to apply, we can just directly
2504+ // interpret the frame index as the offset.
2505+ FIOp.ChangeToImmediate (Offset);
25082506 }
25092507
25102508 if (DeadSCC && OtherOp.isImm () && OtherOp.getImm () == 0 ) {
@@ -2521,7 +2519,6 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
25212519 }
25222520
25232521 assert (!FIOp.isFI ());
2524-
25252522 return true ;
25262523 }
25272524 default : {
0 commit comments