Skip to content

Commit

Permalink
[GlobalOpt] Add test for SRA with i8 array type (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jan 14, 2022
1 parent 8dbc6a2 commit be21932
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions llvm/test/Transforms/GlobalOpt/globalsra-generic-type.ll
@@ -0,0 +1,33 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -globalopt < %s | FileCheck %s

@g = internal global [8 x i8] undef

define void @test() {
; CHECK-LABEL: @test(
; CHECK-NEXT: store i32 1, i32* bitcast ([8 x i8]* @g to i32*), align 4
; CHECK-NEXT: store i32 2, i32* getelementptr (i32, i32* bitcast ([8 x i8]* @g to i32*), i64 1), align 4
; CHECK-NEXT: ret void
;
store i32 1, i32* bitcast ([8 x i8]* @g to i32*)
store i32 2, i32* getelementptr (i32, i32* bitcast ([8 x i8]* @g to i32*), i64 1)
ret void
}

define i32 @load1() {
; CHECK-LABEL: @load1(
; CHECK-NEXT: [[V:%.*]] = load i32, i32* bitcast ([8 x i8]* @g to i32*), align 4
; CHECK-NEXT: ret i32 [[V]]
;
%v = load i32, i32* bitcast ([8 x i8]* @g to i32*)
ret i32 %v
}

define i32 @load2() {
; CHECK-LABEL: @load2(
; CHECK-NEXT: [[V:%.*]] = load i32, i32* getelementptr (i32, i32* bitcast ([8 x i8]* @g to i32*), i64 1), align 4
; CHECK-NEXT: ret i32 [[V]]
;
%v = load i32, i32* getelementptr (i32, i32* bitcast ([8 x i8]* @g to i32*), i64 1)
ret i32 %v
}

0 comments on commit be21932

Please sign in to comment.