[PATCH] D106041: [SimpleLoopUnswitch] Re-fix introduction of UB when hoisted condition may be undef or poison
Hyeongyu Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 15 00:19:02 PDT 2021
hyeongyukim created this revision.
Herald added a subscriber: hiraditya.
hyeongyukim requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
https://bugs.llvm.org/show_bug.cgi?id=27506
https://bugs.llvm.org/show_bug.cgi?id=31652
https://bugs.llvm.org/show_bug.cgi?id=51043
Problems with SimpleLoopUnswitch cause the bug reports above.
while (...) {
if (C) { A }
else { B }
}
Into:
C' = freeze(C)
if (C') {
while (...) { A }
} else {
while (...) { B }
}
This problem can be solved by adding a freeze on hoisted branches(above transform) and has been solved by D29015 <https://reviews.llvm.org/D29015>.
However, D29015 <https://reviews.llvm.org/D29015> is now reverted by performance regression(https://github.com/llvm/llvm-project/commit/2b5a8976514de326bb84f0913d9d451089c11d22)
It is not the first time that an added freeze has caused performance regression.
SimplifyCFG also had a problem with UB caused by branching-on-undef, which was solved by adding freeze to the branching condition. (D104569 <https://reviews.llvm.org/D104569>)
Performance regression occurred in D104569 <https://reviews.llvm.org/D104569>, and patches such as D105344 <https://reviews.llvm.org/D105344> and D105392 <https://reviews.llvm.org/D105392> were written to minimize it.
This patch will correct the SimpleLoopUnswitch as D104569 <https://reviews.llvm.org/D104569> handles the SimplyCFG while minimizing performance loss by introducing patches like D105344 <https://reviews.llvm.org/D105344> and D105392 <https://reviews.llvm.org/D105392>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106041
Files:
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/test/Transforms/SimpleLoopUnswitch/ARM/nontrivial-unswitch-cost.ll
llvm/test/Transforms/SimpleLoopUnswitch/implicit-null-checks.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106041.358852.patch
Type: text/x-patch
Size: 7934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210715/6a6325be/attachment-0001.bin>
More information about the llvm-commits
mailing list