[PATCH] D149577: [InstCombine] Improve bswap optimization

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 11:05:55 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:1693
+        Value *NewSwap = Builder.CreateUnaryIntrinsic(Intrinsic::bswap, Y);
+        return BinaryOperator::Create(Op, OldSwap, NewSwap);
+      } else if (match(Y, m_BSwap(m_Value(OldSwap))) && Y->hasOneUse()) {
----------------
I don't see how this is correct if we only have 1 bswap:
https://alive2.llvm.org/ce/z/zBErQk

Also this apples for `bitreverse` as well.


================
Comment at: llvm/test/Transforms/InstCombine/bswap-fold.ll:542
 
+; Issue#62236
+; Fold: BSWAP( OP( BSWAP(x), y ) ) -> OP( x, BSWAP(y) )
----------------
Can you split the new tests to a seperate patch so we can see the diff generated?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149577



More information about the llvm-commits mailing list