Steve King
2015-Jul-01 17:37 UTC
[LLVMdev] something better than .align for branch targets
Hello LLVM, For some processors, the all or nothing behavior of the .align directive is not optimal for improving fetch efficiency of branches. For example, take an instruction fetch width of 16 bytes and a branch target just 1 byte offset into a fetch block. Align injects 15 bytes of padding rather than leaving well enough alone. Efficiency is unlikely to improve for lack of 1 byte out of 16, and performance may be hurt by all the padding not to mention code size. Is there an existing way for a target to express a "near enough" semantic for code alignment? Regards, -steve
Steve King
2015-Jul-01 20:46 UTC
[LLVMdev] something better than .align for branch targets
> Is there an existing way for a target to express a "near enough" > semantic for code alignment? >After more investigation: The .align directive supports an optional MaxFillBytes parameter, which would nicely prevent the over-padding problem. However, MachineBlockPlacement cannot use this feature when aligning loops since targets support getPrefLoopAlignment(), but not getPrefLoopAlignmentMaxFill(). Does anyone dislike the idea of a new target lowering query getPrefLoopAlignmentMaxFill()? This new query would allow MachineBlockPlacement to specify the align directive's MaxFillBytes parameter when aligning loops. Targets could then control over-padding as they see fit. If there are no objections, I will submit a patch.