[PATCH] D104806: [ScalarEvolution] Make getMinusSCEV() fail for unrelated pointers.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 16:27:30 PDT 2021


efriedma added a comment.

> I'd probably still perfect we just special case the non-integral pointers here because I don't see any reason to harm LSR for integral ones,

We could do something different for LSR icmpzero, that's different from what we do with getMinusSCEV in general, for integral pointers.  It's not hard to change, the question is what exactly can we do. These are the possibilities I've thought of:

1. What we do without any changes.  This involves multiplying pointers by -1, which violates the rules laid out in D104498 <https://reviews.llvm.org/D104498>.  This is not something we really to be doing; even with integral pointers, it leads to issues with pointer provenance.
2. What this patch does, don't do icmpzero analysis for pointers with different pointer bases.  The change seem mostly okay.
3. Explicitly ptrtoint icmp operands.  This isn't too hard to implement.  Without any other changes, it produces a different set of diffs, which isn't obviously better.  (The issue here is that "p" and "ptrtoint p" are different SCEV expressions, so LSR heuristics treat them differently.)
4. Explicitly ptrtoint one of the operands of the icmp.  Or a variation, explicitly ptrtoint one of the operands of the icmp if they have different pointer bases.  I think I briefly tried this, but I don't remember the details; I'll experiment a bit more.
5. Explicitly ptrtoint all pointers analyzed by LSR, so the heuristics treat them as equal.  This produces messy results, which are hard to clean up.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104806/new/

https://reviews.llvm.org/D104806



More information about the llvm-commits mailing list