[llvm] [RISCV][GISel] Added GISelPRedicateCodes to LeadingOnes*Mask (PR #119886)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 09:38:04 PST 2024


================
@@ -493,7 +493,15 @@ def LeadingOnesMask : PatLeaf<(imm), [{
   if (!N->hasOneUse())
     return false;
   return !isInt<32>(N->getSExtValue()) && isMask_64(~N->getSExtValue());
-}], TrailingZeros>;
+}], TrailingZeros> {
+  let GISelPredicateCode = [{
+    if (!MRI.hasOneNonDBGUse(MI.getOperand(0).getReg()))
+      return false;
+    const auto &MO = MI.getOperand(1);
----------------
lenary wrote:

@topperc i presume these are looking at different operand indexes because `MI` is a `G_CONSTANT` (or `G_FCONSTANT`)? or is something else going on here. What validates that this MI is actually what is being expected? I looked through some of the code, but definitely was out of my depth (and I don't think the other GISelPredicates seem to check this either.

https://github.com/llvm/llvm-project/pull/119886


More information about the llvm-commits mailing list