<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><font size="-1">Reid,</font></p>
    <p><font size="-1">That's the transformation that I suspected.  I
        added a test just like this to the patch using the triple for
        Windows.</font></p>
    <p><font size="-1">Thank you,</font><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Evandro Menezes

</pre>
    <div class="moz-cite-prefix">On 08/30/2018 01:56 PM, Reid Kleckner
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CACs=ty+CBg97u8iakrhZp-jynR0pJ2AxN2WkCpaacM6FQumzeQ@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr">I don't have time to try it, but I made this
        reduction:
        <div>
          <pre id="gmail-hterm:copy-to-clipboard-source" style="color:rgb(0,0,0)">target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"                              
target triple = "x86_64-unknown-windows-msvc19.11.0"                                     
@a = dso_local global double 0.000000e+00, align 8                                       
define dso_local double @b() {                                                           
entry:                                                                                   
  %0 = load double, double* @a, align 8                                                  
  %call = call double @pow(double 2.000000e+00, double %0)                               
  ret double %call                                                                       
}                                                                                        
declare dso_local double @pow(double, double)  </pre>
          I suspect the triple is the important part.</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr">On Thu, Aug 30, 2018 at 11:01 AM Evandro Menezes
          <<a href="mailto:e.menezes@samsung.com"
            moz-do-not-send="true">e.menezes@samsung.com</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div text="#000000" bgcolor="#FFFFFF">
            <p><font size="-1">Hey, Reid.</font></p>
            <p><font size="-1">I don't have access to </font>a Windows
              machine.  Would it be possible for you to try the new
              patch at <a
                class="m_360901350220625257moz-txt-link-freetext"
                href="https://reviews.llvm.org/D49273" target="_blank"
                moz-do-not-send="true">https://reviews.llvm.org/D49273</a>?</p>
            <p>Thank you,<br>
            </p>
            <pre class="m_360901350220625257moz-signature" cols="72">-- 
Evandro Menezes

</pre>
            <div class="m_360901350220625257moz-cite-prefix">On
              08/29/2018 06:19 PM, Reid Kleckner wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div dir="ltr">It's a name LLVM makes up when mangling
                  unnamed private globals like @0 = global i32. I'm not
                  yet sure how your change causes these problems, but
                  I've gone ahead and reverted your change in r340991
                  and am starting a reduction now. I have to run soon so
                  I won't be able to share it until tomorrow, most
                  likely.</div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr">On Wed, Aug 29, 2018 at 4:05 PM Evandro
                  Menezes <<a href="mailto:e.menezes@samsung.com"
                    target="_blank" moz-do-not-send="true">e.menezes@samsung.com</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div text="#000000" bgcolor="#FFFFFF">
                    <p><font size="-1">Reid,</font></p>
                    <p><font size="-1">Can you please provide an
                        indication of what this symbol is about, as I'm
                        not familiar with the VS linker?</font></p>
                    <p><font size="-1">Thank you,</font><br>
                    </p>
                    <pre class="m_360901350220625257m_-1038198312386054750moz-signature" cols="72">-- 
Evandro Menezes

</pre>
                    <div
                      class="m_360901350220625257m_-1038198312386054750moz-cite-prefix">On
                      08/29/2018 05:50 PM, Reid Kleckner wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div dir="ltr">My bisection shows that this
                          broke the clang stage 2 build:
                          <div><a
