[PATCH] D65802: [DAGCombiner] Fold br(xor(xor(x, y), 1)) as br(x == y)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 03:58:06 PDT 2019


spatel added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:13495-13497
   // Transform br(xor(x, y)) -> br(x != y)
   // Transform br(xor(xor(x,y), 1)) -> br (x == y)
   if (N.getOpcode() == ISD::XOR) {
----------------
That comment makes me nervous given the logic. Can we assert that N has one user and that user is a br?


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:13526-13527
     if (Op0.getOpcode() != ISD::SETCC && Op1.getOpcode() != ISD::SETCC) {
       bool Equal = false;
-      if (isOneConstant(Op0) && Op0.hasOneUse() &&
+      if (isOneConstant(Op1) && Op0.hasOneUse() &&
           Op0.getOpcode() == ISD::XOR) {
----------------
lebedev.ri wrote:
> ```
> // xor (xor %a, %b), -1
> ```
The code is checking for '1' not '-1'. 
Can we assert that the types are i1 and/or the code should be changed to use llvm::isBitwiseNot()?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65802/new/

https://reviews.llvm.org/D65802





More information about the llvm-commits mailing list