[PATCH] D32252: [GVN] Add phi-translate for scalarpre as a temporary solution

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 10:18:54 PDT 2017


On Thu, May 18, 2017 at 9:51 AM, Daniel Berlin via Phabricator
<reviews at reviews.llvm.org> wrote:
> dberlin added a comment.
>
> Pretty good at this point.
> I don't understand why you changed the CHECK-NEXT lines to CHECK lines though.
> Can you explain?
>

Because with the patch, the following

sw.bb2:                                           ; preds = %if.end, %entry
  %idxprom3 = sext i32 %i to i64
  %arrayidx4 = getelementptr inbounds double*, double** %p, i64 0
  %2 = load double*, double** %arrayidx4, align 8
  %arrayidx5 = getelementptr inbounds double, double* %2, i64 %idxprom3
  %3 = load double, double* %arrayidx5, align 8
; CHECK: sw.bb2:
; CHECK-NOT: sext
; CHECK: phi double [
; CHECK-NOT: load
  %sub6 = fsub double 3.000000e+00, %3
  br label %return

will be transformed to:

sw.bb2:                                           ; preds =
%entry.sw.bb2_crit_edge, %if.end
  %arrayidx5.pre-phi = phi double* [ %arrayidx5.phi.trans.insert,
%entry.sw.bb2_crit_edge ], [ %arrayidx1, %if.end ]
  %2 = phi double [ %.pre2, %entry.sw.bb2_crit_edge ], [ %1, %if.end ]
  %idxprom3.pre-phi = phi i64 [ %.pre1, %entry.sw.bb2_crit_edge ], [
%idxprom, %if.end ]
  %3 = phi double* [ %.pre, %entry.sw.bb2_crit_edge ], [ %0, %if.end ]
  %sub6 = fsub double 3.000000e+00, %2
  br label %return

There is a new pre-phi inserted at the beginning of sw.bb2, so
original `phi double` is not the next line of sw.bb2.

>
>
> ================
> Comment at: lib/Transforms/Scalar/GVN.cpp:239
>    e.opcode = I->getOpcode();
> +  e.commutative = false;
>    for (Instruction::op_iterator OI = I->op_begin(), OE = I->op_end();
> ----------------
> Just initialize it to false in the constructor
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D32252
>
>
>


More information about the llvm-commits mailing list