href="http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/13525"
                              target="_blank" moz-do-not-send="true">http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/13525</a><br>
                          </div>
                          <div><br>
                          </div>
                          <div>We end up with references to __unnamed_1
                            globals that are unresolved. I'll revert and
                            get a reproducer.</div>
                        </div>
                      </div>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr">On Wed, Aug 29, 2018 at 11:00 AM
                          Evandro Menezes via llvm-commits <<a
                            href="mailto:llvm-commits@lists.llvm.org"
                            target="_blank" moz-do-not-send="true">llvm-commits@lists.llvm.org</a>>
                          wrote:<br>
                        </div>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">Author: evandro<br>
                          Date: Wed Aug 29 10:59:34 2018<br>
                          New Revision: 340947<br>
                          <br>
                          URL: <a
                            href="http://llvm.org/viewvc/llvm-project?rev=340947&view=rev"
                            rel="noreferrer" target="_blank"
                            moz-do-not-send="true">http://llvm.org/viewvc/llvm-project?rev=340947&view=rev</a><br>
                          Log:<br>
                          [InstCombine] Expand the simplification of
                          pow() into exp2()<br>
                          <br>
                          Generalize the simplification of `pow(2.0, y)`
                          to `pow(2.0 ** n, y)` for all<br>
                          scalar and vector types.<br>
                          <br>
                          This improvement helps some benchmarks in SPEC
                          CPU2000 and CPU2006, such as<br>
                          252.eon, 447.dealII, 453.povray.  Otherwise,
                          no significant regressions on<br>
                          x86-64 or A64.<br>
                          <br>
                          Differential revision: <a
                            href="https://reviews.llvm.org/D49273"
                            rel="noreferrer" target="_blank"
                            moz-do-not-send="true">https://reviews.llvm.org/D49273</a><br>
                          <br>
                          Modified:<br>
                             
                          llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp<br>
                             
                          llvm/trunk/test/Transforms/InstCombine/pow-1.ll<br>
                          <br>
                          Modified:
                          llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp<br>
                          URL: <a
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=340947&r1=340946&r2=340947&view=diff"
                            rel="noreferrer" target="_blank"
                            moz-do-not-send="true">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=340947&r1=340946&r2=340947&view=diff</a><br>
