xref: /llvm-project/llvm/test/Transforms/SLPVectorizer/X86/reorder_phi.ll (revision 33960c90258ed78b9b877b1a43e219d1cbc2efce)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=slp-vectorizer  -S -mtriple=x86_64-unknown -mcpu=corei7-avx | FileCheck %s
3
4%struct.complex = type { float, float }
5
6define  void @foo (ptr %A, ptr %B, ptr %Result) {
7; CHECK-LABEL: @foo(
8; CHECK-NEXT:  entry:
9; CHECK-NEXT:    [[TMP0:%.*]] = add i64 256, 0
10; CHECK-NEXT:    br label [[LOOP:%.*]]
11; CHECK:       loop:
12; CHECK-NEXT:    [[TMP1:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[TMP18:%.*]], [[LOOP]] ]
13; CHECK-NEXT:    [[TMP2:%.*]] = phi <2 x float> [ zeroinitializer, [[ENTRY]] ], [ [[TMP20:%.*]], [[LOOP]] ]
14; CHECK-NEXT:    [[TMP3:%.*]] = getelementptr inbounds [[STRUCT_COMPLEX:%.*]], ptr [[A:%.*]], i64 [[TMP1]], i32 0
15; CHECK-NEXT:    [[TMP4:%.*]] = getelementptr inbounds [[STRUCT_COMPLEX]], ptr [[B:%.*]], i64 [[TMP1]], i32 0
16; CHECK-NEXT:    [[TMP5:%.*]] = load float, ptr [[TMP4]], align 4
17; CHECK-NEXT:    [[TMP6:%.*]] = getelementptr inbounds [[STRUCT_COMPLEX]], ptr [[B]], i64 [[TMP1]], i32 1
18; CHECK-NEXT:    [[TMP7:%.*]] = load float, ptr [[TMP6]], align 4
19; CHECK-NEXT:    [[TMP8:%.*]] = load <2 x float>, ptr [[TMP3]], align 4
20; CHECK-NEXT:    [[TMP9:%.*]] = insertelement <2 x float> poison, float [[TMP5]], i32 0
21; CHECK-NEXT:    [[TMP10:%.*]] = shufflevector <2 x float> [[TMP9]], <2 x float> poison, <2 x i32> zeroinitializer
22; CHECK-NEXT:    [[TMP11:%.*]] = fmul <2 x float> [[TMP8]], [[TMP10]]
23; CHECK-NEXT:    [[TMP12:%.*]] = insertelement <2 x float> poison, float [[TMP7]], i32 0
24; CHECK-NEXT:    [[TMP13:%.*]] = shufflevector <2 x float> [[TMP12]], <2 x float> poison, <2 x i32> zeroinitializer
25; CHECK-NEXT:    [[TMP14:%.*]] = fmul <2 x float> [[TMP8]], [[TMP13]]
26; CHECK-NEXT:    [[TMP15:%.*]] = shufflevector <2 x float> [[TMP14]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
27; CHECK-NEXT:    [[TMP16:%.*]] = fsub <2 x float> [[TMP11]], [[TMP15]]
28; CHECK-NEXT:    [[TMP17:%.*]] = fadd <2 x float> [[TMP11]], [[TMP15]]
29; CHECK-NEXT:    [[TMP21:%.*]] = shufflevector <2 x float> [[TMP16]], <2 x float> [[TMP17]], <2 x i32> <i32 0, i32 3>
30; CHECK-NEXT:    [[TMP20]] = fadd <2 x float> [[TMP2]], [[TMP21]]
31; CHECK-NEXT:    [[TMP18]] = add nuw nsw i64 [[TMP1]], 1
32; CHECK-NEXT:    [[TMP19:%.*]] = icmp eq i64 [[TMP18]], [[TMP0]]
33; CHECK-NEXT:    br i1 [[TMP19]], label [[EXIT:%.*]], label [[LOOP]]
34; CHECK:       exit:
35; CHECK-NEXT:    store <2 x float> [[TMP20]], ptr [[RESULT:%.*]], align 4
36; CHECK-NEXT:    ret void
37;
38entry:
39  %0 = add i64 256, 0
40  br label %loop
41
42loop:
43  %1 = phi i64 [ 0, %entry ], [ %20, %loop ]
44  %2 = phi float [ 0.000000e+00, %entry ], [ %19, %loop ]
45  %3 = phi float [ 0.000000e+00, %entry ], [ %18, %loop ]
46  %4 = getelementptr inbounds %"struct.complex", ptr %A, i64 %1, i32 0
47  %5 = load float, ptr %4, align 4
48  %6 = getelementptr inbounds %"struct.complex", ptr %A, i64 %1, i32 1
49  %7 = load float, ptr %6, align 4
50  %8 = getelementptr inbounds %"struct.complex", ptr %B, i64 %1, i32 0
51  %9 = load float, ptr %8, align 4
52  %10 = getelementptr inbounds %"struct.complex", ptr %B, i64 %1, i32 1
53  %11 = load float, ptr %10, align 4
54  %12 = fmul float %5, %9
55  %13 = fmul float %7, %11
56  %14 = fsub float %12, %13
57  %15 = fmul float %7, %9
58  %16 = fmul float %5, %11
59  %17 = fadd float %15, %16
60  %18 = fadd float %3, %14
61  %19 = fadd float %2, %17
62  %20 = add nuw nsw i64 %1, 1
63  %21 = icmp eq i64 %20, %0
64  br i1 %21, label %exit, label %loop
65
66exit:
67  store float %18, ptr %Result, align 4
68  %22 = getelementptr inbounds %"struct.complex", ptr %Result,  i32 0, i32 1
69  store float %19, ptr %22, align 4
70  ret void
71}
72
73