llvm.org GIT mirror llvm / 9e0807c
SLPVectorizer: An in-tree vectorized entry cannot also be a scalar external use We were creating external uses for scalar values in MustGather entries that also had a ScalarToTreeEntry (they also are present in a vectorized tuple). This meant we would keep a value 'alive' as a scalar and vectorized causing havoc. This is not necessary because when we create a MustGather vector we explicitly create external uses entries for the insertelement instructions of the MustGather vector elements. Fixes PR18129. radar://15582184 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196508 91177308-0d34-0410-b5e6-96231b3b80d8 Arnold Schwaighofer 5 years ago
2 changed file(s) with 36 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
563563 UE = Scalar->use_end(); User != UE; ++User) {
564564 DEBUG(dbgs() << "SLP: Checking user:" << **User << ".\n");
565565
566 bool Gathered = MustGather.count(*User);
567
568566 // Skip in-tree scalars that become vectors.
569 if (ScalarToTreeEntry.count(*User) && !Gathered) {
567 if (ScalarToTreeEntry.count(*User)) {
570568 DEBUG(dbgs() << "SLP: \tInternal user will be removed:" <<
571569 **User << ".\n");
572570 int Idx = ScalarToTreeEntry[*User]; (void) Idx;
16401638 for (Value::use_iterator User = Scalar->use_begin(),
16411639 UE = Scalar->use_end(); User != UE; ++User) {
16421640 DEBUG(dbgs() << "SLP: \tvalidating user:" << **User << ".\n");
1643 assert(!MustGather.count(*User) &&
1644 "Replacing gathered value with undef");
16451641
16461642 assert((ScalarToTreeEntry.count(*User) ||
16471643 // It is legal to replace the reduction users by undef.
5858 ret double %mul3
5959 }
6060
61 ; A need-to-gather entry cannot be an external use of the scalar element.
62 ; Instead the insertelement instructions of the need-to-gather entry are the
63 ; external users.
64 ; This test would assert because we would keep the scalar fpext and fadd alive.
65 ; PR18129
66
67 ; CHECK-LABEL: needtogather
68 define i32 @needtogather(double *noalias %a, i32 *noalias %b, float * noalias %c,
69 i32 * noalias %d) {
70 entry:
71 %0 = load i32* %d, align 4
72 %conv = sitofp i32 %0 to float
73 %1 = load float* %c
74 %sub = fsub float 0.000000e+00, %1
75 %mul = fmul float %sub, 0.000000e+00
76 %add = fadd float %conv, %mul
77 %conv1 = fpext float %add to double
78 %sub3 = fsub float 1.000000e+00, %1
79 %mul4 = fmul float %sub3, 0.000000e+00
80 %add5 = fadd float %conv, %mul4
81 %conv6 = fpext float %add5 to double
82 %tobool = fcmp une float %add, 0.000000e+00
83 br i1 %tobool, label %if.then, label %if.end
84
85 if.then:
86 br label %if.end
87
88 if.end:
89 %storemerge = phi double [ %conv6, %if.then ], [ %conv1, %entry ]
90 %e.0 = phi double [ %conv1, %if.then ], [ %conv6, %entry ]
91 store double %storemerge, double* %a, align 8
92 %conv7 = fptosi double %e.0 to i32
93 store i32 %conv7, i32* %b, align 4
94 ret i32 undef
95 }