[PATCH] D109807: [InstCombine] Narrow type of logical operation chains where one side is an extend

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 15 00:21:06 PDT 2021


lebedev.ri added a comment.

Please

1. Reduce the tests - they should only contain the minimal needed pattern - two extends and two logical ops.
2. Add tests with extra uses - this fold can not be performed when the existing logical ops have other uses.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1635-1638
+  if (match(Op1, m_c_BinOp(m_ZExtOrSExt(m_Value()), m_Value(Z))) &&
+      cast<BinaryOperator>(Op1)->getOpcode() == LogicOpc) {
+    // Get the other cast.
+    match(Op1, m_c_BinOp(m_Value(Y), m_Specific(Z)));
----------------



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1639-1641
+    Value *NewOp = Builder.CreateBinOp(
+        LogicOpc, Builder.CreateBinOp(LogicOpc, Op0, Y), Z, I.getName());
+    return replaceInstUsesWith(I, NewOp);
----------------
You should create the inner op with Builder,
and outer `BinaryOperator::Create`, and just return latter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109807



More information about the llvm-commits mailing list