[InstCombine] add support for multi-use Y of (X op Y) op Z --> (Y op Z) op X
authorChenbing Zheng <Chenbing.Zheng@streamcomputing.com>
Wed, 31 Aug 2022 02:49:58 +0000 (10:49 +0800)
committerChenbing Zheng <Chenbing.Zheng@streamcomputing.com>
Wed, 31 Aug 2022 02:55:05 +0000 (10:55 +0800)
commit35a3048c2501f7e1de4f662ed402a37f4822feec
tree292a2c68e9545ea37af8486188304d35a98624ec
parentc059ede28ea8faf0540cedad74bc5698ec59e744
[InstCombine] add support for multi-use Y of (X op Y) op Z --> (Y op Z) op X

For (X op Y) op Z --> (Y op Z) op X
we can still do transform when Y is multi-use. In D131356 limit it to one-use,
this patch remove this limit.

This is still not a complete solution, I add a todo test to show it.
In this case, X and Y are both multi use, we can't differentiate how to convert based on this.
But at least we don't make the code worse,and it can solve half the scenarios.
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and-or-not.ll