[PATCH] D105216: [ScalarEvolution] Fix overflow in computeBECount.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 11:17:50 PDT 2021
efriedma created this revision.
efriedma added reviewers: reames, mkazantsev, fhahn, nikic.
Herald added a subscriber: hiraditya.
efriedma requested review of this revision.
Herald added a project: LLVM.
There are two issues with the current implementation of computeBECount:
1. It doesn't account for the possibility that adding "Stride - 1" to Delta might overflow. For almost all loops, it doesn't, but it's not actually proven anywhere.
2. It doesn't account for the possibility that Stride is zero. Granted, that would be a weird "loop", but nothing is actually preventing it.
To deal with this, add two new checks:
1. Use a variety of tricks to try to prove that the addition doesn't overflow. If the proof is impossible, use an alternate sequence which never overflows.
2. Use umin(Stride, 1) to handle the possibility that Stride is zero.
This is, unfortunately, a lot of code to handle a couple really obscure edge cases. Suggestions welcome.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105216
Files:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105216.355634.patch
Type: text/x-patch
Size: 13177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210630/fe1769b2/attachment.bin>
More information about the llvm-commits
mailing list