[PATCH] D106041: [WIP][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
Wed Aug 11 14:35:16 PDT 2021


hyeongyukim updated this revision to Diff 365856.
hyeongyukim added a comment.

While checking the performance regression caused by this patch, I found the following issue:

    Cond.fr = freeze(Cond)
    br Cond.fr, BB_True, BB_False
  BB_True:
    use(Cond.fr)			; Cond.fr is not replaced to true
    ...
  BB_False:
    use(Cond.fr)			; Cond.fr is not repalced to false
    ...

In Original LoopUnswitch, we check the use of invariants and replace them if they are dominated by `LoopPH` or `ClonedPH.`
But while fixing LoopUnswitch, I inserted freeze to `Cond`(which is invariant) and replaced all original uses of `Cond` to `Cond.fr.`
Not only `Cond` but also `Cond.fr` is invariant, but the current implementation doesn't know that `Cond.fr` is invariant.
I added a code and test code(`test1_freeze`) that tells that Cond and Cond.fr are both invariants.


Repository:
  rG LLVM Github Monorepo

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

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
  llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106041.365856.patch
Type: text/x-patch
Size: 14193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210811/d7d6a1b8/attachment.bin>


More information about the llvm-commits mailing list