==============================================================================<br>
                          ---
                          llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
                          (original)<br>
                          +++
                          llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
                          Wed Aug 29 10:59:34 2018<br>
                          @@ -13,6 +13,7 @@<br>
 //===----------------------------------------------------------------------===//<br>
                          <br>
                           #include
                          "llvm/Transforms/Utils/SimplifyLibCalls.h"<br>
                          +#include "llvm/ADT/APSInt.h"<br>
                           #include "llvm/ADT/SmallString.h"<br>
                           #include "llvm/ADT/StringMap.h"<br>
                           #include "llvm/ADT/Triple.h"<br>
                          @@ -1183,12 +1184,13 @@ static Value
                          *getPow(Value *InnerChain[3<br>
                           }<br>
                          <br>
                           /// Use exp{,2}(x * y) for pow(exp{,2}(x),
                          y);<br>
                          -/// exp2(x) for pow(2.0, x); exp10(x) for
                          pow(10.0, x).<br>
                          +/// exp2(n * x) for pow(2.0 ** n, x);
                          exp10(x) for pow(10.0, x).<br>
                           Value
                          *LibCallSimplifier::replacePowWithExp(CallInst
                          *Pow, IRBuilder<> &B) {<br>
                             Value *Base = Pow->getArgOperand(0),
                          *Expo = Pow->getArgOperand(1);<br>
                             AttributeList Attrs =
                          Pow->getCalledFunction()->getAttributes();<br>
                             Module *Mod = Pow->getModule();<br>
                             Type *Ty = Pow->getType();<br>
                          +  bool Ignored;<br>
                          <br>
                             // Evaluate special cases related to a
                          nested function as the base.<br>
                          <br>
                          @@ -1232,10 +1234,28 @@ Value
                          *LibCallSimplifier::replacePowWith<br>
                          <br>
                             // Evaluate special cases related to a
                          constant base.<br>
                          <br>
                          -  // pow(2.0, x) -> exp2(x)<br>
                          -  if (match(Base, m_SpecificFP(2.0))) {<br>
                          -    Value *Exp2 =
                          Intrinsic::getDeclaration(Mod,
                          Intrinsic::exp2, Ty);<br>
                          -    return B.CreateCall(Exp2, Expo, "exp2");<br>
                          +  const APFloat *BaseF;<br>
                          +  if (!match(Pow->getArgOperand(0),
                          m_APFloat(BaseF)))<br>
                          +    return nullptr;<br>
                          +<br>
                          +  // pow(2.0 ** n, x) -> exp2(n * x)<br>
                          +  APFloat BaseR = APFloat(1.0);<br>
                          +  BaseR.convert(BaseF->getSemantics(),
                          APFloat::rmTowardZero, &Ignored);<br>
                          +  BaseR = BaseR / *BaseF;<br>
                          +  bool IsInteger    = BaseF->isInteger(),<br>
                          +       IsReciprocal = BaseR.isInteger();<br>
                          +  const APFloat *NF = IsReciprocal ?
                          &BaseR : BaseF;<br>
                          +  APSInt NI(64, false);<br>
                          +  if ((IsInteger || IsReciprocal) &&<br>
                          +      !NF->convertToInteger(NI,
                          APFloat::rmTowardZero, &Ignored)
                          &&<br>
                          +      NI > 1 && NI.isPowerOf2()) {<br>
                          +    double N = NI.logBase2() * (IsReciprocal
                          ? -1.0 : 1.0);<br>
                          +    Value *FMul = B.CreateFMul(Expo,
                          ConstantFP::get(Ty, N), "mul");<br>
                          +    if (Pow->doesNotAccessMemory())<br>
                          +      return
                          B.CreateCall(Intrinsic::getDeclaration(Mod,
                          Intrinsic::exp2, Ty),<br>
                          +                          FMul, "exp2");<br>
                          +    else<br>
                          +      return emitUnaryFloatFnCall(FMul,
                          TLI->getName(LibFunc_exp2), B, Attrs);<br>
                             }<br>
                          <br>
                             // pow(10.0, x) -> exp10(x)<br>
                          <br>
                          Modified:
                          llvm/trunk/test/Transforms/InstCombine/pow-1.ll<br>
                          URL: <a
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/pow-1.ll?rev=340947&r1=340946&r2=340947&view=diff"
                            rel="noreferrer" target="_blank"
                            moz-do-not-send="true">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/pow-1.ll?rev=340947&r1=340946&r2=340947&view=diff</a><br>
==============================================================================<br>
                          ---
                          llvm/trunk/test/Transforms/InstCombine/pow-1.ll
                          (original)<br>
                          +++
                          llvm/trunk/test/Transforms/InstCombine/pow-1.ll
                          Wed Aug 29 10:59:34 2018<br>
                          @@ -16,6 +16,7 @@<br>
                          <br>
                           declare float @powf(float, float) nounwind
                          readonly<br>
                           declare double @pow(double, double) nounwind
                          readonly<br>
                          +declare double @llvm.pow.f64(double, double)<br>
                           declare <2 x float>
                          @llvm.pow.v2f32(<2 x float>, <2 x
                          float>) nounwind readonly<br>
                           declare <2 x double>
                          @llvm.pow.v2f64(<2 x double>, <2 x
                          double>) nounwind readonly<br>
                          <br>
                          @@ -57,18 +58,18 @@ define <2 x double>
                          @test_simplify2v(<2<br>
                          <br>
                           define float @test_simplify3(float %x) {<br>
                           ; ANY-LABEL: @test_simplify3(<br>
                          -; ANY-NEXT:    [[EXP2:%.*]] = call float
                          @llvm.exp2.f32(float [[X:%.*]])<br>
                          -; ANY-NEXT:    ret float [[EXP2]]<br>
                          +; ANY-NEXT:    [[EXP2F:%.*]] = call float
                          @exp2f(float [[X:%.*]]) [[NUW_RO:#[0-9]+]]<br>
                          +; ANY-NEXT:    ret float [[EXP2F]]<br>
                           ;<br>
                             %retval = call float @powf(float 2.0, float
                          %x)<br>
                             ret float %retval<br>
                           }<br>
                          <br>
                          -; TODO: Should result in exp2(-2.0 * x).<br>
                           define double @test_simplify3n(double %x) {<br>
                           ; ANY-LABEL: @test_simplify3n(<br>
                          -; ANY-NEXT:    [[RETVAL:%.*]] = call double
                          @pow(double 2.500000e-01, double [[X:%.*]])<br>
                          -; ANY-NEXT:    ret double [[RETVAL]]<br>
                          +; ANY-NEXT:    [[MUL:%.*]] = fmul double
                          [[X:%.*]], -2.000000e+00<br>
                          +; ANY-NEXT:    [[EXP2:%.*]] = call double
                          @exp2(double [[MUL]]) [[NUW_RO]]<br>
                          +; ANY-NEXT:    ret double [[EXP2]]<br>
                           ;<br>
                             %retval = call double @pow(double 0.25,
                          double %x)<br>
                             ret double %retval<br>
                          @@ -83,11 +84,11 @@ define <2 x float>
                          @test_simplify3v(<2 x<br>
                             ret <2 x float> %retval<br>
                           }<br>
                          <br>
                          -; TODO: Should result in exp2(2.0 * x).<br>
                           define <2 x double>
                          @test_simplify3vn(<2 x double> %x) {<br>
                           ; ANY-LABEL: @test_simplify3vn(<br>
                          -; ANY-NEXT:    [[RETVAL:%.*]] = call <2 x
                          double> @llvm.pow.v2f64(<2 x double>
                          <double 4.000000e+00, double
                          4.000000e+00>, <2 x double>
                          [[X:%.*]])<br>
                          -; ANY-NEXT:    ret <2 x double>
                          [[RETVAL]]<br>
                          +; ANY-NEXT:    [[MUL:%.*]] = fmul <2 x
                          double> [[X:%.*]], <double 2.000000e+00,
                          double 2.000000e+00><br>
                          +; ANY-NEXT:    [[EXP2:%.*]] = call <2 x
                          double> @llvm.exp2.v2f64(<2 x double>
                          [[MUL]])<br>
                          +; ANY-NEXT:    ret <2 x double>
                          [[EXP2]]<br>
                           ;<br>
                             %retval = call <2 x double>
                          @llvm.pow.v2f64(<2 x double> <double
                          4.0, double 4.0>, <2 x double> %x)<br>
                             ret <2 x double> %retval<br>
                          @@ -95,18 +96,18 @@ define <2 x double>
                          @test_simplify3vn(<2<br>
                          <br>
                           define double @test_simplify4(double %x) {<br>
                           ; ANY-LABEL: @test_simplify4(<br>
                          -; ANY-NEXT:    [[EXP2:%.*]] = call double
                          @llvm.exp2.f64(double [[X:%.*]])<br>
                          +; ANY-NEXT:    [[EXP2:%.*]] = call double
                          @exp2(double [[X:%.*]]) [[NUW_RO]]<br>
                           ; ANY-NEXT:    ret double [[EXP2]]<br>
                           ;<br>
                             %retval = call double @pow(double 2.0,
                          double %x)<br>
                             ret double %retval<br>
                           }<br>
                          <br>
                          -; TODO: Should result in exp2f(3.0 * x).<br>
                           define float @test_simplify4n(float %x) {<br>
                           ; ANY-LABEL: @test_simplify4n(<br>
                          -; ANY-NEXT:    [[RETVAL:%.*]] = call float
                          @powf(float 8.000000e+00, float [[X:%.*]])<br>
                          -; ANY-NEXT:    ret float [[RETVAL]]<br>
                          +; ANY-NEXT:    [[MUL:%.*]] = fmul float
                          [[X:%.*]], 3.000000e+00<br>
                          +; ANY-NEXT:    [[EXP2F:%.*]] = call float
                          @exp2f(float [[MUL]]) [[NUW_RO]]<br>
                          +; ANY-NEXT:    ret float [[EXP2F]]<br>
                           ;<br>
                             %retval = call float @powf(float 8.0, float
                          %x)<br>
                             ret float %retval<br>
                          @@ -121,11 +122,11 @@ define <2 x
                          double> @test_simplify4v(<2<br>
                             ret <2 x double> %retval<br>
                           }<br>
                          <br>
                          -; TODO: Should result in exp2f(-x).<br>
                           define <2 x float>
                          @test_simplify4vn(<2 x float> %x) {<br>
                           ; ANY-LABEL: @test_simplify4vn(<br>
                          -; ANY-NEXT:    [[RETVAL:%.*]] = call <2 x
                          float> @llvm.pow.v2f32(<2 x float>
                          <float 5.000000e-01, float
                          5.000000e-01>, <2 x float> [[X:%.*]])<br>
                          -; ANY-NEXT:    ret <2 x float>
                          [[RETVAL]]<br>
                          +; ANY-NEXT:    [[MUL:%.*]] = fsub <2 x
                          float> <float -0.000000e+00, float
                          -0.000000e+00>, [[X:%.*]]<br>
                          +; ANY-NEXT:    [[EXP2:%.*]] = call <2 x
                          float> @llvm.exp2.v2f32(<2 x float>
                          [[MUL]])<br>
                          +; ANY-NEXT:    ret <2 x float> [[EXP2]]<br>
                           ;<br>
                             %retval = call <2 x float>
                          @llvm.pow.v2f32(<2 x float> <float
                          0.5, float 0.5>, <2 x float> %x)<br>
                             ret <2 x float> %retval<br>
                          @@ -169,7 +170,7 @@ define <2 x double>
                          @test_simplify6v(<2<br>
                          <br>
                           define float @test_simplify7(float %x) {<br>
                           ; ANY-LABEL: @test_simplify7(<br>
                          -; ANY-NEXT:    [[SQRTF:%.*]] = call float
                          @sqrtf(float [[X:%.*]]) [[NUW_RO:#[0-9]+]]<br>
                          +; ANY-NEXT:    [[SQRTF:%.*]] = call float
                          @sqrtf(float [[X:%.*]]) [[NUW_RO]]<br>
                           ; ANY-NEXT:    [[ABS:%.*]] = call float
                          @llvm.fabs.f32(float [[SQRTF]])<br>
                           ; ANY-NEXT:    [[ISINF:%.*]] = fcmp oeq float
                          [[X]], 0xFFF0000000000000<br>
                           ; ANY-NEXT:    [[TMP1:%.*]] = select i1
                          [[ISINF]], float 0x7FF0000000000000, float
                          [[ABS]]<br>
                          @@ -330,7 +331,6 @@ define <2 x double>
                          @pow_neg1_double_fas<br>
                             ret <2 x double> %r<br>
                           }<br>
                          <br>
                          -declare double @llvm.pow.f64(double %Val,
                          double %Power)<br>
                           define double @test_simplify17(double %x) {<br>
                           ; ANY-LABEL: @test_simplify17(<br>
                           ; ANY-NEXT:    [[SQRT:%.*]] = call double
                          @llvm.sqrt.f64(double [[X:%.*]])<br>
                          <br>
                          <br>
_______________________________________________<br>
                          llvm-commits mailing list<br>
                          <a href="mailto:llvm-commits@lists.llvm.org"
                            target="_blank" moz-do-not-send="true">llvm-commits@lists.llvm.org</a><br>
                          <a
                            href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits"
                            rel="noreferrer" target="_blank"
                            moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
                        </blockquote>
                      </div>
                    </blockquote>
                    <br>
                  </div>
                </blockquote>
              </div>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>