This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Add additional targets to divide tests.
ClosedPublic

Authored by keith.walker.arm on Oct 13 2022, 7:15 AM.

Details

Summary

The main motivation for these additional targets is to cover the
differences in the instructions available between Thumb2 and Thumb1.

Ths shows up in these test due to the lack of the following in
Thumb1:

  • Mulitply and Subtract instruction (mls) - used when calculating a remainder.
  • Unsigned Muliple Long instruction (umull) - used in certain cases when optimising division with a constant.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 7:15 AM
keith.walker.arm requested review of this revision.Oct 13 2022, 7:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 7:15 AM
llvm/test/CodeGen/ARM/div.ll
0–1

You can use -check-prefixes=CHECK,CHECK-HWDIV,CHECK-HWDIV-T2 rather than repeatedly using -check-prefix=.

143

divide

llvm/test/CodeGen/ARM/div.ll
1

should this RUN have a check for CHECK-THUMB as well?

3

should this RUN have a check for CHECK-THUMB as well?

llvm/test/CodeGen/ARM/div.ll
0–1

Thanks, I'll update all the run lines to use this feature.

1

Maybe the name "CHECK-HWDIV-T2" could be improved because the CHECK-HWDIV-T2 case also covers the cases when ARM code is generated (rather than Thumb).

So maybe it should be "CHECK-HWDIV-NOT-T1" or possibly CHECK-HWDIV-ARM-OR-THUMB2 (and in this case change CHECK-HWDIV-T1 to CHECK-HWDIV-THUMB1).

Now I've just written that, I think the latter case is possibly the clearest in showing the intent, so I'm going to go with that unless someone provide a better suggestion.

143

Actually in this case multiply is correct.

The test cases @f7 and @f8 for checking for no libcall were added as part of this change https://reviews.llvm.org/D130862 which quote "this urem will be expand by DAGCombiner using multiply by magic constant". The lack of the necessary multiply instruction causes the optimisation in that change to not apply.

Can you summarise the differences you're testing for, in the commit message? I'm not very familiar with the differences but I'll quickly double check them if you list them out.

(also add [LLVM] at the start of the title while you're there)

keith.walker.arm edited the summary of this revision. (Show Details)
  • Updated summary with description of the instructions not available in Thumb1.
  • Merged the multiple --check-prefix= entries into a single --check-prefixes= entry.
  • Changed CHECK-HWDIV-T2 to CHECK-HWDIV-ARM-OR-THUMB2.
  • Changed CHECK-HW-DIV-T1 to CHECK-HWDIV-THUMB1.
  • Tweaked comment about lack of 32-bit => 64-bit HW multiple instructions to say this prevents an optimisation.

Going from the architecture manual, T1 has those two instructions but for "Armv8-M Main Extension only". I see a test line for thumbv8m.base which I think does not have that, is it worth adding one with the main extension?

Otherwise this seems fine we're codifying what we already do and more coverage is a good thing.

keith.walker.arm marked an inline comment as not done.

Added a mainline target "-mtriple=thumbv8m.main -mcpu=cortex-m33" as suggested.

nickdesaulniers accepted this revision.Oct 14 2022, 10:27 AM
nickdesaulniers added inline comments.
llvm/test/CodeGen/ARM/div.ll
3–5

If we're going to have added whitespace up to the pipes |, please keep these all aligned.

This revision is now accepted and ready to land.Oct 14 2022, 10:27 AM
DavidSpickett accepted this revision.Oct 17 2022, 2:07 AM

LGTM, once Nick's not done comments are addressed.

Lined up all the pipes to keep them aligned.

keith.walker.arm marked 2 inline comments as done.Oct 17 2022, 3:46 AM
This revision was landed with ongoing or failed builds.Oct 17 2022, 8:55 AM
This revision was automatically updated to reflect the committed changes.
keith.walker.arm marked an inline comment as done.