[llvm] [LoopFusion] Validate loop structure before creating LoopCandidates (PR #192280)

Ehsan Amiri via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 13:49:09 PDT 2026


================

----------------
amehsan wrote:

Looks like the check that you want to perform already exists in `isEligibleForFusion`. The problem is that this function calls `reportInvalidCandidate`, which seems to assume some conditions are already met. (In particular preheader exists). 

Don't keep the redundant check if you want to do this checks earlier. You may modify this function to skip updating stats and emitting optimization remarks (and that will fix the problem). Right now loop fusion is very conservative, and stats and remarks for this cases is not really useful. 

Also we call `isLoopSimplifyForm` and `isRotatedForm` inside `isEligibleForFusion`. I suspect some of the earlier checks in the fuction are redundant. But it is OK for me if you don't want address this redundancy in this PR.




https://github.com/llvm/llvm-project/pull/192280


More information about the llvm-commits mailing list