[llvm] EnableOptimizeLogicalImm for ARM (PR #165177)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 26 15:30:26 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 -- llvm/lib/Target/ARM/ARMISelLowering.cpp --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/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index c8f3f683a..c9e84b62f 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -130,10 +130,10 @@ ARMInterworking("arm-interworking", cl::Hidden,
cl::init(true));
static cl::opt<bool>
-EnableOptimizeLogicalImm("arm-enable-logical-imm", cl::Hidden,
- cl::desc("Enable ARM logical imm instruction "
- "optimization"),
- cl::init(true));
+ EnableOptimizeLogicalImm("arm-enable-logical-imm", cl::Hidden,
+ cl::desc("Enable ARM logical imm instruction "
+ "optimization"),
+ cl::init(true));
static cl::opt<bool> EnableConstpoolPromotion(
"arm-promote-constant", cl::Hidden,
@@ -20145,7 +20145,8 @@ void ARMTargetLowering::computeKnownBitsForTargetNode(const SDValue Op,
}
}
-static bool isLegalLogicalImmediate(unsigned Imm, const ARMSubtarget *Subtarget) {
+static bool isLegalLogicalImmediate(unsigned Imm,
+ const ARMSubtarget *Subtarget) {
// Handle special cases first
if (!Subtarget->isThumb())
return ARM_AM::getSOImmVal(Imm) != -1;
@@ -20160,13 +20161,15 @@ static bool optimizeLogicalImm(SDValue Op, unsigned Imm, const APInt &Demanded,
unsigned NewOpc, const ARMSubtarget *Subtarget) {
unsigned OldImm = Imm, NewImm;
unsigned Mask = ~0U;
-
+
// Return if the immediate is already all zeros, all ones, a bimm32.
if (Imm == 0 || Imm == ~0U || isLegalLogicalImmediate(Imm, Subtarget))
return false;
-
+
// bic/orn/eon
- if ((Op.getOpcode() == ISD::AND || (Subtarget->isThumb2() && Op.getOpcode() == ISD::OR)) && isLegalLogicalImmediate(~Imm, Subtarget))
+ if ((Op.getOpcode() == ISD::AND ||
+ (Subtarget->isThumb2() && Op.getOpcode() == ISD::OR)) &&
+ isLegalLogicalImmediate(~Imm, Subtarget))
return false;
unsigned EltSize = 32;
``````````
</details>
https://github.com/llvm/llvm-project/pull/165177
More information about the llvm-commits
mailing list