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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 19 10:39:06 PDT 2021


MaskRay accepted this revision.
MaskRay added a comment.

Looks great!



================
Comment at: llvm/test/Transforms/GlobalOpt/globalsra-align.ll:55
   ret i32* %x
 }
----------------
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
}
```


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

https://reviews.llvm.org/D102552



More information about the llvm-commits mailing list