[all-commits] [llvm/llvm-project] c66476: [AssumeBundles] offset should be added to correctl...
Juneyoung Lee via All-commits
all-commits at lists.llvm.org
Thu Apr 1 20:32:35 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c6647693300be4b74575143db7429f284f3afeb1
https://github.com/llvm/llvm-project/commit/c6647693300be4b74575143db7429f284f3afeb1
Author: Juneyoung Lee <aqjune at gmail.com>
Date: 2021-04-02 (Fri, 02 Apr 2021)
Changed paths:
M llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
M llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
M llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
Log Message:
-----------
[AssumeBundles] offset should be added to correctly calculate align
This is a patch to fix the bug in alignment calculation (see https://reviews.llvm.org/D90529#2619492).
Consider this code:
```
call void @llvm.assume(i1 true) ["align"(i32* %a, i32 32, i32 28)]
%arrayidx = getelementptr inbounds i32, i32* %a, i64 -1
; aligment of %arrayidx?
```
The llvm.assume guarantees that `%a - 28` is 32-bytes aligned, meaning that `%a` is 32k + 28 for some k.
Therefore `a - 4` cannot be 32-bytes aligned but the existing code was calculating the pointer as 32-bytes aligned.
The reason why this happened is as follows.
`DiffSCEV` stores `%arrayidx - %a` which is -4.
`OffSCEV` stores the offset value of “align”, which is 28.
`DiffSCEV` + `OffSCEV` = 24 should be used for `a - 4`'s offset from 32k, but `DiffSCEV` - `OffSCEV` = 32 was being used instead.
Reviewed By: Tyker
Differential Revision: https://reviews.llvm.org/D98759
More information about the All-commits
mailing list