1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -O3 -S < %s | FileCheck %s
3 ; RUN: opt -passes='default<O3>' -S < %s | FileCheck %s
5 define void @foo(i1 %which, i32 %a, i32 %b, ptr %result) {
8 ; CHECK-NEXT: [[TMP0:%.*]] = sub i32 0, [[B:%.*]]
9 ; CHECK-NEXT: [[Z_V_P:%.*]] = select i1 [[WHICH:%.*]], i32 [[B]], i32 [[TMP0]]
10 ; CHECK-NEXT: [[Z_V:%.*]] = add i32 [[Z_V_P]], [[A:%.*]]
11 ; CHECK-NEXT: [[Z:%.*]] = zext i32 [[Z_V]] to i64
12 ; CHECK-NEXT: [[C:%.*]] = load i64, ptr [[RESULT:%.*]], align 4
13 ; CHECK-NEXT: [[VALUE:%.*]] = add i64 [[C]], [[Z]]
14 ; CHECK-NEXT: store i64 [[VALUE]], ptr [[RESULT]], align 4
15 ; CHECK-NEXT: ret void
19 %x2 = zext i32 %x to i64
20 br i1 %which, label %final, label %delay
24 %y2 = zext i32 %y to i64
28 %z = phi i64 [ %x2, %entry ], [ %y2, %delay ]
29 %c = load i64, ptr %result
30 %value = add i64 %z, %c
31 store i64 %value, ptr %result
35 define void @bar(i1 %which, i32 %a, i32 %b, ptr %result) {
38 ; CHECK-NEXT: [[TMP0:%.*]] = sub i32 0, [[B:%.*]]
39 ; CHECK-NEXT: [[SPEC_SELECT_P:%.*]] = select i1 [[WHICH:%.*]], i32 [[B]], i32 [[TMP0]]
40 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = add i32 [[SPEC_SELECT_P]], [[A:%.*]]
41 ; CHECK-NEXT: [[Z2:%.*]] = zext i32 [[SPEC_SELECT]] to i64
42 ; CHECK-NEXT: [[C:%.*]] = load i64, ptr [[RESULT:%.*]], align 4
43 ; CHECK-NEXT: [[VALUE:%.*]] = add i64 [[C]], [[Z2]]
44 ; CHECK-NEXT: store i64 [[VALUE]], ptr [[RESULT]], align 4
45 ; CHECK-NEXT: ret void
49 br i1 %which, label %final, label %delay
56 %z = phi i32 [ %x, %entry ], [ %y, %delay ]
57 %z2 = zext i32 %z to i64
58 %c = load i64, ptr %result
59 %value = add i64 %z2, %c
60 store i64 %value, ptr %result
64 define void @foo_opt(i1 %which, i32 %a, i32 %b, ptr nocapture %result) {
65 ; CHECK-LABEL: @foo_opt(
67 ; CHECK-NEXT: [[TMP0:%.*]] = sub i32 0, [[B:%.*]]
68 ; CHECK-NEXT: [[Z_V_P:%.*]] = select i1 [[WHICH:%.*]], i32 [[B]], i32 [[TMP0]]
69 ; CHECK-NEXT: [[Z_V:%.*]] = add i32 [[Z_V_P]], [[A:%.*]]
70 ; CHECK-NEXT: [[Z:%.*]] = zext i32 [[Z_V]] to i64
71 ; CHECK-NEXT: [[C:%.*]] = load i64, ptr [[RESULT:%.*]], align 4
72 ; CHECK-NEXT: [[VALUE:%.*]] = add i64 [[C]], [[Z]]
73 ; CHECK-NEXT: store i64 [[VALUE]], ptr [[RESULT]], align 4
74 ; CHECK-NEXT: ret void
78 %z.v.p = select i1 %which, i32 %b, i32 %0
79 %z.v = add i32 %z.v.p, %a
80 %z = zext i32 %z.v to i64
81 %c = load i64, ptr %result, align 4
82 %value = add i64 %c, %z
83 store i64 %value, ptr %result, align 4