This is an archive of the discontinued LLVM Phabricator instance.

Utilize DQ-Form instructions for spill/restore and fix FrameIndex elimination to only use `lis/addi` if necessary
ClosedPublic

Authored by lei on Oct 10 2017, 12:57 PM.

Details

Summary

Currently we produce a bunch of unnecessary code when emitting the prologue/epilogue for spills/restores.
Namely, if the load from stack slot/store to stack slot instruction is an X-Form instruction, we will
always produce an LIS/ORI sequence for the stack offset.

Furthermore, we have not exploited the P9 vector D-Form loads/stores for this purpose.

This patch will address both issues.

Specifying the D-Form load as the instruction to use for stack spills/reloads should be safe because:

  1. The stack should be aligned according to the ABI
  2. If the stack isn't aligned, PPCRegisterInfo::eliminateFrameIndex() will check for the offset being a multiple of 16 and will convert it to an X-Form instruction if it isn't.

SPEC2017 performance run was done but none of the benchmarks showed any significant improvement.

	       SPEED UP
	       Baseline/new
SPEC_INT	
500.perlbench_r	1.00
502.gcc_r	1.00
505.mcf_r	0.99
523.xalancbmk_r	1.00
525.x264_r	1.01
531.deepsjeng_r	1.00
541.leela_r	1.00
557.xz_r	1.00
	
SPEC_FP	
508.namd_r	1.00
511.povray_r	1.00
519.lbm_r	1.00
538.imagick_r	1.00
544.nab_r	1.00

Diff Detail

Event Timeline

lei created this revision.Oct 10 2017, 12:57 PM
lei edited the summary of this revision. (Show Details)Oct 10 2017, 1:02 PM
echristo accepted this revision.Oct 10 2017, 6:28 PM

Code generation looks a lot more reasonable. Can you commit the change to test/CodeGen/PowerPC/sjlj.ll separately?

This revision is now accepted and ready to land.Oct 10 2017, 6:28 PM
lei added a comment.EditedOct 11 2017, 10:38 AM

Code generation looks a lot more reasonable. Can you commit the change to test/CodeGen/PowerPC/sjlj.ll separately?

NFC patch committed for test/CodeGen/PowerPC/sjlj.ll: rL315482

lei closed this revision.Oct 11 2017, 7:24 PM

Commit rL315500: [PowerPC] Utilize DQ-Form instructions for spill/restore and fix FrameIndex elimination to only use lis/addi if necessary.