1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2 ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
5 ; This test tries to convince CHECK about promoting the load from %A + 2,
6 ; because there is a load of %A in the entry block
7 define internal i32 @callee(i1 %C, ptr %A) {
8 ; CHECK-LABEL: define {{[^@]+}}@callee
9 ; CHECK-SAME: (i1 [[C:%.*]], ptr [[A:%.*]]) {
11 ; CHECK-NEXT: [[A_0:%.*]] = load i32, ptr [[A]], align 4
12 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
14 ; CHECK-NEXT: ret i32 [[A_0]]
16 ; CHECK-NEXT: [[A_2:%.*]] = getelementptr i32, ptr [[A]], i32 2
17 ; CHECK-NEXT: [[R:%.*]] = load i32, ptr [[A_2]], align 4
18 ; CHECK-NEXT: ret i32 [[R]]
21 ; Unconditonally load the element at %A
22 %A.0 = load i32, ptr %A
23 br i1 %C, label %T, label %F
29 ; Load the element at offset two from %A. This should not be promoted!
30 %A.2 = getelementptr i32, ptr %A, i32 2
31 %R = load i32, ptr %A.2
36 ; CHECK-LABEL: define {{[^@]+}}@foo() {
37 ; CHECK-NEXT: [[X:%.*]] = call i32 @callee(i1 false, ptr null)
38 ; CHECK-NEXT: ret i32 [[X]]
40 %X = call i32 @callee(i1 false, ptr null) ; <i32> [#uses=1]