[PATCH] D98058: [InstCombine] Simplify phis with incoming pointer-casts.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 08:56:27 PST 2021


lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

LGTM, thank you.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1326-1327
+    // stripping pointer casts.
+    SmallPtrSet<Value *, 4> KnownEqual;
+    KnownEqual.insert(IV0);
+    if (IV0 != IV0Stripped &&
----------------
I'm being super nitpicky, but i'd suggest `s/KnownEqual/CheckedIVs/`


================
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();
+        })) {
----------------
fhahn wrote:
> 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?
This seems fine, thanks.
This is mostly to avoid worst-case scenarios with switches.


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