Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / align-avx-complete-objects.cpp
blob38b522b2e7e03430cf4b79fac69f9f42c587f2a8
1 // RUN: %clang_cc1 %std_cxx11-14 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -fmax-type-align=16 -emit-llvm -o - -Werror | FileCheck %s --check-prefixes=CHECK,PRE17
2 // RUN: %clang_cc1 %std_cxx17- %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -fmax-type-align=16 -emit-llvm -o - -Werror | FileCheck %s --check-prefixes=CHECK,CXX17
4 typedef float AVX2Float __attribute__((__vector_size__(32)));
7 #if __cplusplus < 202002L
8 volatile
9 #endif
10 float TestAlign(void)
12 volatile AVX2Float *p = new AVX2Float;
13 *p = *p;
14 AVX2Float r = *p;
15 return r[0];
18 // CHECK: [[R:%.*]] = alloca <8 x float>, align 32
19 // PRE17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32)
20 // CXX17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
21 // CHECK-NEXT: store ptr [[CALL]], ptr [[P:%.*]], align 8
22 // CHECK-NEXT: [[ONE:%.*]] = load ptr, ptr [[P]], align 8
23 // CHECK-NEXT: [[TWO:%.*]] = load volatile <8 x float>, ptr [[ONE]], align 16
24 // CHECK-NEXT: [[THREE:%.*]] = load ptr, ptr [[P]], align 8
25 // CHECK-NEXT: store volatile <8 x float> [[TWO]], ptr [[THREE]], align 16
26 // CHECK-NEXT: [[FOUR:%.*]] = load ptr, ptr [[P]], align 8
27 // CHECK-NEXT: [[FIVE:%.*]] = load volatile <8 x float>, ptr [[FOUR]], align 16
28 // CHECK-NEXT: store <8 x float> [[FIVE]], ptr [[R]], align 32
29 // CHECK-NEXT: [[SIX:%.*]] = load <8 x float>, ptr [[R]], align 32
30 // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <8 x float> [[SIX]], i32 0
31 // CHECK-NEXT: ret float [[VECEXT]]
33 typedef float AVX2Float_Explicitly_aligned __attribute__((__vector_size__(32))) __attribute__((aligned (32)));
35 typedef AVX2Float_Explicitly_aligned AVX2Float_indirect;
37 typedef AVX2Float_indirect AVX2Float_use_existing_align;
39 #if __cplusplus < 202002L
40 volatile
41 #endif
42 float TestAlign2(void)
44 volatile AVX2Float_use_existing_align *p = new AVX2Float_use_existing_align;
45 *p = *p;
46 AVX2Float_use_existing_align r = *p;
47 return r[0];
50 // CHECK: [[R:%.*]] = alloca <8 x float>, align 32
51 // PRE17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32)
52 // CXX17-NEXT: [[CALL:%.*]] = call noalias noundef nonnull align 32 ptr @_ZnwmSt11align_val_t(i64 noundef 32, i64 noundef 32)
53 // CHECK-NEXT: store ptr [[CALL]], ptr [[P:%.*]], align 8
54 // CHECK-NEXT: [[ONE:%.*]] = load ptr, ptr [[P]], align 8
55 // CHECK-NEXT: [[TWO:%.*]] = load volatile <8 x float>, ptr [[ONE]], align 32
56 // CHECK-NEXT: [[THREE:%.*]] = load ptr, ptr [[P]], align 8
57 // CHECK-NEXT: store volatile <8 x float> [[TWO]], ptr [[THREE]], align 32
58 // CHECK-NEXT: [[FOUR:%.*]] = load ptr, ptr [[P]], align 8
59 // CHECK-NEXT: [[FIVE:%.*]] = load volatile <8 x float>, ptr [[FOUR]], align 32
60 // CHECK-NEXT: store <8 x float> [[FIVE]], ptr [[R]], align 32
61 // CHECK-NEXT: [[SIX:%.*]] = load <8 x float>, ptr [[R]], align 32
62 // CHECK-NEXT: [[VECEXT:%.*]] = extractelement <8 x float> [[SIX]], i32 0
63 // CHECK-NEXT: ret float [[VECEXT]]