2015-05-22 10:51:49 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86
|
|
|
|
// RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
|
2015-06-23 05:31:43 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -triple x86_64-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
|
2015-08-28 06:24:56 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86
|
|
|
|
// RUN: %clang_cc1 -fopenmp -triple i386-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
|
|
|
|
// RUN: %clang_cc1 -fopenmp -triple i386-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
|
2015-05-22 10:51:49 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC
|
|
|
|
// RUN: %clang_cc1 -fopenmp -triple powerpc64-unknown-unknown -target-abi elfv1-qpx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC-QPX
|
2014-05-22 16:54:05 +08:00
|
|
|
|
2017-12-30 02:07:07 +08:00
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple x86_64-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -target-feature +avx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -target-feature +avx512f -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=X86-AVX512
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -triple powerpc64-unknown-unknown -target-abi elfv1-qpx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=PPC-QPX
|
|
|
|
|
2014-09-30 13:29:28 +08:00
|
|
|
void h1(float *c, float *a, double b[], int size)
|
2014-05-22 16:54:05 +08:00
|
|
|
{
|
|
|
|
// CHECK-LABEL: define void @h1
|
|
|
|
int t = 0;
|
2014-09-30 13:29:28 +08:00
|
|
|
#pragma omp simd safelen(16) linear(t) aligned(c:32) aligned(a,b)
|
|
|
|
// CHECK: [[C_PTRINT:%.+]] = ptrtoint
|
|
|
|
// CHECK-NEXT: [[C_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[C_PTRINT]], 31
|
|
|
|
// CHECK-NEXT: [[C_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[C_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[C_MASKCOND]])
|
|
|
|
// CHECK: [[A_PTRINT:%.+]] = ptrtoint
|
2015-05-22 10:51:49 +08:00
|
|
|
|
|
|
|
// X86-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
// X86-AVX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 31
|
2015-06-23 05:31:43 +08:00
|
|
|
// X86-AVX512-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 63
|
2015-05-22 10:51:49 +08:00
|
|
|
// PPC-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
// PPC-QPX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
|
2014-09-30 13:29:28 +08:00
|
|
|
// CHECK-NEXT: [[A_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[A_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[A_MASKCOND]])
|
|
|
|
// CHECK: [[B_PTRINT:%.+]] = ptrtoint
|
2015-05-22 10:51:49 +08:00
|
|
|
|
|
|
|
// X86-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
|
|
|
|
// X86-AVX-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
|
2015-06-23 05:31:43 +08:00
|
|
|
// X86-AVX512-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 63
|
2015-05-22 10:51:49 +08:00
|
|
|
// PPC-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
|
|
|
|
// PPC-QPX-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
|
|
|
|
|
2014-09-30 13:29:28 +08:00
|
|
|
// CHECK-NEXT: [[B_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[B_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[B_MASKCOND]])
|
2014-05-22 16:54:05 +08:00
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
c[i] = a[i] * a[i] + b[i] * b[t];
|
|
|
|
++t;
|
2015-08-21 20:19:04 +08:00
|
|
|
}
|
|
|
|
// do not emit parallel_loop_access metadata due to usage of safelen clause.
|
|
|
|
// CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
|
|
|
|
#pragma omp simd safelen(16) linear(t) aligned(c:32) aligned(a,b) simdlen(8)
|
|
|
|
// CHECK: [[C_PTRINT:%.+]] = ptrtoint
|
|
|
|
// CHECK-NEXT: [[C_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[C_PTRINT]], 31
|
|
|
|
// CHECK-NEXT: [[C_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[C_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[C_MASKCOND]])
|
|
|
|
// CHECK: [[A_PTRINT:%.+]] = ptrtoint
|
|
|
|
|
|
|
|
// X86-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
// X86-AVX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 31
|
|
|
|
// X86-AVX512-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 63
|
|
|
|
// PPC-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
// PPC-QPX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
|
|
|
|
// CHECK-NEXT: [[A_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[A_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[A_MASKCOND]])
|
|
|
|
// CHECK: [[B_PTRINT:%.+]] = ptrtoint
|
|
|
|
|
|
|
|
// X86-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
|
|
|
|
// X86-AVX-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
|
|
|
|
// X86-AVX512-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 63
|
|
|
|
// PPC-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
|
|
|
|
// PPC-QPX-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
|
|
|
|
|
|
|
|
// CHECK-NEXT: [[B_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[B_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[B_MASKCOND]])
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
c[i] = a[i] * a[i] + b[i] * b[t];
|
|
|
|
++t;
|
|
|
|
}
|
2014-05-22 16:54:05 +08:00
|
|
|
// do not emit parallel_loop_access metadata due to usage of safelen clause.
|
|
|
|
// CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
|
2015-08-21 20:19:04 +08:00
|
|
|
#pragma omp simd linear(t) aligned(c:32) aligned(a,b) simdlen(8)
|
|
|
|
// CHECK: [[C_PTRINT:%.+]] = ptrtoint
|
|
|
|
// CHECK-NEXT: [[C_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[C_PTRINT]], 31
|
|
|
|
// CHECK-NEXT: [[C_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[C_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[C_MASKCOND]])
|
|
|
|
// CHECK: [[A_PTRINT:%.+]] = ptrtoint
|
|
|
|
|
|
|
|
// X86-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
// X86-AVX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 31
|
|
|
|
// X86-AVX512-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 63
|
|
|
|
// PPC-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
// PPC-QPX-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
|
|
|
|
|
|
|
|
// CHECK-NEXT: [[A_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[A_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[A_MASKCOND]])
|
|
|
|
// CHECK: [[B_PTRINT:%.+]] = ptrtoint
|
|
|
|
|
|
|
|
// X86-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
|
|
|
|
// X86-AVX-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
|
|
|
|
// X86-AVX512-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 63
|
|
|
|
// PPC-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
|
|
|
|
// PPC-QPX-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
|
|
|
|
|
|
|
|
// CHECK-NEXT: [[B_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[B_MASKEDPTR]], 0
|
|
|
|
// CHECK-NEXT: call void @llvm.assume(i1 [[B_MASKCOND]])
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
c[i] = a[i] * a[i] + b[i] * b[t];
|
|
|
|
++t;
|
|
|
|
// CHECK: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
|
2014-05-22 16:54:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void h2(float *c, float *a, float *b, int size)
|
|
|
|
{
|
|
|
|
// CHECK-LABEL: define void @h2
|
|
|
|
int t = 0;
|
|
|
|
#pragma omp simd linear(t)
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
c[i] = a[i] * a[i] + b[i] * b[t];
|
|
|
|
++t;
|
|
|
|
// CHECK: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access [[LOOP_H2_HEADER:![0-9]+]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void h3(float *c, float *a, float *b, int size)
|
|
|
|
{
|
|
|
|
// CHECK-LABEL: define void @h3
|
|
|
|
#pragma omp simd
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
for (int j = 0; j < size; ++j) {
|
|
|
|
c[j*i] = a[i] * b[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// do not emit parallel_loop_access for nested loop.
|
|
|
|
// CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Metadata for h1:
|
2015-01-09 06:39:28 +08:00
|
|
|
// CHECK: [[LOOP_H1_HEADER:![0-9]+]] = distinct !{[[LOOP_H1_HEADER]], [[LOOP_WIDTH_16:![0-9]+]], [[LOOP_VEC_ENABLE:![0-9]+]]}
|
2014-12-16 03:10:08 +08:00
|
|
|
// CHECK: [[LOOP_WIDTH_16]] = !{!"llvm.loop.vectorize.width", i32 16}
|
|
|
|
// CHECK: [[LOOP_VEC_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true}
|
2015-08-21 20:19:04 +08:00
|
|
|
// CHECK: [[LOOP_H1_HEADER:![0-9]+]] = distinct !{[[LOOP_H1_HEADER]], [[LOOP_WIDTH_8:![0-9]+]], [[LOOP_VEC_ENABLE]]}
|
|
|
|
// CHECK: [[LOOP_WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}
|
|
|
|
// CHECK: [[LOOP_H1_HEADER:![0-9]+]] = distinct !{[[LOOP_H1_HEADER]], [[LOOP_WIDTH_8]], [[LOOP_VEC_ENABLE]]}
|
2014-05-22 16:54:05 +08:00
|
|
|
//
|
|
|
|
// Metadata for h2:
|
2015-01-09 06:39:28 +08:00
|
|
|
// CHECK: [[LOOP_H2_HEADER]] = distinct !{[[LOOP_H2_HEADER]], [[LOOP_VEC_ENABLE]]}
|
2014-05-22 16:54:05 +08:00
|
|
|
//
|
|
|
|
// Metadata for h3:
|
2015-01-09 06:39:28 +08:00
|
|
|
// CHECK: [[LOOP_H3_HEADER:![0-9]+]] = distinct !{[[LOOP_H3_HEADER]], [[LOOP_VEC_ENABLE]]}
|
2014-05-22 16:54:05 +08:00
|
|
|
//
|