llvm-6502/test/Transforms/SLPVectorizer/X86/saxpy.ll
Nadav Rotem 8383b539ff Add support for bottom-up SLP vectorization infrastructure.
This commit adds the infrastructure for performing bottom-up SLP vectorization (and other optimizations) on parallel computations.
The infrastructure has three potential users:

  1. The loop vectorizer needs to be able to vectorize AOS data structures such as (sum += A[i] + A[i+1]).

  2. The BB-vectorizer needs this infrastructure for bottom-up SLP vectorization, because bottom-up vectorization is faster to compute.

  3. A loop-roller needs to be able to analyze consecutive chains and roll them into a loop, in order to reduce code size. A loop roller does not need to create vector instructions, and this infrastructure separates the chain analysis from the vectorization.

This patch also includes a simple (100 LOC) bottom up SLP vectorizer that uses the infrastructure, and can vectorize this code:

void SAXPY(int *x, int *y, int a, int i) {
  x[i]   = a * x[i]   + y[i];
  x[i+1] = a * x[i+1] + y[i+1];
  x[i+2] = a * x[i+2] + y[i+2];
  x[i+3] = a * x[i+3] + y[i+3];
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179117 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-09 19:44:35 +00:00

51 lines
2.1 KiB
LLVM

; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
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"
; SLP vectorization example from http://cs.stanford.edu/people/eschkufz/research/asplos291-schkufza.pdf
;CHECK: SAXPY
;CHECK: mul <4 x i32>
;CHECK: ret
define void @SAXPY(i32* noalias nocapture %x, i32* noalias nocapture %y, i32 %a, i64 %i) #0 {
%1 = getelementptr inbounds i32* %x, i64 %i
%2 = load i32* %1, align 4, !tbaa !0
%3 = mul nsw i32 %2, %a
%4 = getelementptr inbounds i32* %y, i64 %i
%5 = load i32* %4, align 4, !tbaa !0
%6 = add nsw i32 %3, %5
store i32 %6, i32* %1, align 4, !tbaa !0
%7 = add i64 %i, 1
%8 = getelementptr inbounds i32* %x, i64 %7
%9 = load i32* %8, align 4, !tbaa !0
%10 = mul nsw i32 %9, %a
%11 = getelementptr inbounds i32* %y, i64 %7
%12 = load i32* %11, align 4, !tbaa !0
%13 = add nsw i32 %10, %12
store i32 %13, i32* %8, align 4, !tbaa !0
%14 = add i64 %i, 2
%15 = getelementptr inbounds i32* %x, i64 %14
%16 = load i32* %15, align 4, !tbaa !0
%17 = mul nsw i32 %16, %a
%18 = getelementptr inbounds i32* %y, i64 %14
%19 = load i32* %18, align 4, !tbaa !0
%20 = add nsw i32 %17, %19
store i32 %20, i32* %15, align 4, !tbaa !0
%21 = add i64 %i, 3
%22 = getelementptr inbounds i32* %x, i64 %21
%23 = load i32* %22, align 4, !tbaa !0
%24 = mul nsw i32 %23, %a
%25 = getelementptr inbounds i32* %y, i64 %21
%26 = load i32* %25, align 4, !tbaa !0
%27 = add nsw i32 %24, %26
store i32 %27, i32* %22, align 4, !tbaa !0
ret void
}
attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
!0 = metadata !{metadata !"int", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA"}