[PATCH] D118102: [LoopInterchange] Prevent interchange with unsafe control-flow divergence inside inner loops (PR48057)

Congzhe Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 8 09:51:25 PST 2022


congzhe added a comment.

In D118102#3287827 <https://reviews.llvm.org/D118102#3287827>, @Meinersbur wrote:

> 



> `store i16 %conv9.i, i16* @e` hazards with itself from different iterations (same memory, both are "write"). It would not be very different if it was an array and indexed `e[f(d,c)]` where `f` is a speculable/const function (and potentially always returns `0`). If no dependence is detected, I'd consider it a bug.

Thanks Michael, when we check dependency in loop interchange, we check instructions in pair and we did not check an instruction with itself. That's why we did not detect the output dependency that  `store i16 %conv9.i, i16* @e` hazards with itself. I've updated the check so I could detect the output dependency now (patch not updated yet).

> In principle an output-dependency does not matter if overwritten anyway before being used. However, DependenceAnalysis doesn't even have an API to consider that. It also does not make a difference between "unconditionally overwrite" (in literature called a "kill") and a conditional or partial write:

I agree with you. The problem in this bug is the "conditional or partial write" you mentioned, in other words, output dependency under control-flow divergence. I can add code to detect "output dependency under control-flow divergence" in loop interchange, or in DependenceAnalysis.cpp. IIUC you prefer to do it in DependenceAnalysis.cpp and add new API there, so I'm working on an design and I'd appreciate it if we could further discuss it maybe on the next loop opt meeting.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118102/new/

https://reviews.llvm.org/D118102



More information about the llvm-commits mailing list