Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / cxx1z-init-statement.cpp
blob7604541cbbd923aeed30908e1eb51db6e685e995
1 // RUN: %clang_cc1 -std=c++1z -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s -w | FileCheck %s
3 typedef int T;
4 void f() {
5 // CHECK: %[[A:.*]] = alloca i32, align 4
6 // CHECK-NEXT: store i32 5, ptr %[[A]], align 4
7 // CHECK-NEXT: %[[B:.*]] = load i32, ptr %[[A]], align 4
8 // CHECK-NEXT: %[[C:.*]] = icmp slt i32 %[[B]], 8
9 if (int a = 5; a < 8)
13 void f1() {
14 // CHECK: %[[A:.*]] = alloca i32, align 4
15 // CHECK-NEXT: %[[B:.*]] = alloca i32, align 4
16 // CHECK-NEXT: %[[C:.*]] = alloca i32, align 4
17 // CHECK-NEXT: store i32 5, ptr %[[B]], align 4
18 // CHECK-NEXT: store i32 7, ptr %[[C]], align 4
19 if (int a, b = 5; int c = 7)
23 int f2() {
24 // CHECK: %[[A:.*]] = alloca i32, align 4
25 // CHECK-NEXT: %[[B:.*]] = call noundef i32 @_Z2f2v()
26 // CHECK-NEXT: store i32 7, ptr %[[A]], align 4
27 // CHECK-NEXT: %[[C:.*]] = load i32, ptr %[[A]], align 4
28 // CHECK-NEXT: %[[D:.*]] = icmp ne i32 %[[C]], 0
29 if (T{f2()}; int c = 7)
31 return 2;
34 void g() {
35 // CHECK: %[[A:.*]] = alloca i32, align 4
36 // CHECK-NEXT: store i32 5, ptr %[[A]], align 4
37 // CHECK-NEXT: %[[B:.*]] = load i32, ptr %[[A]], align 4
38 // CHECK-NEXT: switch i32 %[[B]], label %[[C:.*]] [
39 switch (int a = 5; a) {
40 case 0:
41 break;
45 void g1() {
46 // CHECK: %[[A:.*]] = alloca i32, align 4
47 // CHECK-NEXT: %[[B:.*]] = alloca i32, align 4
48 // CHECK-NEXT: %[[C:.*]] = alloca i32, align 4
49 // CHECK-NEXT: store i32 5, ptr %[[B]], align 4
50 // CHECK-NEXT: store i32 7, ptr %[[C]], align 4
51 // CHECK-NEXT: %[[D:.*]] = load i32, ptr %[[C]], align 4
52 // CHECK-NEXT: switch i32 %[[D]], label %[[E:.*]] [
53 switch (int a, b = 5; int c = 7) {
54 case 0:
55 break;
59 int g2() {
60 // CHECK: %[[A:.*]] = alloca i32, align 4
61 // CHECK-NEXT: %[[B:.*]] = call noundef i32 @_Z2f2v()
62 // CHECK-NEXT: store i32 7, ptr %[[A]], align 4
63 // CHECK-NEXT: %[[C:.*]] = load i32, ptr %[[A]], align 4
64 // CHECK-NEXT: switch i32 %[[C]], label %[[E:.*]] [
65 switch (T{f2()}; int c = 7) {
66 case 0:
67 break;
69 return 2;