xref: /llvm-project/llvm/test/Transforms/ArgumentPromotion/bitcasts.ll (revision bcbc6151640f53e9d78392c66de9760c664d8b1d)
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
3
4; Test argument promotion involving bitcasts.
5
6%opaque = type opaque
7
8define internal i32 @callee_basic(ptr %p) {
9; CHECK-LABEL: define {{[^@]+}}@callee_basic
10; CHECK-SAME: (i32 [[P_0_VAL:%.*]], i32 [[P_4_VAL:%.*]]) {
11; CHECK-NEXT:    [[Z:%.*]] = add i32 [[P_0_VAL]], [[P_4_VAL]]
12; CHECK-NEXT:    ret i32 [[Z]]
13;
14  %x = load i32, ptr %p
15  %p1 = getelementptr i8, ptr %p, i64 4
16  %y = load i32, ptr %p1
17  %z = add i32 %x, %y
18  ret i32 %z
19}
20
21define void @caller_basic(ptr %p) {
22; CHECK-LABEL: define {{[^@]+}}@caller_basic
23; CHECK-SAME: (ptr [[P:%.*]]) {
24; CHECK-NEXT:    [[P_VAL:%.*]] = load i32, ptr [[P]], align 4
25; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr i8, ptr [[P]], i64 4
26; CHECK-NEXT:    [[P_VAL1:%.*]] = load i32, ptr [[TMP2]], align 4
27; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @callee_basic(i32 [[P_VAL]], i32 [[P_VAL1]])
28; CHECK-NEXT:    ret void
29;
30  call i32 @callee_basic(ptr %p)
31  ret void
32}
33
34define internal i32 @callee_opaque(ptr %p) {
35; CHECK-LABEL: define {{[^@]+}}@callee_opaque
36; CHECK-SAME: (i32 [[P_0_VAL:%.*]], i32 [[P_4_VAL:%.*]]) {
37; CHECK-NEXT:    [[Z:%.*]] = add i32 [[P_0_VAL]], [[P_4_VAL]]
38; CHECK-NEXT:    ret i32 [[Z]]
39;
40  %x = load i32, ptr %p
41  %p1.32 = getelementptr i32, ptr %p, i64 1
42  %y = load i32, ptr %p1.32
43  %z = add i32 %x, %y
44  ret i32 %z
45}
46
47define void @caller_opaque(ptr %p) {
48; CHECK-LABEL: define {{[^@]+}}@caller_opaque
49; CHECK-SAME: (ptr [[P:%.*]]) {
50; CHECK-NEXT:    [[P_VAL:%.*]] = load i32, ptr [[P]], align 4
51; CHECK-NEXT:    [[TMP3:%.*]] = getelementptr i8, ptr [[P]], i64 4
52; CHECK-NEXT:    [[P_VAL1:%.*]] = load i32, ptr [[TMP3]], align 4
53; CHECK-NEXT:    [[TMP5:%.*]] = call i32 @callee_opaque(i32 [[P_VAL]], i32 [[P_VAL1]])
54; CHECK-NEXT:    ret void
55;
56  call i32 @callee_opaque(ptr %p)
57  ret void
58}
59