This is an archive of the discontinued LLVM Phabricator instance.

[LLVM][Uniformity] Propagate divergence only along divergent outputs.
ClosedPublic

Authored by sameerds on May 15 2023, 10:07 PM.

Details

Summary

When an instruction is determined to be divergent, not all its outputs are
divergent. The users of only divergent outputs should now be examined for
divergence.

Also, replaced a repeating pattern of "if new divergent instruction, then add to
worklist" by combining it into a single function. This does not cause any change
in functionality.

Diff Detail

Event Timeline

sameerds created this revision.May 15 2023, 10:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2023, 10:07 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
sameerds requested review of this revision.May 15 2023, 10:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2023, 10:07 PM
sameerds added a subscriber: Restricted Project.
foad accepted this revision.May 15 2023, 11:48 PM

LGTM with or without nits addressed.

llvm/include/llvm/ADT/GenericUniformityImpl.h
358–359

Maybe it's time to comment each function separately? The one you've changed no longer returns anything.

786–788

else after return looks odd and it seems easy to avoid it here.

This revision is now accepted and ready to land.May 15 2023, 11:48 PM
sameerds updated this revision to Diff 522501.May 16 2023, 2:07 AM
  • added a small but important fix
  • eliminated return-after-else
sameerds retitled this revision from [LLVM][Uniformity] Simplify handling of new divergent values to [LLVM][Uniformity] Propagate divergence only along divergent outputs..May 16 2023, 2:08 AM
sameerds edited the summary of this revision. (Show Details)
sameerds requested review of this revision.May 16 2023, 2:10 AM
sameerds marked 2 inline comments as done.

Requesting a fresh review because I added a fix. markDefsDivergent() only records divergent outputs of a multi-output instruction, but pushUsers() was blindly propagating divergence along the uses of the uniform outputs. The change was small and related to what I was doing, so didn't create a separate review. This eliminates a FIXME in an existing MIR test.

foad added inline comments.May 16 2023, 2:23 AM
llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/always-uniform-gmir.mir
100 ↗(On Diff #522501)

Just checking my understanding: this should have said "FIXME: first output of below inline asm should be uniform"?

sameerds added inline comments.May 16 2023, 2:33 AM
llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/always-uniform-gmir.mir
100 ↗(On Diff #522501)

That is my understanding too! After recent changes, it is certainly true that the s32 output should be uniform, and this current change ensures that its use in the COPY instruction also remains uniform. If I revert the current change but keep this test, then the CHECK-NOT fails for %4.

arsenm accepted this revision.May 16 2023, 7:24 AM
This revision is now accepted and ready to land.May 16 2023, 7:24 AM