[InstCombine] Add freezeAllUsesOfArgument to visitFreeze
authorhyeongyu kim <gusrb406@snu.ac.kr>
Sat, 24 Jul 2021 09:06:21 +0000 (18:06 +0900)
committerhyeongyu kim <gusrb406@snu.ac.kr>
Sat, 24 Jul 2021 09:08:58 +0000 (18:08 +0900)
commitaca5aeb7523d7868a4b0706330dcdfc58c0adaed
tree423d7f18857ec51b4137c30463a118f6ca946fc1
parent228bea6a36cd0eb3b7f80d18bce9f8d5a1a69c95
[InstCombine] Add freezeAllUsesOfArgument to visitFreeze

In D106041, a freeze was added before the branch condition to solve the miscompilation problem of SimpleLoopUnswitch.
However, I found that the added freeze disturbed other optimizations in the following situations.
```
arg.fr = freeze(arg)
use(arg.fr)
...
use(arg)
```
It is a problem that occurred when arg and arg.fr were recognized as different values.
Therefore, changing to use arg.fr instead of arg throughout the function eliminates the above problem.
Thus, I add a function that changes all uses of arg to freeze(arg) to visitFreeze of InstCombine.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D106233
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/freeze.ll
llvm/test/Transforms/PhaseOrdering/X86/vector-reductions-logical.ll