This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][NFC] Call the API getVScaleRange directly
ClosedPublic

Authored by Allen on Jul 19 2023, 7:19 AM.

Details

Summary

Use the maximum 64 for BitWidth of getVScaleRange to avoid returning an empty range.

the previous changes bring in a Buildbot failure because MinSVEVectorSize = MinSVEVectorSize.

error: explicitly assigning value of variable of type 'unsigned int' to itself [-Werror,-Wself-assign]

Diff Detail

Event Timeline

Allen created this revision.Jul 19 2023, 7:19 AM
Allen requested review of this revision.Jul 19 2023, 7:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 7:19 AM

I like the cleanup. getVScaleRange can fail, returning an empty range. Would this handle those cases too?

nikic added inline comments.Jul 20 2023, 12:33 AM
llvm/lib/Analysis/InstructionSimplify.cpp
6544

if (const APInt *C = CR.getSingleElement())

Allen updated this revision to Diff 542425.Jul 20 2023, 4:42 AM
Allen edited the summary of this revision. (Show Details)
Allen marked an inline comment as done.

I like the cleanup. getVScaleRange can fail, returning an empty range. Would this handle those cases too?

Use the maximum 64 for BitWidth of getVScaleRange to avoid returning an empty range.

sdesmalen accepted this revision.Jul 24 2023, 5:52 AM

I like the cleanup. getVScaleRange can fail, returning an empty range. Would this handle those cases too?

Use the maximum 64 for BitWidth of getVScaleRange to avoid returning an empty range.

It seems getSingleElement() returns nullptr when:

  • The range is empty
  • The range is invalid
  • The maximum < minimum (e.g. for a range of vscale_range(1, 0)).

So I think the change is fine, regardless of the bitwidth.

This revision is now accepted and ready to land.Jul 24 2023, 5:52 AM
nikic added inline comments.Jul 24 2023, 5:52 AM
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
405

I'm not sure this is going to do the right thing if there is no upper bound on the range. Won't the * 128 overflow in that case?

Allen added inline comments.Jul 25 2023, 12:22 AM
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
405

This refactor doesn't reduces the range of the upper limit.
Maybe we assume there is no overflow because the maximum value of vscale is 2048 for arm targets, https://reviews.llvm.org/D98030

This revision was landed with ongoing or failed builds.Jul 26 2023, 12:54 AM
This revision was automatically updated to reflect the committed changes.
DavidSpickett added inline comments.
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
420
/work/open_source/lldb-cross-compile/llvm-project/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp:420:22: warning: explicitly assigning value of variable of type 'unsigned int' to itself [-Wself-assign]
    MinSVEVectorSize = MinSVEVectorSize;
    ~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~

Compiling with clang-11.

Allen marked an inline comment as done.Jul 26 2023, 2:29 AM
Allen added inline comments.
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
420

Thanks for the reminder, I already revert , and will fix this bug.

Allen updated this revision to Diff 544289.Jul 26 2023, 3:50 AM
Allen marked an inline comment as done.
Allen edited the summary of this revision. (Show Details)
Allen added a reviewer: DavidSpickett.

Fix build error

error: explicitly assigning value of variable of type 'unsigned int' to itself [-Werror,-Wself-assign]
This revision was landed with ongoing or failed builds.Jul 26 2023, 3:55 AM