[llvm] Implement hasOrNot (PR #163995)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 17 10:20:20 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/CodeGen/TargetLowering.h llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.h llvm/lib/Target/ARM/ARMISelLowering.cpp llvm/lib/Target/ARM/ARMISelLowering.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 322c7b906..1feb749b7 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -828,9 +828,7 @@ public:
   }
 
   /// Return true if the target has a bitwise or-not operation:
-  virtual bool hasOrNot(SDValue X) const {
-    return false;
-  }
+  virtual bool hasOrNot(SDValue X) const { return false; }
 
   /// Return true if the target has a bit-test instruction:
   ///   (X & (1 << Y)) ==/!= 0
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 737471bc9..7f141b669 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -12258,8 +12258,8 @@ static SDValue foldVSelectToSignBitSplatMask(SDNode *N, SelectionDAG &DAG) {
   }
 
   // If we have to invert the sign bit mask and OR with -1, only do that
-  // transform if the target has a bitwise 'or not' instruction (the invert is free).
-  // (Cond0 s> -1) ? -1 : N2 --> ~(Cond0 s>> BW-1) | freeze(N2)
+  // transform if the target has a bitwise 'or not' instruction (the invert is
+  // free). (Cond0 s> -1) ? -1 : N2 --> ~(Cond0 s>> BW-1) | freeze(N2)
   if (isAllOnesOrAllOnesSplat(N2) && TLI.hasOrNot(N2)) {
     SDLoc DL(N);
     SDValue ShiftAmt = DAG.getShiftAmountConstant(EltSizeInBits - 1, VT, DL);

``````````

</details>


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


More information about the llvm-commits mailing list