1; RUN: opt < %s -basicaa -slp-vectorizer -S |FileCheck %s 2target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 3 4; Test if SLP can handle GEP expressions. 5; The test perform the following action: 6; x->first = y->first + 16 7; x->second = y->second + 16 8 9; CHECK-LABEL: foo1 10; CHECK: <2 x i32*> 11define void @foo1 ({ i32*, i32* }* noalias %x, { i32*, i32* }* noalias %y) { 12 %1 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 0 13 %2 = load i32*, i32** %1, align 8 14 %3 = getelementptr inbounds i32, i32* %2, i64 16 15 %4 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 0 16 store i32* %3, i32** %4, align 8 17 %5 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 1 18 %6 = load i32*, i32** %5, align 8 19 %7 = getelementptr inbounds i32, i32* %6, i64 16 20 %8 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 1 21 store i32* %7, i32** %8, align 8 22 ret void 23} 24 25; Test that we don't vectorize GEP expressions if indexes are not constants. 26; We can't produce an efficient code in that case. 27; CHECK-LABEL: foo2 28; CHECK-NOT: <2 x i32*> 29define void @foo2 ({ i32*, i32* }* noalias %x, { i32*, i32* }* noalias %y, i32 %i) { 30 %1 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 0 31 %2 = load i32*, i32** %1, align 8 32 %3 = getelementptr inbounds i32, i32* %2, i32 %i 33 %4 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 0 34 store i32* %3, i32** %4, align 8 35 %5 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 1 36 %6 = load i32*, i32** %5, align 8 37 %7 = getelementptr inbounds i32, i32* %6, i32 %i 38 %8 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 1 39 store i32* %7, i32** %8, align 8 40 ret void 41} 42