[llvm] [ARM] isShifterOpProfitable should return true if we are optimizing for size (PR #158683)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 09:51:28 PDT 2025


https://github.com/AZero13 created https://github.com/llvm/llvm-project/pull/158683

None

>From 7b0c078ac9d765b26c5426461c1c0f18a5cfe3f9 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Mon, 15 Sep 2025 12:49:15 -0400
Subject: [PATCH] [ARM] isShifterOpProfitable should return true if we are
 optimizing for size

---
 llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
index 9ad46df159c20..a201d81507e9d 100644
--- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -542,7 +542,7 @@ bool ARMDAGToDAGISel::isShifterOpProfitable(const SDValue &Shift,
                                             unsigned ShAmt) {
   if (!Subtarget->isLikeA9() && !Subtarget->isSwift())
     return true;
-  if (Shift.hasOneUse())
+  if (Shift.hasOneUse() || CurDAG->shouldOptForSize())
     return true;
   // R << 2 is free.
   return ShOpcVal == ARM_AM::lsl &&



More information about the llvm-commits mailing list