[all-commits] [llvm/llvm-project] 4674ce: [SimplifyCFG] Fix branch-weight overflow when fold...

Andrei Elovikov via All-commits all-commits at lists.llvm.org
Tue Jul 28 09:33:36 PDT 2026


  Branch: refs/heads/users/eas/vplan-based-stride-mv-tests
  Home:   https://github.com/llvm/llvm-project
  Commit: 4674ce3fe91a0edea6cf780332891575af0884e9
      https://github.com/llvm/llvm-project/commit/4674ce3fe91a0edea6cf780332891575af0884e9
  Author: Alok Kumar Sharma <AlokKumar.Sharma at amd.com>
  Date:   2026-07-28 (Tue, 28 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Utils/Local.cpp
    A llvm/test/Transforms/SimplifyCFG/switch-default-fold-weight-overflow.ll

  Log Message:
  -----------
  [SimplifyCFG] Fix branch-weight overflow when folding switch case into default (#212520)

The overflow guard added in #178964 for merging a switch case's weight
into the default's calls fitWeights() to downscale the weights, but the
returned value was never assigned back to Weights, so the downscale
didn't take effect. As a result, a default+case sum that overflows
uint64_t would wrap around, turning a dominant default weight into a
small, incorrect one.

Assign fitWeights()'s result back to Weights before the addition so the
downscale takes effect as intended.


  Commit: aee4691d992692b3efffe4bbacec07d7740f2b06
      https://github.com/llvm/llvm-project/commit/aee4691d992692b3efffe4bbacec07d7740f2b06
  Author: Andrei Elovikov <andrei.elovikov at sifive.com>
  Date:   2026-07-28 (Tue, 28 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Utils/Local.cpp
    A llvm/test/Transforms/SimplifyCFG/switch-default-fold-weight-overflow.ll

  Log Message:
  -----------
  Merge branch 'main' into users/eas/vplan-based-stride-mv-tests


Compare: https://github.com/llvm/llvm-project/compare/5b3df5e62bd0...aee4691d9926

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