[all-commits] [llvm/llvm-project] 362cd6: [SimpleLoopUnswitch] Don't latch-redirect trivial ...

Adel Ejjeh via All-commits all-commits at lists.llvm.org
Wed Jul 8 14:15:08 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 362cd64fab04219913d89a14fc54767376a9a737
      https://github.com/llvm/llvm-project/commit/362cd64fab04219913d89a14fc54767376a9a737
  Author: Adel Ejjeh <adel.ejjeh at amd.com>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
    A llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch-convergent.ll

  Log Message:
  -----------
  [SimpleLoopUnswitch] Don't latch-redirect trivial unswitch across convergent ops (#207047)

The trivial-unswitch case added in #204934 can redirect a loop-invariant
branch's latch edge to the loop exit, turning it into an exit branch
that then gets hoisted to the preheader. That changes how many
iterations (and, on GPUs, which lanes) execute the loop body.

When the loop contains a convergent operation that runs each iteration,
hoisting the branch lets one (possibly non-uniform) path bypass the loop
entirely and skip the convergent op. Concretely, this miscompiles an
AMDGPU warp reduction (llvm.amdgcn.update.dpp): lanes drop out of the
cross-lane shuffle, so block reductions come back with partial results.

Guard the new latch-redirect transform with the same convergent /
cross-block-token check that isSafeForNonTrivialUnswitching already
applies (refactored into a shared loopContainsConvergentOrTokenOp
helper). Adds a target-independent lit test that fails before this
change and passes after.

Co-authored-by: Claude Opus



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list