[PATCH] D102552: [GlobalOpt] recompute alignments for loads and stores of updated globals

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 20 08:22:44 PDT 2021


spatel added inline comments.


================
Comment at: llvm/test/Transforms/GlobalOpt/globalsra-align.ll:55
   ret i32* %x
 }
----------------
MaskRay wrote:
> Consider adding a load test.
> 
> ```
> define i32* @reduce_align_2(i32* %y) {
> ; CHECK-LABEL: @reduce_align_2(
> ; CHECK-NEXT:    store i32* null, i32** getelementptr inbounds ([7 x i32*], [7 x i32*]* @a.1, i32 0, i64 2), align 8
> ; CHECK-NEXT:    ret i32* null
> ;
>   %x = load i32*, i32** getelementptr inbounds ([2 x [7 x i32*]], [2 x [7 x i32*]]* @a, i64 0, i64 0, i64 0), align 1
>   store i32* %y, i32** getelementptr inbounds ([2 x [7 x i32*]], [2 x [7 x i32*]]* @a, i64 0, i64 1, i64 2), align 4
>   ret i32* %x
> }
> 
> define i32* @reduce_align_3(i32* %y) {
> ; CHECK-LABEL: @reduce_align_3(
> ; CHECK-NEXT:    store i32* null, i32** getelementptr inbounds ([7 x i32*], [7 x i32*]* @a.1, i32 0, i64 3), align 4
> ; CHECK-NEXT:    ret i32* null
> ;
>   %x = load i32*, i32** getelementptr inbounds ([2 x [7 x i32*]], [2 x [7 x i32*]]* @a, i64 0, i64 0, i64 0), align 1
>   store i32* %y, i32** getelementptr inbounds ([2 x [7 x i32*]], [2 x [7 x i32*]]* @a, i64 0, i64 1, i64 3), align 8
>   ret i32* %x
> }
> 
> define i32* @reduce_align_4() {
>   %x = load i32*, i32** getelementptr inbounds ([2 x [7 x i32*]], [2 x [7 x i32*]]* @a, i64 0, i64 0, i64 2), align 1
>   ret i32* %x
> }
> ```
I'll add "externally_initialized" to the global declaration and adjust the tests. The existing tests have loads, but they are all getting folded to null.


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

https://reviews.llvm.org/D102552



More information about the llvm-commits mailing list