1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
4 ; Don't constant-propagate byval pointers, since they are not pointers!
7 %struct.MYstr = type { i8, i32 }
8 @mystr = internal global %struct.MYstr zeroinitializer ; <ptr> [#uses=3]
9 define internal void @vfu1(ptr byval(%struct.MYstr) align 4 %u) nounwind {
12 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr [[STRUCT_MYSTR:%.*]], ptr [[U:%.*]], i32 0, i32 1
13 ; CHECK-NEXT: store i32 99, ptr [[TMP0]], align 4
14 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr [[STRUCT_MYSTR]], ptr [[U]], i32 0, i32 0
15 ; CHECK-NEXT: store i8 97, ptr [[TMP1]], align 4
16 ; CHECK-NEXT: br label [[RETURN:%.*]]
18 ; CHECK-NEXT: ret void
21 %0 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 1 ; <ptr> [#uses=1]
22 store i32 99, ptr %0, align 4
23 %1 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 0 ; <ptr> [#uses=1]
24 store i8 97, ptr %1, align 4
27 return: ; preds = %entry
31 define internal i32 @vfu2(ptr byval(%struct.MYstr) align 4 %u) nounwind readonly {
34 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr getelementptr inbounds ([[STRUCT_MYSTR:%.*]], ptr @mystr, i64 0, i32 1), align 4
35 ; CHECK-NEXT: [[TMP1:%.*]] = load i8, ptr @mystr, align 1
36 ; CHECK-NEXT: [[TMP2:%.*]] = zext i8 [[TMP1]] to i32
37 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], [[TMP0]]
38 ; CHECK-NEXT: ret i32 [[TMP3]]
41 %0 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 1 ; <ptr> [#uses=1]
43 %2 = getelementptr %struct.MYstr, ptr %u, i32 0, i32 0 ; <ptr> [#uses=1]
45 %4 = zext i8 %3 to i32
50 define i32 @unions() nounwind {
51 ; CHECK-LABEL: @unions(
53 ; CHECK-NEXT: call void @vfu1(ptr byval([[STRUCT_MYSTR:%.*]]) align 4 @mystr) #[[ATTR0:[0-9]+]]
54 ; CHECK-NEXT: [[RESULT:%.*]] = call i32 @vfu2(ptr byval([[STRUCT_MYSTR]]) align 4 @mystr) #[[ATTR0]]
55 ; CHECK-NEXT: ret i32 [[RESULT]]
58 call void @vfu1(ptr byval(%struct.MYstr) align 4 @mystr) nounwind
59 %result = call i32 @vfu2(ptr byval(%struct.MYstr) align 4 @mystr) nounwind