blob: 7ea5fe5a07a0ef4ce2c2984fccaab57dd2b44d2c [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
16// Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
17// CHECK: baz{{.*}} #0
18// CHECK: foo{{.*}} #1
Eric Christopher64a247b2015-06-12 01:35:56 +000019// We ignore the tune attribute so walrus should be identical to baz and bar.
20// CHECK: walrus{{.*}} #0
Eric Christopher249e3762015-06-12 01:36:00 +000021// We're currently ignoring the fpmath attribute so koala should be identical to baz and bar.
22// CHECK: koala{{.*}} #0
Eric Christopher4dfe0752015-06-12 01:35:58 +000023// CHECK: echidna{{.*}} #2
Eric Christopher11acf732015-06-12 01:35:52 +000024// CHECK: bar{{.*}} #0
25// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
Eric Christopher2374a7c2015-07-01 01:07:12 +000026// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
27// 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"
28// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"