1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
; RUN: opt -S -passes=gvn < %s | FileCheck %s
declare void @capture(ptr)
declare void @some_call()
define i32 @test_call_before_capture(ptr %p) {
; CHECK-LABEL: define i32 @test_call_before_capture(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
; CHECK-NEXT: store i32 123, ptr [[A]], align 4
; CHECK-NEXT: call void @some_call()
; CHECK-NEXT: call void @capture(ptr [[A]])
; CHECK-NEXT: ret i32 123
;
%a = alloca i32
store i32 123, ptr %a
call void @some_call()
%v = load i32, ptr %a
call void @capture(ptr %a)
ret i32 %v
}
define i32 @test_call_after_capture(ptr %p) {
; CHECK-LABEL: define i32 @test_call_after_capture(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
; CHECK-NEXT: store i32 123, ptr [[A]], align 4
; CHECK-NEXT: call void @capture(ptr [[A]])
; CHECK-NEXT: call void @some_call()
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[A]], align 4
; CHECK-NEXT: ret i32 [[V]]
;
%a = alloca i32
store i32 123, ptr %a
call void @capture(ptr %a)
call void @some_call()
%v = load i32, ptr %a
ret i32 %v
}
define i32 @test_store_before_capture(ptr %p) {
; CHECK-LABEL: define i32 @test_store_before_capture(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
; CHECK-NEXT: store i32 123, ptr [[A]], align 4
; CHECK-NEXT: [[P2:%.*]] = load ptr, ptr [[P]], align 8
; CHECK-NEXT: store i32 42, ptr [[P2]], align 4
; CHECK-NEXT: call void @capture(ptr [[A]])
; CHECK-NEXT: ret i32 123
;
%a = alloca i32
store i32 123, ptr %a
%p2 = load ptr, ptr %p
store i32 42, ptr %p2
%v = load i32, ptr %a
call void @capture(ptr %a)
ret i32 %v
}
define i32 @test_store_after_capture(ptr %p) {
; CHECK-LABEL: define i32 @test_store_after_capture(
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
; CHECK-NEXT: store i32 123, ptr [[A]], align 4
; CHECK-NEXT: call void @capture(ptr [[A]])
; CHECK-NEXT: [[P2:%.*]] = load ptr, ptr [[P]], align 8
; CHECK-NEXT: store i32 42, ptr [[P2]], align 4
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[A]], align 4
; CHECK-NEXT: ret i32 [[V]]
;
%a = alloca i32
store i32 123, ptr %a
call void @capture(ptr %a)
%p2 = load ptr, ptr %p
store i32 42, ptr %p2
%v = load i32, ptr %a
ret i32 %v
}
|