blob: e21f047ed0addd152ccbcae76a161fac8e62c998 [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; }
8
Eric Christopher4dfe0752015-06-12 01:35:58 +00009int __attribute__((target("mno-sse2"))) echidna(int a) { return 4; }
10
Eric Christopher11acf732015-06-12 01:35:52 +000011int bar(int a) { return baz(a) + foo(a); }
12
13// Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
14// CHECK: baz{{.*}} #0
15// CHECK: foo{{.*}} #1
Eric Christopher64a247b2015-06-12 01:35:56 +000016// We ignore the tune attribute so walrus should be identical to baz and bar.
17// CHECK: walrus{{.*}} #0
Eric Christopher4dfe0752015-06-12 01:35:58 +000018// CHECK: echidna{{.*}} #2
Eric Christopher11acf732015-06-12 01:35:52 +000019// CHECK: bar{{.*}} #0
20// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
21// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+sse,+sse2,+avx,+sse4.2"
Eric Christopher4dfe0752015-06-12 01:35:58 +000022// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2,-sse2"