[PATCH] D85687: [Instcombine] Fix uses of undef (PR46940)

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 13:46:20 PDT 2020


kazu created this revision.
kazu added reviewers: spatel, aqjune, nikic, lebedev.ri.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
kazu requested review of this revision.

Without this patch, we attempt to distribute And over Xor even in
unsafe circumstances like so:

  undef & (true ^ true)  ==>  (undef & true) ^ (undef & true)

and evaluate it to undef instead of false.  Note that "true ^ true"
may show up implicitly with one true being part of a PHI node.

This patch fixes the problem by teaching SimplifyAndInst and
SimplifyUsingDistributiveLaws to not use undef as part of
simplifications when they distribute And over Xor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85687

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/dont-distribute-phi.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85687.284496.patch
Type: text/x-patch
Size: 4197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/a583ed57/attachment.bin>


More information about the llvm-commits mailing list