llvm / llvm/llvm-project

Should we have a llvm.loop.optsize/minsize attribute

Open
#159,595 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This stems from the discussion in https://github.com/llvm/llvm-project/pull/159522. That PR aims to use PGOForceFunctionAttrsPass (added in https://github.com/llvm/llvm-project/pull/69030) to prevent SimpleLoopUnswitch from increasing the code size of cold functions.

Is it worthwhile to have a loop-level equivalent, something like PGOForceLoopAttrsPass that annotates cold loops with a `llvm.loop.optsize` attribute or equivalent?

We have the llvm.loop.unroll.disable attribute for LoopUnroll, but this would be more general. Just from a quick grep in llvm/lib/Transforms/Scalar it looks like LoopUnroll, SimpleLoopUnswitch, LoopBoundSplit, LoopLoadElimination and LoopIdiomRecognize could take advantage of this to get more granular behaviour.

cc) @aeubanks @nikic @fhahn @teresajohnson

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.