[all-commits] [llvm/llvm-project] 1a5f4c: [InstCombine] Add optimization to prevent poison f...

Hyeongyu Kim via All-commits all-commits at lists.llvm.org
Sat Jul 10 20:41:28 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1a5f4cbe1bd62e6624cbb77dad0d363addd1b324
      https://github.com/llvm/llvm-project/commit/1a5f4cbe1bd62e6624cbb77dad0d363addd1b324
  Author: hyeongyu kim <gusrb406 at snu.ac.kr>
  Date:   2021-07-11 (Sun, 11 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/freeze.ll

  Log Message:
  -----------
  [InstCombine] Add optimization to prevent poison from being propagated.

In D104569, Freeze was inserted just before br to solve the `branching on undef` miscompilation problem.
But value analysis was being disturbed by added freeze.

```
v = load ptr
cond = freeze(icmp (and v, const), const')
br cond, ...
```
The case in which value analysis disturbed is as above.
By changing freeze to add immediately after load, value analysis will be successful again.

```
v = load ptr
freeze(icmp (and v, const), const')
=>
v = load ptr
v' = freeze v
icmp (and v', const), const'
```
In this patch, I propose the above optimization.
With this patch, the poison will not spread as the freeze is performed early.

Reviewed By: nikic, lebedev.ri

Differential Revision: https://reviews.llvm.org/D105392




More information about the All-commits mailing list