This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Simplify llvm.vscale when vscale_range attribute exists
ClosedPublic

Authored by junparser on Jul 26 2021, 11:17 PM.

Details

Diff Detail

Event Timeline

junparser created this revision.Jul 26 2021, 11:17 PM
junparser requested review of this revision.Jul 26 2021, 11:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2021, 11:17 PM

Hi @junparser, thanks for looking into this performance improvement! However, I personally think it makes more sense to just always replace a call to vscale directly with a constant if you know the value of vscale at runtime - possibly done in InstSimplify or something like that? That way you don't need to add lots of different instcombine changes to support all the different folds that can happen. Constant folds would just kick in automatically.

junparser updated this revision to Diff 362330.Jul 28 2021, 4:24 AM

Address comment. Move change to InstSimplify Pass

david-arm accepted this revision.Jul 28 2021, 5:07 AM

LGTM! Thanks a lot for making the changes. :)

This revision is now accepted and ready to land.Jul 28 2021, 5:07 AM
frasercrmck added inline comments.Jul 28 2021, 5:08 AM
llvm/lib/Analysis/InstructionSimplify.cpp
5787

I'd say that SVE isn't a good variable name here since RISC-V will also use this attribute at some point.

david-arm added inline comments.Jul 28 2021, 5:10 AM
llvm/lib/Analysis/InstructionSimplify.cpp
5787

Ah, good spot @frasercrmck ! Sorry I missed that. :(

spatel added inline comments.Jul 28 2021, 5:14 AM
llvm/test/Transforms/InstSimplify/fold-vscale.ll
10

The shifts in these tests are not necessary to show the transform, so I'd take them out.

junparser updated this revision to Diff 362362.Jul 28 2021, 6:40 AM

Address comments.

This revision was landed with ongoing or failed builds.Jul 28 2021, 6:42 AM
This revision was automatically updated to reflect the committed changes.
david-arm added inline comments.Jul 28 2021, 7:01 AM
llvm/lib/Analysis/InstructionSimplify.cpp
5787

nit: I think 'Scalar' here is a bit confusing as that's kind of the opposite of 'Vector'. Perhaps 'Scalable' is better?

frasercrmck added inline comments.Jul 28 2021, 7:02 AM
llvm/lib/Analysis/InstructionSimplify.cpp
5787

Yeah. Or VScaleMin and VScaleMax?

sdesmalen added inline comments.Jul 28 2021, 7:09 AM
llvm/lib/Analysis/InstructionSimplify.cpp
5787

Or just Min and Max?

llvm/test/Transforms/InstSimplify/fold-vscale.ll
4

nit: it would be useful to add _range_<min>_<max> to the name as well, since the attributes are at the bottom, making it slightly easier to read, e.g.@ vscale_i64_range_1_1().

OK, I'll fix these with an NFC patch. Thanks!