This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Do not hoist/sink convergent function calls
ClosedPublic

Authored by yaxunl on Feb 24 2023, 12:46 PM.

Details

Summary

Currently SimplifyCFG hoists/sink common instructions in then/else basic blocks
when certain options are enabled, which is the case for default clang optimization
pipelines for -O3. It tries to hoist/sink convergent function calls in divergent
control flow, which causes incorrect ISA generated for GPU, e.g.
https://github.com/ROCm-Developer-Tools/HIP/issues/3172

This patch fixes that by conservatively disable hoisting/sinking common
convergent function calls in then/else blocks.

Diff Detail

Event Timeline

yaxunl created this revision.Feb 24 2023, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 12:46 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
yaxunl requested review of this revision.Feb 24 2023, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 12:46 PM
foad added a subscriber: foad.Feb 26 2023, 11:56 PM
tra accepted this revision.Feb 27 2023, 11:59 AM
tra added inline comments.
llvm/test/Transforms/SimplifyCFG/convergent.ll
55

Nit: Do we intend to pattern-match if.then here and use [[IF_THEN]]: instead?

I guess we should either consistently use captured labels, or literal label names everywhere.

This revision is now accepted and ready to land.Feb 27 2023, 11:59 AM
yaxunl added inline comments.Feb 27 2023, 12:38 PM
llvm/test/Transforms/SimplifyCFG/convergent.ll
55

that is done by utils/update_test_checks.py. need a separate patch to fix utils/update_test_checks.py.

This revision was automatically updated to reflect the committed changes.
nhaehnle added inline comments.Mar 2 2023, 3:52 AM
llvm/test/Transforms/SimplifyCFG/convergent.ll
55

I have a patch for that at https://reviews.llvm.org/D142452, I just haven't been able to follow up over the last month.