This is an archive of the discontinued LLVM Phabricator instance.

[LAA] Handle forked pointers with add/sub instructions
ClosedPublic

Authored by huntergr on Jul 21 2022, 8:11 AM.

Details

Summary

Handle cases where a forked pointer has an add or sub instruction before reaching a select.

Tests were precommitted in rG0a715c114686

Diff Detail

Event Timeline

huntergr created this revision.Jul 21 2022, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2022, 8:11 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
huntergr requested review of this revision.Jul 21 2022, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2022, 8:11 AM
mgabka added a subscriber: mgabka.Jul 25 2022, 5:10 AM
paulwalker-arm accepted this revision.Aug 12 2022, 5:57 AM

I'm not hugely familiar with this code but I can see you're following the same idiom as used for Instruction::GetElementPtr which is just a special type of add so this patch looks good to me. Please remember to run clang-format before landing the patch.

llvm/lib/Analysis/LoopAccessAnalysis.cpp
931–932

This looks to break the 80 character line length rules.

This revision is now accepted and ready to land.Aug 12 2022, 5:57 AM
fhahn accepted this revision.Aug 14 2022, 3:34 AM

LGTM, thanks! Please format the diff with clang-format before committing.

It would probably be also good to add at least one test where the pointer bounds are expanded (e.g. with LV) and the ops require freezing.

llvm/lib/Analysis/LoopAccessAnalysis.cpp
828

Are you planning to support additional bin-ops in the future here? Or could this be moved to the scope in the corresponding switch case?

928

Not directly related to this patch, but given that we return after the switch it might be simpler to follow if we would just return instead of break in the switch?

This revision was landed with ongoing or failed builds.Aug 17 2022, 1:52 AM
This revision was automatically updated to reflect the committed changes.
huntergr added inline comments.Aug 17 2022, 2:01 AM
llvm/lib/Analysis/LoopAccessAnalysis.cpp
828

I plan to support multiply in a future patch; it seems to need a little more work that add and sub.

Though there's plenty of codebases which can benefit from this work, one of the main cases we considered is https://github.com/HydroBench/Hydro/ -- specifically the loops in riemann.c

There's a few other problems I need to deal with for hydro (openmp runtime functions not being annotated by default, lack of vectorization using masked functions) before I can finish off the rest of this work. But there's at least a few more operations to add to this switch statement -- multiplies as mentioned above, zero and sign extends, and phis used for non-SAR purposes in the loop (e.g. if-then)

928

Yes, I'll add that in a follow-on patch along with the extra test.