Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / volatile.cpp
blob38724659ad8a3557cad7ad6b44e4f6cdfbeb5649
1 // RUN: %clang_cc1 -O2 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK
2 struct agg
4 int a ;
5 int b ;
6 } t;
7 struct agg a;
8 int vt=10;
9 _Complex float cf;
10 int volatile vol =10;
11 void f0() {
12 const_cast<volatile _Complex float &>(cf) = const_cast<volatile _Complex float&>(cf) + 1;
13 // CHECK: %cf.real = load volatile float, ptr @cf
14 // CHECK: %cf.imag = load volatile float, ptr getelementptr
15 // CHECK: %add.r = fadd float %cf.real, 1.000000e+00
16 // CHECK: %add.i = fadd float %cf.imag, 0.000000e+00
17 // CHECK: store volatile float %add.r
18 // CHECK: store volatile float %add.i, ptr getelementptr
19 static_cast<volatile _Complex float &>(cf) = static_cast<volatile _Complex float&>(cf) + 1;
20 // CHECK: %cf.real1 = load volatile float, ptr @cf
21 // CHECK: %cf.imag2 = load volatile float, ptr getelementptr
22 // CHECK: %add.r3 = fadd float %cf.real1, 1.000000e+00
23 // CHECK: %add.i4 = fadd float %cf.imag2, 0.000000e+00
24 // CHECK: store volatile float %add.r3, ptr @cf
25 // CHECK: store volatile float %add.i4, ptr getelementptr
26 const_cast<volatile int &>(a.a) = const_cast<volatile int &>(t.a) ;
27 // CHECK: %0 = load volatile i32, ptr @t
28 // CHECK: store volatile i32 %0, ptr @a
29 static_cast<volatile int &>(a.b) = static_cast<volatile int &>(t.a) ;
30 // CHECK: %1 = load volatile i32, ptr @t
31 // CHECK: store volatile i32 %1, ptr getelementptr
32 const_cast<volatile int&>(vt) = const_cast<volatile int&>(vt) + 1;
33 // CHECK: %2 = load volatile i32, ptr @vt
34 // CHECK: %add = add nsw i32 %2, 1
35 // CHECK: store volatile i32 %add, ptr @vt
36 static_cast<volatile int&>(vt) = static_cast<volatile int&>(vt) + 1;
37 // CHECK: %3 = load volatile i32, ptr @vt
38 // CHECK: %add5 = add nsw i32 %3, 1
39 // CHECK: store volatile i32 %add5, ptr @vt
40 vt = const_cast<int&>(vol);
41 // %4 = load i32, ptr @vol
42 // store i32 %4, ptr @vt