[all-commits] [llvm/llvm-project] 29d054: [SimplifyCFG] Preserve knowledge about guarding co...

Max Kazantsev via All-commits all-commits at lists.llvm.org
Wed Sep 8 00:06:27 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29d054bf126870706f909a821895770bd9af42b3
      https://github.com/llvm/llvm-project/commit/29d054bf126870706f909a821895770bd9af42b3
  Author: Max Kazantsev <mkazantsev at azul.com>
  Date:   2021-09-08 (Wed, 08 Sep 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/SimplifyCFG/tautological-conditional-branch.ll

  Log Message:
  -----------
  [SimplifyCFG] Preserve knowledge about guarding condition by adding assume

This improvement adds "assume" after removal of branch basing on UB in successor block.

Consider the following example:

```
pred:
  x = ...
  cond = x > 10
  br cond, bb, other.succ

bb:
  phi [nullptr, pred], ... // other possible preds
  load(phi) // UB if we came from pred

other.succ:
  // here we know that x <= 10, but this knowledge is lost
  // after the branch is turned to unconditional unless we
  // preserve it with assume.
```

If we remove the branch basing on knowledge about UB in a successor block,
then the fact that x <= 10 is other.succ might be lost if this condition is
not inferrable from any dominating condition. To preserve this knowledge, we
can add assume intrinsic with (possibly inverted) branch condition.

Patch by Dmitry Bakunevich!

Differential Revision: https://reviews.llvm.org/D109054
Reviewed By: lebedev.ri




More information about the All-commits mailing list