[PATCH] D137632: [LoopPredication] Widen checks if condition operands constant ranges are known

Dmitry Makogon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 07:29:52 PST 2023


dmakogon marked an inline comment as done.
dmakogon added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopPredication.cpp:850
+
+  bool LHSMaxIsGreaterThanRHSMax = LHSMaxValue.ugt(RHSMaxValue);
+  if (IsSigned)
----------------
apilipenko wrote:
> Why do you need to check this?
Well, this is the speculation condition we decided to use. The idea here is the following:
Assume LHS is an index and RHS is array length.
So we'd like to speculate only if the index possible maximum value isn't greater that the array length maximum value.
Otherwise we assume that index would take the value greater than the array length in most cases, so we'd deoptimize.
We don't have exact statistics that such cases prevail, it's just our expectations I guess. Also here we cut off the case when LHS has a full-set range.


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

https://reviews.llvm.org/D137632



More information about the llvm-commits mailing list