blob: b02dd7196508af3ff71374cf82135f788ffce2a4 [file] [log] [blame]
Eric Christopher11acf732015-06-12 01:35:52 +00001// RUN: %clang_cc1 -triple x86_64-linux-gnu -target-cpu x86-64 -emit-llvm %s -o - | FileCheck %s
2
3int baz(int a) { return 4; }
4
5int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 4; }
6
Eric Christopher64a247b2015-06-12 01:35:56 +00007int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
Eric Christopher249e3762015-06-12 01:36:00 +00008int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
Eric Christopher64a247b2015-06-12 01:35:56 +00009
Eric Christopher4dfe0752015-06-12 01:35:58 +000010int __attribute__((target("mno-sse2"))) echidna(int a) { return 4; }
11
Eric Christopher298ac302015-07-01 00:08:32 +000012int __attribute__((target("sse4"))) panda(int a) { return 4; }
13
Eric Christopher11acf732015-06-12 01:35:52 +000014int bar(int a) { return baz(a) + foo(a); }
15
Eric Christopheraf4d6082015-07-06 23:51:59 +000016int __attribute__((target("avx, sse4.2, arch= ivybridge"))) qux(int a) { return 4; }
Eric Christopher3a98b3c2015-08-27 19:59:34 +000017int __attribute__((target("mno-aes, arch=ivybridge"))) qax(int a) { return 4; }
Eric Christopheraf4d6082015-07-06 23:51:59 +000018
Eric Christopher11acf732015-06-12 01:35:52 +000019// Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
20// CHECK: baz{{.*}} #0
21// CHECK: foo{{.*}} #1
Eric Christopher64a247b2015-06-12 01:35:56 +000022// We ignore the tune attribute so walrus should be identical to baz and bar.
23// CHECK: walrus{{.*}} #0
Eric Christopher249e3762015-06-12 01:36:00 +000024// We're currently ignoring the fpmath attribute so koala should be identical to baz and bar.
25// CHECK: koala{{.*}} #0
Eric Christopher4dfe0752015-06-12 01:35:58 +000026// CHECK: echidna{{.*}} #2
Eric Christopher11acf732015-06-12 01:35:52 +000027// CHECK: bar{{.*}} #0
Eric Christopheraf4d6082015-07-06 23:51:59 +000028// CHECK: qux{{.*}} #1
Eric Christopher3a98b3c2015-08-27 19:59:34 +000029// CHECK: qax{{.*}} #4
Eric Christopher11acf732015-06-12 01:35:52 +000030// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
Eric Christopher3a98b3c2015-08-27 19:59:34 +000031// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
Eric Christopher2374a7c2015-07-01 01:07:12 +000032// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop"
33// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
Eric Christopher3a98b3c2015-08-27 19:59:34 +000034// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,-aes"