[llvm] [RISCV][NFC] Simplify ISD::SELECT Legality (PR #142650)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 3 10:56:55 PDT 2025


https://github.com/lenary created https://github.com/llvm/llvm-project/pull/142650

ISD::SELECT is legal by default, so this change to the conditional makes it clearer that XTHeadCondMov and XMipsCMove both leave this operation legal rather than custom expanding it.

>From 7e71b01ded3c5260b96bfb7764177e843d44b2ff Mon Sep 17 00:00:00 2001
From: Sam Elliott <quic_aelliott at quicinc.com>
Date: Tue, 3 Jun 2025 09:31:31 -0700
Subject: [PATCH] [RISCV][NFC] Simplify ISD::SELECT Legality

ISD::SELECT is legal by default, so this change to the conditional makes
it clearer that XTHeadCondMov and XMipsCMove both leave this operation
legal rather than custom expanding it.
---
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 6e8e4ac1c6a95..6158e51346d77 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -434,9 +434,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
     setOperationAction(ISD::ABS, MVT::i32, Custom);
   }
 
-  if (Subtarget.useCCMovInsn())
-    setOperationAction(ISD::SELECT, XLenVT, Legal);
-  else if (!Subtarget.hasVendorXTHeadCondMov())
+  if (!Subtarget.useCCMovInsn() && !Subtarget.hasVendorXTHeadCondMov())
     setOperationAction(ISD::SELECT, XLenVT, Custom);
 
   if (Subtarget.hasVendorXqcia() && !Subtarget.is64Bit()) {



More information about the llvm-commits mailing list