This is an archive of the discontinued LLVM Phabricator instance.

TTI: Add function to hasBranchDivergence
ClosedPublic

Authored by arsenm on Jun 2 2023, 4:24 AM.

Details

Summary

It my be possible to contextually ignore divergence
in a function.

Diff Detail

Event Timeline

arsenm created this revision.Jun 2 2023, 4:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 4:24 AM
arsenm requested review of this revision.Jun 2 2023, 4:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 4:24 AM
tra added inline comments.Jun 2 2023, 10:08 AM
llvm/include/llvm/Analysis/TargetTransformInfo.h
403

Nit: the comment sounds ambiguous.

Is that "can be used to report all values *that* can be assumed [to be] uniform"?
Or "can be used to report that all values can be assumed [to be] uniform"?

Considering that we're returning a bool, I assume it's the latter.

404

Does it mean that with nullptr argument the function reports whether the target has a concept of divergence, but if passed an actual function, ti would report whether the function has divergent IR?

I'd argue that for such different purposes we should have separate function calls.

  • bool hasBranchDivergence() would report whether target cares about divergence.
  • bool isAlwaysUniform(const Function *F) would report whether a given function is divergent.
arsenm updated this revision to Diff 527973.Jun 2 2023, 2:17 PM

Try to make comment clearer

llvm/include/llvm/Analysis/TargetTransformInfo.h
404

No, this is backwards. This isn't and can't be a stateful declaration about the content of the function. This can only report divergent target executing in single threaded mode such that you can/should ignore any analysis of the function. Which is essentially this is acting like a target that doesn't care about divergence, which is the same concept.

tra accepted this revision.Jun 2 2023, 2:56 PM

Thank you for the explanation. LGTM.

This revision is now accepted and ready to land.Jun 2 2023, 2:56 PM