[PATCH] D97122: [SCEV] Improve handling of pointer compares involving subtractions (WIP).

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 21:49:37 PST 2021


mkazantsev added a comment.

This logic looks very similar to what `isKnownPredicateViaNoOverflow` does. Is the only difference here is that it supports non-constant operands? Maybe we should improve `isKnownPredicateViaNoOverflow` instead. This looks very narrow-oriented.



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:3117
+  //
+  // (-C1 + X) /u C2 can be transformed to (C1 /u C3) + (X /u C2), if
+  //   * C1 % C2 == 0
----------------
What `C3` stands for? Is it actually `C2`?


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:10976
+                                                  const SCEV *RHS) {
+  // Handle Y - X <= Y, if X s>= 0 and Y >= X. In that case, the result of (Y -
+  // X) will be in [0, Y+1) expression won't wrap in the unsigned sense.
----------------
Please specify that `<=` and `>=` here are actually unsigned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97122



More information about the llvm-commits mailing list