This is an archive of the discontinued LLVM Phabricator instance.

[SVE][CodeGen][NFC] Replace TypeSize comparison operators with their scalar equivalents
ClosedPublic

Authored by david-arm on Sep 29 2020, 6:05 AM.

Details

Summary

In certain places in llvm/lib/CodeGen we were relying upon the TypeSize
comparison operators when in fact the code was only ever expecting
either scalar values or fixed width vectors. I've changed some of these
places to use the equivalent scalar operator.

Diff Detail

Event Timeline

david-arm created this revision.Sep 29 2020, 6:05 AM
david-arm requested review of this revision.Sep 29 2020, 6:05 AM

Please separate all the "non-functional" (just adding .getFixedSize()) changes into a separate patch from any changes that potentially have functional effects.

Hi @efriedma, sure I can do that. To be honest (and this is probably my lack of understanding of what is meant by a functional change) I thought they were almost all non-functional. That's why I originally put them in this patch together. Just for my understanding, which bits do you consider non-functional? I can definitely see that one change in TargetLowering is non-functional, but in other cases such as mergeTruncStores where I call getScalarSizeInBits() instead of getSizeInBits() to me, naively, this seemed non-functional because we're dealing with scalar values - the function bails out if the type is not a simple integer. Similarly in ReduceLoadWidth we bail out immediately if the type is a vector, so from that point onwards the type is guaranteed to be scalar.

From a fixed-width vector perspective, all the getFixedSize() changes are purely NFC. Changes like getSizeInBits() -> getScalarSizeInBits() are _possibly_ functional if your assumption that the type must be a scalar value, ends up being false. I think the exception here are the cases where it can be trivially seen that the function bails out early when the type is not a scalar.

From a scalable-vector perspective, the getFixedSize() changes are not necessarily non-functional, because if a scalable vector goes down these code-paths things will now break with an assert where it would previously 'just work'. In your patch you're making the assumption that scalable vectors shouldn't go down these code-paths, so they are likely to be non-functional.

I think Eli's point is that you could move out all the getFixedSize changes into a separate patch, as those are known to be NFC for fixed-width vectors and can't break any of the buildbots or impact any other users of LLVM that don't compile for SVE.

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7862

Was this change supposed to be part of this patch?

david-arm updated this revision to Diff 295247.Sep 30 2020, 5:21 AM
david-arm retitled this revision from [SVE][CodeGen] Replace TypeSize comparison operators with their scalar equivalents to [SVE][CodeGen][NFC] Replace TypeSize comparison operators with their scalar equivalents.
david-arm edited the summary of this revision. (Show Details)
david-arm updated this revision to Diff 295749.Oct 2 2020, 1:14 AM
This revision is now accepted and ready to land.Oct 16 2020, 2:54 AM