[llvm-bugs] [Bug 33165] NewGVN miscompiles select undef

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 25 08:51:05 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33165

Daniel Berlin <dberlin at dberlin.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED

--- Comment #3 from Daniel Berlin <dberlin at dberlin.org> ---
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"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170525/ed0c7824/attachment.html>


More information about the llvm-bugs mailing list