2013-04-09 19:44:35 +00:00
|
|
|
; 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
|
|
|
|
|
2013-04-14 05:47:04 +00:00
|
|
|
define void @SAXPY(i32* noalias nocapture %x, i32* noalias nocapture %y, i32 %a, i64 %i) {
|
2013-04-09 19:44:35 +00:00
|
|
|
%1 = getelementptr inbounds i32* %x, i64 %i
|
2013-04-14 05:47:04 +00:00
|
|
|
%2 = load i32* %1, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%3 = mul nsw i32 %2, %a
|
|
|
|
%4 = getelementptr inbounds i32* %y, i64 %i
|
2013-04-14 05:47:04 +00:00
|
|
|
%5 = load i32* %4, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%6 = add nsw i32 %3, %5
|
2013-04-14 05:47:04 +00:00
|
|
|
store i32 %6, i32* %1, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%7 = add i64 %i, 1
|
|
|
|
%8 = getelementptr inbounds i32* %x, i64 %7
|
2013-04-14 05:47:04 +00:00
|
|
|
%9 = load i32* %8, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%10 = mul nsw i32 %9, %a
|
|
|
|
%11 = getelementptr inbounds i32* %y, i64 %7
|
2013-04-14 05:47:04 +00:00
|
|
|
%12 = load i32* %11, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%13 = add nsw i32 %10, %12
|
2013-04-14 05:47:04 +00:00
|
|
|
store i32 %13, i32* %8, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%14 = add i64 %i, 2
|
|
|
|
%15 = getelementptr inbounds i32* %x, i64 %14
|
2013-04-14 05:47:04 +00:00
|
|
|
%16 = load i32* %15, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%17 = mul nsw i32 %16, %a
|
|
|
|
%18 = getelementptr inbounds i32* %y, i64 %14
|
2013-04-14 05:47:04 +00:00
|
|
|
%19 = load i32* %18, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%20 = add nsw i32 %17, %19
|
2013-04-14 05:47:04 +00:00
|
|
|
store i32 %20, i32* %15, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%21 = add i64 %i, 3
|
|
|
|
%22 = getelementptr inbounds i32* %x, i64 %21
|
2013-04-14 05:47:04 +00:00
|
|
|
%23 = load i32* %22, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%24 = mul nsw i32 %23, %a
|
|
|
|
%25 = getelementptr inbounds i32* %y, i64 %21
|
2013-04-14 05:47:04 +00:00
|
|
|
%26 = load i32* %25, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
%27 = add nsw i32 %24, %26
|
2013-04-14 05:47:04 +00:00
|
|
|
store i32 %27, i32* %22, align 4
|
2013-04-09 19:44:35 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2013-07-07 06:57:07 +00:00
|
|
|
; Make sure we don't crash on this one.
|
|
|
|
define void @SAXPY_crash(i32* noalias nocapture %x, i32* noalias nocapture %y, i64 %i) {
|
|
|
|
%1 = add i64 %i, 1
|
|
|
|
%2 = getelementptr inbounds i32* %x, i64 %1
|
|
|
|
%3 = getelementptr inbounds i32* %y, i64 %1
|
|
|
|
%4 = load i32* %3, align 4
|
|
|
|
%5 = add nsw i32 undef, %4
|
|
|
|
store i32 %5, i32* %2, align 4
|
|
|
|
%6 = add i64 %i, 2
|
|
|
|
%7 = getelementptr inbounds i32* %x, i64 %6
|
|
|
|
%8 = getelementptr inbounds i32* %y, i64 %6
|
|
|
|
%9 = load i32* %8, align 4
|
|
|
|
%10 = add nsw i32 undef, %9
|
|
|
|
store i32 %10, i32* %7, align 4
|
|
|
|
ret void
|
|
|
|
}
|