Let EarlyCSE fold equivalent freeze instructions
authorJuneyoung Lee <aqjune@gmail.com>
Fri, 28 Feb 2020 09:47:57 +0000 (18:47 +0900)
committerJuneyoung Lee <aqjune@gmail.com>
Fri, 28 Feb 2020 11:35:20 +0000 (20:35 +0900)
commitcc28a754679a2c85625e719944154fe82491f008
tree7eeb5d80e174b434cc3aece4ec6049a2093a281a
parent6b035b607f5f5e4db6f1ca51340d7a87b5807a0c
Let EarlyCSE fold equivalent freeze instructions

Summary:
This patch makes EarlyCSE fold equivalent freeze instructions.

Another optimization that I think will be useful is to remove freeze if its operand is used as a branch condition or at llvm.assume:

```
  %c = ...
  br i1 %c, label %A, ..
A:
  %d = freeze %c ; %d can be optimized to %c because %c cannot be poison or undef (or 'br %c' would be UB otherwise)
```

If it make sense for EarlyCSE to support this as well, I will make a patch for this.

Reviewers: spatel, reames, lebedev.ri

Reviewed By: lebedev.ri

Subscribers: lebedev.ri, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75334
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/test/Transforms/EarlyCSE/basic.ll