[all-commits] [llvm/llvm-project] a18ce4: [LoopPredication] Account for critical edges when ...
Max Kazantsev via All-commits
all-commits at lists.llvm.org
Mon Feb 27 03:26:33 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a18ce47a3e0065d0a26b370a73440411b76d8493
https://github.com/llvm/llvm-project/commit/a18ce47a3e0065d0a26b370a73440411b76d8493
Author: Max Kazantsev <mkazantsev at azul.com>
Date: 2023-02-27 (Mon, 27 Feb 2023)
Changed paths:
M llvm/lib/Transforms/Scalar/LoopPredication.cpp
M llvm/test/Transforms/LoopPredication/pr61022.ll
Log Message:
-----------
[LoopPredication] Account for critical edges when inserting assumes. PR26496
Loop predication can insert assumes to preserve knowledge about some facts that
may otherwise be lost, because loop predication is a lossy transform. When a guard
is represented as branch by widenable condition, it should insert it in the guarded
block. However, if the guarded block has other predecessors than the guard block,
then the condition might not dominate it. Currently we generate invalid code here.
One possible fix here is to split critical edge and insert the assume there, but in
this case we should modify CFG, which Loop Predication is not currently doing, and we
want to keep it that way.
The fix is to handle this case by inserting a Phi which takes `Cond` as input from the
guard block and `true` from any other blocks. This is valid in terms of IR and does
not introduce any new knowledge if we came from another block.
Differential Revision: https://reviews.llvm.org/D144859
Reviewed By: nikic, skatkov
More information about the All-commits
mailing list