| 1 |
// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 -emit-llvm %s -o - | FileCheck %s |
| 2 |
|
| 3 |
// CHECK: define {{.*}}@f_default({{.*}} [[f_default:#[0-9]+]] |
| 4 |
// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge({{.*}} [[f_avx_sse4_2_ivybridge:#[0-9]+]] |
| 5 |
// CHECK: define {{.*}}@f_fpmath_387({{.*}} [[f_default]] |
| 6 |
// CHECK: define {{.*}}@f_no_sse2({{.*}} [[f_no_sse2:#[0-9]+]] |
| 7 |
// CHECK: define {{.*}}@f_sse4({{.*}} [[f_sse4:#[0-9]+]] |
| 8 |
// CHECK: define {{.*}}@f_no_sse4({{.*}} [[f_no_sse4:#[0-9]+]] |
| 9 |
// CHECK: define {{.*}}@f_default2({{.*}} [[f_default]] |
| 10 |
// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge_2({{.*}} [[f_avx_sse4_2_ivybridge]] |
| 11 |
// CHECK: define {{.*}}@f_no_aes_ivybridge({{.*}} [[f_no_aes_ivybridge:#[0-9]+]] |
| 12 |
// CHECK: define {{.*}}@f_no_mmx({{.*}} [[f_no_mmx:#[0-9]+]] |
| 13 |
// CHECK: define {{.*}}@f_lakemont_mmx({{.*}} [[f_lakemont_mmx:#[0-9]+]] |
| 14 |
// CHECK: define {{.*}}@f_use_before_def({{.*}} [[f_lakemont_mmx]] |
| 15 |
// CHECK: define {{.*}}@f_tune_sandybridge({{.*}} [[f_tune_sandybridge:#[0-9]+]] |
| 16 |
// CHECK: define {{.*}}@f_x86_64_v2({{.*}} [[f_x86_64_v2:#[0-9]+]] |
| 17 |
// CHECK: define {{.*}}@f_x86_64_v3({{.*}} [[f_x86_64_v3:#[0-9]+]] |
| 18 |
// CHECK: define {{.*}}@f_x86_64_v4({{.*}} [[f_x86_64_v4:#[0-9]+]] |
| 19 |
// CHECK: define {{.*}}@f_avx10_1{{.*}} [[f_avx10_1:#[0-9]+]] |
| 20 |
// CHECK: define {{.*}}@f_prefer_256_bit({{.*}} [[f_prefer_256_bit:#[0-9]+]] |
| 21 |
// CHECK: define {{.*}}@f_no_prefer_256_bit({{.*}} [[f_no_prefer_256_bit:#[0-9]+]] |
| 22 |
|
| 23 |
// CHECK: [[f_default]] = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" "tune-cpu"="i686" |
| 24 |
void f_default(void) {} |
| 25 |
|
| 26 |
// CHECK: [[f_avx_sse4_2_ivybridge]] = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" |
| 27 |
__attribute__((target("avx,sse4.2,arch=ivybridge"))) |
| 28 |
void f_avx_sse4_2_ivybridge(void) {} |
| 29 |
|
| 30 |
// We're currently ignoring the fpmath attribute. So checked above that |
| 31 |
// attributes are identical to f_default. |
| 32 |
__attribute__((target("fpmath=387"))) |
| 33 |
void f_fpmath_387(void) {} |
| 34 |
|
| 35 |
// CHECK-NOT: tune-cpu |
| 36 |
// CHECK: [[f_no_sse2]] = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87,-aes,-amx-avx512,-avx,-avx10.1,-avx10.2,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sha512,-sm3,-sm4,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop" "tune-cpu"="i686" |
| 37 |
__attribute__((target("no-sse2"))) |
| 38 |
void f_no_sse2(void) {} |
| 39 |
|
| 40 |
// CHECK: [[f_sse4]] = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "tune-cpu"="i686" |
| 41 |
__attribute__((target("sse4"))) |
| 42 |
void f_sse4(void) {} |
| 43 |
|
| 44 |
// CHECK: [[f_no_sse4]] = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87,-amx-avx512,-avx,-avx10.1,-avx10.2,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-sha512,-sm3,-sm4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop" "tune-cpu"="i686" |
| 45 |
__attribute__((target("no-sse4"))) |
| 46 |
void f_no_sse4(void) {} |
| 47 |
|
| 48 |
// checked above that attributes are identical to f_default |
| 49 |
void f_default2(void) { |
| 50 |
f_avx_sse4_2_ivybridge(); |
| 51 |
return f_default(); |
| 52 |
} |
| 53 |
|
| 54 |
// Checked above to have same attributes as f_avx_sse4_2_ivybridge |
| 55 |
__attribute__((target("avx, sse4.2, arch= ivybridge"))) |
| 56 |
void f_avx_sse4_2_ivybridge_2(void) {} |
| 57 |
|
| 58 |
// CHECK: [[f_no_aes_ivybridge]] = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes,-vaes" |
| 59 |
__attribute__((target("no-aes, arch=ivybridge"))) |
| 60 |
void f_no_aes_ivybridge(void) {} |
| 61 |
|
| 62 |
// CHECK-NOT: tune-cpu |
| 63 |
// CHECK: [[f_no_mmx]] = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87,-mmx" |
| 64 |
__attribute__((target("no-mmx"))) |
| 65 |
void f_no_mmx(void) {} |
| 66 |
|
| 67 |
// CHECK: [[f_lakemont_mmx]] = {{.*}}"target-cpu"="lakemont" "target-features"="+cx8,+mmx" |
| 68 |
// Adding the attribute to a definition does update it in IR. |
| 69 |
__attribute__((target("arch=lakemont,mmx"))) |
| 70 |
void f_lakemont_mmx(void) {} |
| 71 |
|
| 72 |
void f_use_before_def(void); |
| 73 |
void usage(void){ |
| 74 |
f_use_before_def(); |
| 75 |
} |
| 76 |
|
| 77 |
// Checked above to have same attributes as f_lakemont_mmx |
| 78 |
__attribute__((target("arch=lakemont,mmx"))) |
| 79 |
void f_use_before_def(void) {} |
| 80 |
|
| 81 |
// CHECK: [[f_tune_sandybridge]] = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" "tune-cpu"="sandybridge" |
| 82 |
__attribute__((target("tune=sandybridge"))) |
| 83 |
void f_tune_sandybridge(void) {} |
| 84 |
|
| 85 |
// CHECK: [[f_x86_64_v2]] ={{.*}}"target-cpu"="x86-64-v2" |
| 86 |
// CHECK-SAME: "target-features"="+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+popcnt,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" |
| 87 |
__attribute__((target("arch=x86-64-v2"))) |
| 88 |
void f_x86_64_v2(void) {} |
| 89 |
|
| 90 |
// CHECK: [[f_x86_64_v3]] = {{.*}}"target-cpu"="x86-64-v3" |
| 91 |
// CHECK-SAME: "target-features"="+avx,+avx2,+bmi,+bmi2,+cmov,+crc32,+cx16,+cx8,+f16c,+fma,+fxsr,+lzcnt,+mmx,+movbe,+popcnt,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" |
| 92 |
__attribute__((target("arch=x86-64-v3"))) |
| 93 |
void f_x86_64_v3(void) {} |
| 94 |
|
| 95 |
// CHECK: [[f_x86_64_v4]] = {{.*}}"target-cpu"="x86-64-v4" |
| 96 |
// CHECK-SAME: "target-features"="+avx,+avx2,+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl,+bmi,+bmi2,+cmov,+crc32,+cx16,+cx8,+f16c,+fma,+fxsr,+lzcnt,+mmx,+movbe,+popcnt,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" |
| 97 |
__attribute__((target("arch=x86-64-v4"))) |
| 98 |
void f_x86_64_v4(void) {} |
| 99 |
|
| 100 |
// CHECK: [[f_avx10_1]] = {{.*}}"target-cpu"="i686" "target-features"="+avx,+avx10.1,+avx2,+avx512bf16,+avx512bitalg,+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512fp16,+avx512ifma,+avx512vbmi,+avx512vbmi2,+avx512vl,+avx512vnni,+avx512vpopcntdq,+cmov,+crc32,+cx8,+f16c,+fma,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" |
| 101 |
__attribute__((target("avx10.1"))) |
| 102 |
void f_avx10_1(void) {} |
| 103 |
|
| 104 |
// CHECK: [[f_prefer_256_bit]] = {{.*}}"target-features"="{{.*}}+prefer-256-bit |
| 105 |
__attribute__((target("prefer-256-bit"))) |
| 106 |
void f_prefer_256_bit(void) {} |
| 107 |
|
| 108 |
// CHECK: [[f_no_prefer_256_bit]] = {{.*}}"target-features"="{{.*}}-prefer-256-bit |
| 109 |
__attribute__((target("no-prefer-256-bit"))) |
| 110 |
void f_no_prefer_256_bit(void) {} |