[LoopUnswitch] Simplify branch condition if it is select with constant operands
authorJuneyoung Lee <aqjune@gmail.com>
Tue, 30 Mar 2021 11:03:50 +0000 (20:03 +0900)
committerJuneyoung Lee <aqjune@gmail.com>
Tue, 30 Mar 2021 11:09:42 +0000 (20:09 +0900)
commit6b4b1dc6ec6f0bf0a1bb414fbe751ccab99d41a0
treedb7b19b1def5ecaad74900b9003deb351dd4650a
parentf71ed5dfe280851e30b4c3fb4be559cd17570167
[LoopUnswitch] Simplify branch condition if it is select with constant operands

This fixes the miscompilation reported in https://reviews.llvm.org/rG5bb38e84d3d0#986154 .

`select _, true, false` matches both m_LogicalAnd and m_LogicalOr, making later
transformations confused.
Simplify the branch condition to not have the form.
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll