<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:dberlin@dberlin.org" title="Daniel Berlin <dberlin@dberlin.org>"> <span class="fn">Daniel Berlin</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - NewGVN miscompiles select undef"
   href="https://bugs.llvm.org/show_bug.cgi?id=33165">bug 33165</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>FIXED
           </td>
           <td>---
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - NewGVN miscompiles select undef"
   href="https://bugs.llvm.org/show_bug.cgi?id=33165#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - NewGVN miscompiles select undef"
   href="https://bugs.llvm.org/show_bug.cgi?id=33165">bug 33165</a>
              from <span class="vcard"><a class="email" href="mailto:dberlin@dberlin.org" title="Daniel Berlin <dberlin@dberlin.org>"> <span class="fn">Daniel Berlin</span></a>
</span></b>
        <pre>So, this isn't fixed, but it's not newgvn's fault :)
Nor does GVN get it right on purpose :)

The instruction simplifier tells us c and b are equivalent:

   1012   } else if (I->isBinaryOp()) {
   1013     Value *V =
-> 1014         SimplifyBinOp(E->getOpcode(), E->getOperand(0),
E->getOperand(1), SQ);
   1015     if (const Expression *SimplifiedE = checkSimplificationResults(E,
I, V))
   1016       return SimplifiedE;
   1017   } else if (auto *BI = dyn_cast<BitCastInst>(I)) {
(lldb) p E->getOperand(0)
^[[A^[[D(llvm::Value *) $0 = 0x0000000106814560
(lldb) p E->getOperand(1)->dump()
  %b = select i1 %1, i2 %a, i2 undef
(lldb) p E->getOperand(0)->dump()
  %a = xor i2 %0, -1
(lldb)


(IE we call simplifyBinOp on and (%a, %b)


Process 70946 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x00000001019b4f6f opt`(anonymous
namespace)::NewGVN::createExpression(this=0x00007fff5fbfa368,
I=0x0000000106814780) const at NewGVN.cpp:1015
   1012   } else if (I->isBinaryOp()) {
   1013     Value *V =
   1014         SimplifyBinOp(E->getOpcode(), E->getOperand(0),
E->getOperand(1), SQ);
-> 1015     if (const Expression *SimplifiedE = checkSimplificationResults(E,
I, V))
   1016       return SimplifiedE;
   1017   } else if (auto *BI = dyn_cast<BitCastInst>(I)) {
   1018     Value *V =
(lldb) p V->dump()
  %b = select i1 %1, i2 %a, i2 undef
(lldb)

It returns  "%b"</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>