[PATCH] D105216: [ScalarEvolution] Fix overflow in computeBECount.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 13 13:46:24 PDT 2021


reames added a comment.

Eli, I think I just had an "aha!" moment.  Check my reasoning here, but I think we can greatly simplify the patch structure.

The most recent case you added, appears to simply be a specialization of ceiling(max(A,B)-A, C) where max(A,B) > A - C is known.    I don't think we actually need to know anything about where A, B, and C come from for your lowering to be valid.  I think we can also generalize this slightly into two pieces:

1. A general ceiling lowering when ceiling(X-A, C) where X > A - C
2. A pushdown rule for max(X,Y) > Z as X > Z && Y > Z ==> max(X,Y) > Z

This really tempts me to go back to the first version of your patch, and add another specialization of how to generate a faster ceiling.

What do you think?



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:11734
+      RHSGEStart = true;
+    } else if (isLoopEntryGuardedByCond(
+                   L, CondGT, OrigRHS,
----------------
I split off this part of the change into 087310c71e with a bit of restructuring.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105216



More information about the llvm-commits mailing list