[all-commits] [llvm/llvm-project] e03b1b: [CodeGen][MachineLoop] Fix getLoopID (#137820)
Vito Kortbeek via All-commits
all-commits at lists.llvm.org
Fri May 23 23:53:12 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e03b1b895e03bf404c4d254faa47356de516bb94
https://github.com/llvm/llvm-project/commit/e03b1b895e03bf404c4d254faa47356de516bb94
Author: Vito Kortbeek <kortbeek at synopsys.com>
Date: 2025-05-24 (Sat, 24 May 2025)
Changed paths:
M llvm/lib/CodeGen/MachineLoopInfo.cpp
M llvm/test/CodeGen/X86/code-align-loops.ll
Log Message:
-----------
[CodeGen][MachineLoop] Fix getLoopID (#137820)
Mirror the `getLoopID()` implementation of `LoopInfo` in
`MachineLoopInfo`.
`getLoopID` used `findLoopControlBlock` to detect the special case where
there is a single latch. However, `findLoopControlBlock` returns the
exiting block if the latch is not an exiting block. The middle end
places the `LoopID` metadata on the
latch regardless of if it's an exiting block or not.
I raised this issue in the PR that introduced the `getLoopID()` helper
(https://github.com/llvm/llvm-project/pull/71026#discussion_r2000595214)
and @FreddyLeaf confirmed this is a bug and asked me to help implement a
refinement.
I've mirrored the implementation of `LoopInfo` instead of simply
changing `findLoopControlBlock()` to `findLoopControlBlock()` to keep
the two implementations consistent. The only difference between the two
is that `MachineLoopInfo::getLoopID` initially starts out with a
`MachineBacisBlock` and attempts to retrieve the `BasicBlock` (if it
wasn't for this difference, I would have moved it to `genericLoopInfo`).
I've also updated the test associated with
https://github.com/llvm/llvm-project/pull/71026 (`test5`) that check the
alignment for a loop with a single latch that's not the exit. This test
will fail for the current implementation. I'm not sure if we want to
include this test upstream (it might look out of place after we remove
the 'single-latch-specialization' from `getLoopID()`).
Let me know if you have any comments, @FreddyLeaf !
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