[PATCH] D113202: [DAG] FoldConstantArithmetic - fold bitlogic(bitcast(x),bitcast(y)) -> bitcast(bitlogic(x,y))

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 10:53:16 PDT 2021


RKSimon added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5298
+  // TODO: Can we generalize this and fold any bitcasted constant data?
+  if (ISD::isBitwiseLogicOp(Opcode) && N1->getOpcode() == ISD::BITCAST &&
+      N2->getOpcode() == ISD::BITCAST) {
----------------
lebedev.ri wrote:
> Can we have cases where only one of operands is a bitcast / both are bitcasts but only one should be peeked?
Yes - and if we ever generalize this to work with any opcode that's what we'll end up having to do (probably in a similar way to the per-element-computeKnownBits code you did a few months ago?).

Its whether such IR actually appears for just this bitlogic case - this tends to mainly occur on 32-bit targets with vXi64 BUILD_VECTORs which get legalized to v2Xi32.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113202



More information about the llvm-commits mailing list