<div dir="ltr"><div>I am extremely sorry about the noise.<br></div><br>I reverted my commit to investigate this test case.<div>I think that is because the expected output get slightly changed, but I prefer to be cautious and revert my commit for now.</div><div><br></div><div>Do you know where to find information about PR30742 (name of the failing function).</div><div>It is full of undef and I can't make sense of it. Probably a bugpoint generated case.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 29, 2017 at 7:35 PM, Robinson, Paul <span dir="ltr"><<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is causing multiple bots to fail, can you revert or fix please?<br>
Failing Tests (1):<br>
    LLVM :: Transforms/LoopVectorize/iv_<wbr>outside_user.ll<br>
<br>
Thanks,<br>
--paulr<br>
<div class="HOEnZb"><div class="h5"><br>
> -----Original Message-----<br>
> From: llvm-commits [mailto:<a href="mailto:llvm-commits-bounces@lists.llvm.org">llvm-commits-bounces@<wbr>lists.llvm.org</a>] On Behalf<br>
> Of Alexandre Isoard via llvm-commits<br>
> Sent: Thursday, June 29, 2017 12:29 PM<br>
> To: <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> Subject: [llvm] r306695 - ScalarEvolution: Add URem support<br>
><br>
> Author: aisoard<br>
> Date: Thu Jun 29 09:29:04 2017<br>
> New Revision: 306695<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=306695&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=306695&view=rev</a><br>
> Log:<br>
> ScalarEvolution: Add URem support<br>
><br>
> In LLVM IR the following code:<br>
><br>
>     %r = urem <ty> %t, %b<br>
><br>
> is equivalent to:<br>
><br>
>     %q = udiv <ty> %t, %b<br>
>     %s = mul <ty> nuw %q, %b<br>
>     %r = sub <ty> nuw %t, %q ; (t / b) * b + (t % b) = t<br>
><br>
> As UDiv, Mul and Sub are already supported by SCEV, URem can be<br>
> implemented with minimal effort this way.<br>
><br>
> Note: While SRem and SDiv are also related this way, SCEV does not<br>
> provides SDiv yet.<br>
><br>
><br>
> Added:<br>
>     llvm/trunk/test/Analysis/<wbr>ScalarEvolution/flattened.ll<br>
>     llvm/trunk/test/Analysis/<wbr>ScalarEvolution/urem-0.ll<br>
> Modified:<br>
>     llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h<br>
>     llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/include/<wbr>llvm/Analysis/ScalarEvolution.<wbr>h?rev=306695&r1=3<br>
> 06694&r2=306695&view=diff<br>
> ==============================<wbr>==============================<wbr>==============<br>
> ====<br>
> --- llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h Thu Jun 29 09:29:04<br>
> 2017<br>
> @@ -1244,6 +1244,7 @@ public:<br>
>    }<br>
>    const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS);<br>
>    const SCEV *getUDivExactExpr(const SCEV *LHS, const SCEV *RHS);<br>
> +  const SCEV *getURemExpr(const SCEV *LHS, const SCEV *RHS);<br>
>    const SCEV *getAddRecExpr(const SCEV *Start, const SCEV *Step, const<br>
> Loop *L,<br>
>                              SCEV::NoWrapFlags Flags);<br>
>    const SCEV *getAddRecExpr(<wbr>SmallVectorImpl<const SCEV *> &Operands,<br>
><br>
> Modified: llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/lib/<wbr>Analysis/ScalarEvolution.cpp?<wbr>rev=306695&r1=306694&r<br>
> 2=306695&view=diff<br>
> ==============================<wbr>==============================<wbr>==============<br>
> ====<br>
> --- llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp (original)<br>
> +++ llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp Thu Jun 29 09:29:04 2017<br>
> @@ -2935,6 +2935,29 @@ const SCEV *ScalarEvolution::getMulExpr(<br>
>    return getOrCreateMulExpr(Ops, Flags);<br>
>  }<br>
><br>
> +/// Represents an unsigned remainder expression based on unsigned<br>
> division.<br>
> +const SCEV *ScalarEvolution::getURemExpr(<wbr>const SCEV *LHS,<br>
> +                                         const SCEV *RHS) {<br>
> +  assert(getEffectiveSCEVType(<wbr>LHS->getType()) ==<br>
> +         getEffectiveSCEVType(RHS-><wbr>getType()) &&<br>
> +         "SCEVURemExpr operand types don't match!");<br>
> +<br>
> +  // TODO:<br>
> +  //  - short circuit '%a = %x urem %x --> 0' (why is it not done for<br>
> udiv?)<br>
> +  //  - short circuit '%a = %x urem 0 --> %a' (same as for udiv)<br>
> +  //  - update upper-bound and lower-bound cache for the final result<br>
> +  //    (or improve how subtraction is estimated)<br>
> +<br>
> +  // Short-circuit easy cases<br>
> +  if (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS))<br>
> +    if (RHSC->getValue()->equalsInt(<wbr>1))<br>
> +      return getZero(LHS->getType()); // X urem 1 --> 0<br>
> +<br>
> +  const SCEV *UDiv = getUDivExpr(LHS, RHS);<br>
> +  const SCEV *Mult = getMulExpr(UDiv, RHS, SCEV::FlagNUW);<br>
> +  return getMinusSCEV(LHS, Mult, SCEV::FlagNUW);<br>
> +}<br>
> +<br>
>  /// Get a canonical unsigned division expression, or something simpler if<br>
>  /// possible.<br>
>  const SCEV *ScalarEvolution::getUDivExpr(<wbr>const SCEV *LHS,<br>
> @@ -4095,6 +4118,7 @@ static Optional<BinaryOp> MatchBinaryOp(<br>
>    case Instruction::Sub:<br>
>    case Instruction::Mul:<br>
>    case Instruction::UDiv:<br>
> +  case Instruction::URem:<br>
>    case Instruction::And:<br>
>    case Instruction::Or:<br>
>    case Instruction::AShr:<br>
> @@ -5416,6 +5440,8 @@ const SCEV *ScalarEvolution::createSCEV(<br>
>      }<br>
>      case Instruction::UDiv:<br>
>        return getUDivExpr(getSCEV(BO->LHS), getSCEV(BO->RHS));<br>
> +    case Instruction::URem:<br>
> +      return getURemExpr(getSCEV(BO->LHS), getSCEV(BO->RHS));<br>
>      case Instruction::Sub: {<br>
>        SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;<br>
>        if (BO->Op)<br>
><br>
> Added: llvm/trunk/test/Analysis/<wbr>ScalarEvolution/flattened.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/test/<wbr>Analysis/ScalarEvolution/<wbr>flattened.ll?rev=306695&v<br>
> iew=auto<br>
> ==============================<wbr>==============================<wbr>==============<br>
> ====<br>
> --- llvm/trunk/test/Analysis/<wbr>ScalarEvolution/flattened.ll (added)<br>
> +++ llvm/trunk/test/Analysis/<wbr>ScalarEvolution/flattened.ll Thu Jun 29<br>
> 09:29:04 2017<br>
> @@ -0,0 +1,22 @@<br>
> +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s<br>
> +<br>
> +<br>
> +define void @foo([7 x i8]* %a) {<br>
> +entry:<br>
> +     br label %bb<br>
> +<br>
> +bb:<br>
> +     %idx = phi i64 [ 0, %entry ], [ %idx.incr, %bb ]<br>
> +     %i = udiv i64 %idx, 7<br>
> +     %j = urem i64 %idx, 7<br>
> +     %a.ptr = getelementptr [7 x i8], [7 x i8]* %a, i64 %i, i64 %j<br>
> +; CHECK: %a.ptr<br>
> +; CHECK-NEXT: -->  {%a,+,1}<nw><%bb><br>
> +     %val = load i8, i8* %a.ptr<br>
> +     %idx.incr = add i64 %idx, 1<br>
> +     %test = icmp ne i64 %idx.incr, 35<br>
> +     br i1 %test, label %bb, label %exit<br>
> +<br>
> +exit:<br>
> +     ret void<br>
> +}<br>
><br>
> Added: llvm/trunk/test/Analysis/<wbr>ScalarEvolution/urem-0.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/test/<wbr>Analysis/ScalarEvolution/urem-<br>
> 0.ll?rev=306695&view=auto<br>
> ==============================<wbr>==============================<wbr>==============<br>
> ====<br>
> --- llvm/trunk/test/Analysis/<wbr>ScalarEvolution/urem-0.ll (added)<br>
> +++ llvm/trunk/test/Analysis/<wbr>ScalarEvolution/urem-0.ll Thu Jun 29 09:29:04<br>
> 2017<br>
> @@ -0,0 +1,15 @@<br>
> +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s<br>
> +<br>
> +define i8 @foo(i8 %a) {<br>
> +        %t0 = urem i8 %a, 27<br>
> +; CHECK: %t0<br>
> +; CHECK-NEXT: -->  ((-27 * (%a /u 27)) + %a)<br>
> +        ret i8 %t0<br>
> +}<br>
> +<br>
> +define i8 @bar(i8 %a) {<br>
> +        %t1 = urem i8 %a, 1<br>
> +; CHECK: %t1<br>
> +; CHECK-NEXT: -->  0<br>
> +        ret i8 %t1<br>
> +}<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div>
</div>