[PATCH] D98058: [InstCombine] Simplify phis with incoming pointer-casts.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 08:46:39 PST 2021
fhahn added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1322-1328
+ Value *Inc0 = PN.getIncomingValue(0);
+ Value *Inc0Stripped = Inc0->stripPointerCasts();
+ if (Inc0 != Inc0Stripped &&
+ all_of(PN.incoming_values(), [Inc0, Inc0Stripped](Value *Inc) {
+ return Inc0 == Inc || Inc0Stripped == Inc->stripPointerCasts();
+ })) {
+ return CastInst::CreatePointerCast(Inc0Stripped, PN.getType());
----------------
lebedev.ri wrote:
> I would recommend `s/Inc/IV/`
Updated all the names
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1325-1327
+ all_of(PN.incoming_values(), [Inc0, Inc0Stripped](Value *Inc) {
+ return Inc0 == Inc || Inc0Stripped == Inc->stripPointerCasts();
+ })) {
----------------
lebedev.ri wrote:
> lebedev.ri wrote:
> > I would recommend a less brute-force approach.
> > Add a map<IV, stripped>, and don't redo the work if the result is known.
> Well, i guess `map` is an overkill, just `set<IV>` should be plenty enough.
Done, although I am not sure how often this will trigger. It will at least for the initial step. Not sure if you had something different in mind?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98058/new/
https://reviews.llvm.org/D98058
More information about the llvm-commits
mailing list