[PATCH] D155622: [X86] Recognize standalone `(1 << nbits) - 1` pattern as bzhi

Danila Malyutin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 10:35:40 PDT 2023


danilaml added inline comments.


================
Comment at: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:3510
+  assert((Node->getOpcode() == ISD::ADD ||
+      Node->getOpcode() == ISD::AND || Node->getOpcode() == ISD::SRL) &&
       "Should be either an and-mask, or right-shift after clearing high bits.");
----------------
goldstein.w.n wrote:
> nit: needs clang format.
I think this part is already clang-formatted. I'll recheck.


================
Comment at: llvm/test/CodeGen/X86/extract-lowbits.ll:2948
   ret i64 %masked
 }
 
----------------
goldstein.w.n wrote:
> Can you add a test where `nbits` is masked by vreg width? Just want to make sure those semantics are maintained.
Could elaborate? Which semantics should the test verify?
Do you mean something like `(1 << (nbits & vreg_width)) - 1`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155622



More information about the llvm-commits mailing list