2014-09-10 17:58:16 +00:00
|
|
|
; RUN: opt < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S -simplifycfg | FileCheck %s
|
2013-03-02 01:33:49 +00:00
|
|
|
|
|
|
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-apple-macosx10.8.0"
|
|
|
|
|
|
|
|
;
|
|
|
|
; We want to make sure that we are vectorizeing the scalar loop only once
|
|
|
|
; even if the pass manager runs the vectorizer multiple times due to inlining.
|
|
|
|
|
|
|
|
|
|
|
|
; This test checks that we add metadata to vectorized loops
|
2013-10-02 20:29:00 +00:00
|
|
|
; CHECK-LABEL: @_Z4foo1Pii(
|
2013-03-02 01:33:49 +00:00
|
|
|
; CHECK: <4 x i32>
|
2013-05-28 20:00:34 +00:00
|
|
|
; CHECK: llvm.loop
|
2013-03-02 01:33:49 +00:00
|
|
|
; CHECK: ret
|
|
|
|
|
|
|
|
; This test comes from the loop:
|
|
|
|
;
|
|
|
|
;int foo (int *A, int n) {
|
|
|
|
; return std::accumulate(A, A + n, 0);
|
|
|
|
;}
|
|
|
|
define i32 @_Z4foo1Pii(i32* %A, i32 %n) #0 {
|
|
|
|
entry:
|
|
|
|
%idx.ext = sext i32 %n to i64
|
|
|
|
%add.ptr = getelementptr inbounds i32* %A, i64 %idx.ext
|
|
|
|
%cmp3.i = icmp eq i32 %n, 0
|
|
|
|
br i1 %cmp3.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i
|
|
|
|
|
|
|
|
for.body.i: ; preds = %entry, %for.body.i
|
|
|
|
%__init.addr.05.i = phi i32 [ %add.i, %for.body.i ], [ 0, %entry ]
|
|
|
|
%__first.addr.04.i = phi i32* [ %incdec.ptr.i, %for.body.i ], [ %A, %entry ]
|
2013-04-30 17:52:57 +00:00
|
|
|
%0 = load i32* %__first.addr.04.i, align 4
|
2013-03-02 01:33:49 +00:00
|
|
|
%add.i = add nsw i32 %0, %__init.addr.05.i
|
|
|
|
%incdec.ptr.i = getelementptr inbounds i32* %__first.addr.04.i, i64 1
|
|
|
|
%cmp.i = icmp eq i32* %incdec.ptr.i, %add.ptr
|
|
|
|
br i1 %cmp.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i
|
|
|
|
|
|
|
|
_ZSt10accumulateIPiiET0_T_S2_S1_.exit: ; preds = %for.body.i, %entry
|
|
|
|
%__init.addr.0.lcssa.i = phi i32 [ 0, %entry ], [ %add.i, %for.body.i ]
|
|
|
|
ret i32 %__init.addr.0.lcssa.i
|
|
|
|
}
|
|
|
|
|
2013-05-28 20:00:34 +00:00
|
|
|
; This test checks that we don't vectorize loops that are marked with the "width" == 1 metadata.
|
2013-10-02 20:29:00 +00:00
|
|
|
; CHECK-LABEL: @_Z4foo2Pii(
|
2013-03-02 01:33:49 +00:00
|
|
|
; CHECK-NOT: <4 x i32>
|
2013-05-28 20:00:34 +00:00
|
|
|
; CHECK: llvm.loop
|
2013-03-02 01:33:49 +00:00
|
|
|
; CHECK: ret
|
|
|
|
define i32 @_Z4foo2Pii(i32* %A, i32 %n) #0 {
|
|
|
|
entry:
|
|
|
|
%idx.ext = sext i32 %n to i64
|
|
|
|
%add.ptr = getelementptr inbounds i32* %A, i64 %idx.ext
|
|
|
|
%cmp3.i = icmp eq i32 %n, 0
|
|
|
|
br i1 %cmp3.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i
|
|
|
|
|
|
|
|
for.body.i: ; preds = %entry, %for.body.i
|
|
|
|
%__init.addr.05.i = phi i32 [ %add.i, %for.body.i ], [ 0, %entry ]
|
|
|
|
%__first.addr.04.i = phi i32* [ %incdec.ptr.i, %for.body.i ], [ %A, %entry ]
|
2013-04-30 17:52:57 +00:00
|
|
|
%0 = load i32* %__first.addr.04.i, align 4
|
2013-03-02 01:33:49 +00:00
|
|
|
%add.i = add nsw i32 %0, %__init.addr.05.i
|
|
|
|
%incdec.ptr.i = getelementptr inbounds i32* %__first.addr.04.i, i64 1
|
|
|
|
%cmp.i = icmp eq i32* %incdec.ptr.i, %add.ptr
|
2013-05-28 20:00:34 +00:00
|
|
|
br i1 %cmp.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i, !llvm.loop !0
|
2013-03-02 01:33:49 +00:00
|
|
|
|
|
|
|
_ZSt10accumulateIPiiET0_T_S2_S1_.exit: ; preds = %for.body.i, %entry
|
|
|
|
%__init.addr.0.lcssa.i = phi i32 [ 0, %entry ], [ %add.i, %for.body.i ]
|
|
|
|
ret i32 %__init.addr.0.lcssa.i
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind readonly ssp uwtable "fp-contract-model"="standard" "no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" }
|
|
|
|
|
2015-01-08 22:38:29 +00:00
|
|
|
; CHECK: !0 = distinct !{!0, !1, !2}
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
|
|
|
; CHECK: !1 = !{!"llvm.loop.vectorize.width", i32 1}
|
|
|
|
; CHECK: !2 = !{!"llvm.loop.interleave.count", i32 1}
|
2015-01-08 22:38:29 +00:00
|
|
|
; CHECK: !3 = distinct !{!3, !1, !2}
|
2013-03-02 01:33:49 +00:00
|
|
|
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
|
|
|
!0 = !{!0, !1}
|
|
|
|
!1 = !{!"llvm.loop.vectorize.width", i32 1}
|