[PATCH] D139109: [LoopUnswitch] Perform loop unswitching on select instructions

Sergei Kachkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 05:59:11 PST 2022


kachkov98 added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:3104
+  if (auto *SI = dyn_cast<SelectInst>(Best.TI))
+    Best.TI = turnSelectIntoBranch(SI, DT, LI, MSSAU);
+  else if (isGuard(Best.TI))
----------------
mkazantsev wrote:
> It is not an equivalent transform in sense of UB. If the condition was posion, then select by this condition is also poison. If you turn it into a branch, branch by poisoned condition is immediate UB. How do you account for that?
Accidentionally it was correct in some tests, because unswitchNontrivialInvariants() inserts freeze for branch conditions if the branch is not guaranteed to execute at least once in loop body; for other loops it will not work, so now we insert freeze of select condition explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139109



More information about the llvm-commits mailing list