@@ -2471,10 +2471,13 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
2471
2471
if (OtherOp.isImm ()) {
2472
2472
OtherOp.setImm (OtherOp.getImm () + Offset);
2473
2473
Offset = 0 ;
2474
- }
2475
2474
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.
2478
2481
Register DstReg = DstOp.getReg ();
2479
2482
2480
2483
if (!TmpReg && MaterializedReg == FrameReg) {
@@ -2496,15 +2499,10 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
2496
2499
OtherOp.setIsKill (true );
2497
2500
OtherOp.setIsRenamable (true );
2498
2501
FIOp.ChangeToImmediate (Offset);
2499
- } else if (!OtherOp.isImm () && !MaterializedReg) {
2500
- FIOp.ChangeToImmediate (Offset);
2501
2502
} 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);
2508
2506
}
2509
2507
2510
2508
if (DeadSCC && OtherOp.isImm () && OtherOp.getImm () == 0 ) {
@@ -2521,7 +2519,6 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
2521
2519
}
2522
2520
2523
2521
assert (!FIOp.isFI ());
2524
-
2525
2522
return true ;
2526
2523
}
2527
2524
default : {
0 commit comments