[Value][InstCombine] Fix one-use checks in PHI-of-op -> Op-of-PHI[s] transforms to...
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 26 Aug 2020 14:06:03 +0000 (17:06 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 26 Aug 2020 17:20:41 +0000 (20:20 +0300)
commit95848ea101274b8bd774c63bad55f21a08080705
treea2c6a519a7a0d9bfb3a8ca94ac581e7f334bb762
parentc07a430bd39cccb64712ddcba85254a5bb1cd89b
[Value][InstCombine] Fix one-use checks in PHI-of-op -> Op-of-PHI[s] transforms to be one-user checks

As FIXME said, they really should be checking for a single user,
not use, so let's do that. It is not *that* unusual to have
the same value as incoming value in a PHI node, not unlike
how a PHI may have the same incoming basic block more than once.

There isn't a nice way to do that, Value::users() isn't uniqified,
and Value only tracks it's uses, not Users, so the check is
potentially costly since it does indeed potentially involes
traversing the entire use list of a value.
llvm/include/llvm/IR/Value.h
llvm/lib/IR/Value.cpp
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll
llvm/test/Transforms/InstCombine/phi-of-extractvalues.ll
llvm/test/Transforms/InstCombine/phi-of-insertvalues.ll
llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
llvm/test/Transforms/PGOProfile/chr.ll