[llvm] [RISCV] Don't transfer (select c, t, f) to Zicond when optimizing for size (PR #163501)

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 15 22:27:01 PDT 2025


================
@@ -9458,8 +9458,11 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {
     }
 
     // (select c, t, f) -> (or (czero_eqz t, c), (czero_nez f, c))
-    // Unless we have the short forward branch optimization.
-    if (!Subtarget.hasConditionalMoveFusion())
+    // Unless we have the short forward branch optimization or CondV has one use
+    // when optimizaing for size.
+    if (!Subtarget.hasConditionalMoveFusion() &&
+        (!DAG.shouldOptForSize() ||
+         (DAG.shouldOptForSize() && CondV.hasOneUse())))
----------------
tclin914 wrote:

Thanks.

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


More information about the llvm-commits mailing list