[EarlyCSE] Use m_LogicalAnd/Or matchers to handle branch conditions
authorJuneyoung Lee <aqjune@gmail.com>
Sun, 27 Dec 2020 20:36:26 +0000 (05:36 +0900)
committerJuneyoung Lee <aqjune@gmail.com>
Sun, 27 Dec 2020 20:36:26 +0000 (05:36 +0900)
commitd3f1f7b6bca585b76d40422e8076d59113e3bb80
treedfbd1e977e9d7c90cadc3d6eaf9037a339f700cb
parentf1d648b973d32ab0e70ef20efb0f146240e50f58
[EarlyCSE] Use m_LogicalAnd/Or matchers to handle branch conditions

EarlyCSE's handleBranchCondition says:

```
// If the condition is AND operation, we can propagate its operands into the
// true branch. If it is OR operation, we can propagate them into the false
// branch.
```

This holds for the corresponding select patterns as well.

This is a part of an ongoing work for disabling buggy select->and/or transformations.
See llvm.org/pr48353 and D93065 for more context

Proof:
and: https://alive2.llvm.org/ce/z/MQWodU
or: https://alive2.llvm.org/ce/z/9GLbB_

Reviewed By: nikic

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