[PATCH] D120648: [DAGCombine] fold (bswap(srl (bswap c), 8*x)) -> (shl c, 8*x)

Chenbing.Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 17 01:37:19 PDT 2022


Chenbing.Zheng marked an inline comment as done.
Chenbing.Zheng added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:9729-9730
+  if (N0->getOpcode() == ISD::SRL && N0.hasOneUse()) {
+    auto *ShAmt = dyn_cast<ConstantSDNode>(N0.getOperand(1));
+    if (ShAmt && ShAmt->getZExtValue() % 8 == 0) {
+      SDValue BSwap = N0->getOperand(0);
----------------
lebedev.ri wrote:
> I'm guessing it isn't worth it to instead check with the knownbits that low 3 bits are zeros?
It seems that x % 8 == 0 is simple and clear.


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

https://reviews.llvm.org/D120648



More information about the llvm-commits mailing list