Reinitialize the ivars in the subtarget so that they can be reset with the new features.
[oota-llvm.git] / test / CodeGen / X86 / subtarget-feature-change.ll
1 ; RUN: llc < %s -march=x86-64 | FileCheck %s
2
3 ; This should not generate SSE instructions:
4 ;
5 ; CHECK: without.sse:
6 ; CHECK: flds
7 ; CHECK: fmuls
8 ; CHECK: fstps
9 define void @without.sse(float* nocapture %a, float* nocapture %b, float* nocapture %c, i32 %n) #0 {
10 entry:
11   %cmp9 = icmp sgt i32 %n, 0
12   br i1 %cmp9, label %for.body, label %for.end
13
14 for.body:
15   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
16   %arrayidx = getelementptr inbounds float* %b, i64 %indvars.iv
17   %0 = load float* %arrayidx, align 4, !tbaa !0
18   %arrayidx2 = getelementptr inbounds float* %c, i64 %indvars.iv
19   %1 = load float* %arrayidx2, align 4, !tbaa !0
20   %mul = fmul float %0, %1
21   %arrayidx4 = getelementptr inbounds float* %a, i64 %indvars.iv
22   store float %mul, float* %arrayidx4, align 4, !tbaa !0
23   %indvars.iv.next = add i64 %indvars.iv, 1
24   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
25   %exitcond = icmp eq i32 %lftr.wideiv, %n
26   br i1 %exitcond, label %for.end, label %for.body
27
28 for.end:
29   ret void
30 }
31
32 ; This should generate SSE instructions:
33 ;
34 ; CHECK: with.sse
35 ; CHECK: movss
36 ; CHECK: mulss
37 ; CHECK: movss
38 define void @with.sse(float* nocapture %a, float* nocapture %b, float* nocapture %c, i32 %n) #1 {
39 entry:
40   %cmp9 = icmp sgt i32 %n, 0
41   br i1 %cmp9, label %for.body, label %for.end
42
43 for.body:
44   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
45   %arrayidx = getelementptr inbounds float* %b, i64 %indvars.iv
46   %0 = load float* %arrayidx, align 4, !tbaa !0
47   %arrayidx2 = getelementptr inbounds float* %c, i64 %indvars.iv
48   %1 = load float* %arrayidx2, align 4, !tbaa !0
49   %mul = fmul float %0, %1
50   %arrayidx4 = getelementptr inbounds float* %a, i64 %indvars.iv
51   store float %mul, float* %arrayidx4, align 4, !tbaa !0
52   %indvars.iv.next = add i64 %indvars.iv, 1
53   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
54   %exitcond = icmp eq i32 %lftr.wideiv, %n
55   br i1 %exitcond, label %for.end, label %for.body
56
57 for.end:
58   ret void
59 }
60
61 attributes #0 = { nounwind optsize ssp uwtable "target-cpu"="core2" "target-features"="-sse4a,-avx2,-xop,-fma4,-bmi2,-3dnow,-3dnowa,-pclmul,-sse,-avx,-sse41,-ssse3,+mmx,-rtm,-sse42,-lzcnt,-f16c,-popcnt,-bmi,-aes,-fma,-rdrand,-sse2,-sse3" }
62 attributes #1 = { nounwind optsize ssp uwtable "target-cpu"="core2" "target-features"="-sse4a,-avx2,-xop,-fma4,-bmi2,-3dnow,-3dnowa,-pclmul,+sse,-avx,-sse41,+ssse3,+mmx,-rtm,-sse42,-lzcnt,-f16c,-popcnt,-bmi,-aes,-fma,-rdrand,+sse2,+sse3" }
63
64 !0 = metadata !{metadata !"float", metadata !1}
65 !1 = metadata !{metadata !"omnipotent char", metadata !2}
66 !2 = metadata !{metadata !"Simple C/C++ TBAA"}