This is an archive of the discontinued LLVM Phabricator instance.

[instcombine] Simplify separate_storage hints.
ClosedPublic

Authored by davidtgoldblatt on Feb 27 2023, 5:20 PM.

Details

Summary

Before this change, we call getUnderlyingObject on each separate_storage
operand on every alias() call (potentially requiring lots of pointer
chasing). Instead, we rewrite the assumptions in instcombine to do this
pointer-chasing once.

We still leave the getUnderlyingObject calls in alias(), just expecting
them to be no-ops much of the time. This is relatively fast (just a
couple dyn_casts with no pointer chasing) and avoids making alias
analysis results depend on whether or not instcombine has been run.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 5:20 PM
davidtgoldblatt requested review of this revision.Feb 27 2023, 5:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 5:20 PM
nikic added inline comments.Feb 28 2023, 1:00 AM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
2523

This should be done unconditionally, independently of the BasicAA flag.

2532

Use replaceUse() instead, drop code below.

StephenFan added inline comments.Feb 28 2023, 1:37 AM
llvm/test/Transforms/InstCombine/assume-separate_storage.ll
3

Is 2>&1 necessary?

Unconditionally do fold, use replaceUse, remove unnecessary pipe redirection.

davidtgoldblatt marked 3 inline comments as done.Feb 28 2023, 3:19 PM
nikic accepted this revision.Mar 1 2023, 12:16 AM

LGTM

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
2529
2530

Drop braces.

2531

Sounds like OBO.Inputs should be a MutableArrayRef...

This revision is now accepted and ready to land.Mar 1 2023, 12:16 AM

Would you mind committing for me? I don't have commit access.

I'll take a look at doing the MutableArrayRef change as well.

This revision was automatically updated to reflect the committed changes.