[LAA] Rework overflow checking in getPtrStride [nfc]
authorPhilip Reames <preames@rivosinc.com>
Mon, 1 May 2023 17:16:32 +0000 (10:16 -0700)
committerPhilip Reames <listmail@philipreames.com>
Mon, 1 May 2023 17:21:02 +0000 (10:21 -0700)
commit4343534a670f74e87841c0ca03d3189b72c04b1d
tree33cec847e0a34106dc3d64532fa26bf7e6b9bba2
parentd38d6ca1798b339a8d292e91f8e0708c334769ff
[LAA] Rework overflow checking in getPtrStride [nfc]

The previous code structure and comments were exceedingly confusing.  I have multiple times looked at this code and suspected a bug.  This time, I decided to take the time to reflow the code and comment out why it is correct.

The only suspect (to me) case left is that an underaligned access with a unit stride (in terms of the access type) might miss the undefined null pointer when wrapping.  This is unlikely to be an issue for C/C++ code with real page sizes, so I'm not bothering to fully convince myself whether that case is correct or not.
llvm/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp