1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
4 ;; This function returns its second argument on all return statements
5 define internal ptr @incdec(i1 %C, ptr %V) {
6 ; CHECK-LABEL: @incdec(
7 ; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[V:%.*]], align 4
8 ; CHECK-NEXT: br i1 [[C:%.*]], label [[T:%.*]], label [[F:%.*]]
10 ; CHECK-NEXT: [[X1:%.*]] = add i32 [[X]], 1
11 ; CHECK-NEXT: store i32 [[X1]], ptr [[V]], align 4
12 ; CHECK-NEXT: ret ptr [[V]]
14 ; CHECK-NEXT: [[X2:%.*]] = sub i32 [[X]], 1
15 ; CHECK-NEXT: store i32 [[X2]], ptr [[V]], align 4
16 ; CHECK-NEXT: ret ptr [[V]]
19 br i1 %C, label %T, label %F
32 ;; This function returns its first argument as a part of a multiple return
34 define internal { i32, i32 } @foo(i32 %A, i32 %B) {
36 ; CHECK-NEXT: [[X:%.*]] = add nuw nsw i32 [[A:%.*]], [[B:%.*]]
37 ; CHECK-NEXT: [[Y:%.*]] = insertvalue { i32, i32 } undef, i32 [[A]], 0
38 ; CHECK-NEXT: [[Z:%.*]] = insertvalue { i32, i32 } [[Y]], i32 [[X]], 1
39 ; CHECK-NEXT: ret { i32, i32 } [[Z]]
42 %Y = insertvalue { i32, i32 } undef, i32 %A, 0
43 %Z = insertvalue { i32, i32 } %Y, i32 %X, 1
47 define void @caller(i1 %C) personality ptr @__gxx_personality_v0 {
48 ; CHECK-LABEL: @caller(
49 ; CHECK-NEXT: [[Q:%.*]] = alloca i32, align 4
50 ; CHECK-NEXT: [[W:%.*]] = call ptr @incdec(i1 [[C:%.*]], ptr [[Q]])
51 ; CHECK-NEXT: [[S1:%.*]] = call { i32, i32 } @foo(i32 1, i32 2)
52 ; CHECK-NEXT: [[X1:%.*]] = extractvalue { i32, i32 } [[S1]], 0
53 ; CHECK-NEXT: [[S2:%.*]] = invoke { i32, i32 } @foo(i32 3, i32 4)
54 ; CHECK-NEXT: to label [[OK:%.*]] unwind label [[LPAD:%.*]]
56 ; CHECK-NEXT: [[X2:%.*]] = extractvalue { i32, i32 } [[S2]], 0
57 ; CHECK-NEXT: [[Z:%.*]] = add nuw nsw i32 [[X1]], [[X2]]
58 ; CHECK-NEXT: store i32 [[Z]], ptr [[W]], align 4
59 ; CHECK-NEXT: br label [[RET:%.*]]
61 ; CHECK-NEXT: [[EXN:%.*]] = landingpad { ptr, i32 }
63 ; CHECK-NEXT: br label [[RET]]
65 ; CHECK-NEXT: ret void
68 ;; Call incdec to see if %W is properly replaced by %Q
69 %W = call ptr @incdec(i1 %C, ptr %Q ) ; <i32> [#uses=1]
70 ;; Call @foo twice, to prevent the arguments from propagating into the
71 ;; function (so we can check the returned argument is properly
72 ;; propagated per-caller).
73 %S1 = call { i32, i32 } @foo(i32 1, i32 2)
74 %X1 = extractvalue { i32, i32 } %S1, 0
75 %S2 = invoke { i32, i32 } @foo(i32 3, i32 4) to label %OK unwind label %LPAD
78 %X2 = extractvalue { i32, i32 } %S2, 0
79 ;; Do some stuff with the returned values which we can grep for
85 %exn = landingpad {ptr, i32}
93 declare i32 @__gxx_personality_v0(...)