Skip to content

Refactor Lowerings to be consistent with AArch64 (NFC)#196614

Open
LumioseSil wants to merge 1 commit intollvm:mainfrom
LumioseSil:brcc
Open

Refactor Lowerings to be consistent with AArch64 (NFC)#196614
LumioseSil wants to merge 1 commit intollvm:mainfrom
LumioseSil:brcc

Conversation

@LumioseSil
Copy link
Copy Markdown
Contributor

No description provided.

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-backend-arm

Author: LumioseSil (LumioseSil)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/196614.diff

1 Files Affected:

  • (modified) llvm/lib/Target/ARM/ARMISelLowering.cpp (+18-16)
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index ff8df9b33b3cc..c91e2e9b4985b 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -4862,10 +4862,14 @@ SDValue ARMTargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
   SDLoc dl(Op);
   unsigned Opc = Cond.getOpcode();
 
+  bool OptimizeMul =
+      (Opc == ISD::SMULO || Opc == ISD::UMULO) && !Subtarget->isThumb1Only();
   if (Cond.getResNo() == 1 &&
       (Opc == ISD::SADDO || Opc == ISD::UADDO || Opc == ISD::SSUBO ||
-       Opc == ISD::USUBO)) {
-    if (!isTypeLegal(Cond->getValueType(0)))
+       Opc == ISD::USUBO || OptimizeMul)) {
+
+    // Only lower legal XALUO ops.
+    if (!DAG.getTargetLoweringInfo().isTypeLegal(Cond->getValueType(0)))
       return SDValue();
 
     SDValue Value, OverflowCmp;
@@ -5488,7 +5492,7 @@ SDValue ARMTargetLowering::LowerBRCOND(SDValue Op, SelectionDAG &DAG) const {
       (Opc == ISD::SADDO || Opc == ISD::UADDO || Opc == ISD::SSUBO ||
        Opc == ISD::USUBO || OptimizeMul)) {
     // Only lower legal XALUO ops.
-    if (!isTypeLegal(Cond->getValueType(0)))
+    if (!DAG.getTargetLoweringInfo().isTypeLegal(LHS->getValueType(0)))
       return SDValue();
 
     // The actual operation with overflow check.
@@ -5530,12 +5534,12 @@ SDValue ARMTargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) const {
   unsigned Opc = LHS.getOpcode();
   bool OptimizeMul = (Opc == ISD::SMULO || Opc == ISD::UMULO) &&
                       !Subtarget->isThumb1Only();
-  if (LHS.getResNo() == 1 && (isOneConstant(RHS) || isNullConstant(RHS)) &&
+  if (LHS.getResNo() == 1 && isOneConstant(RHS) &&
       (Opc == ISD::SADDO || Opc == ISD::UADDO || Opc == ISD::SSUBO ||
        Opc == ISD::USUBO || OptimizeMul) &&
       (CC == ISD::SETEQ || CC == ISD::SETNE)) {
     // Only lower legal XALUO ops.
-    if (!isTypeLegal(LHS->getValueType(0)))
+    if (!DAG.getTargetLoweringInfo().isTypeLegal(LHS->getValueType(0)))
       return SDValue();
 
     // The actual operation with overflow check.
@@ -5543,16 +5547,16 @@ SDValue ARMTargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) const {
     SDValue ARMcc;
     std::tie(Value, OverflowCmp) = getARMXALUOOp(LHS.getValue(0), DAG, ARMcc);
 
-    if ((CC == ISD::SETNE) != isOneConstant(RHS)) {
-      // Reverse the condition code.
+    if (CC == ISD::SETEQ)
       ARMcc = getInvertedARMCondCode(ARMcc, DAG);
-    }
 
     return DAG.getNode(ARMISD::BRCOND, dl, MVT::Other, Chain, Dest, ARMcc,
                        OverflowCmp);
   }
 
-  if (LHS.getValueType() == MVT::i32) {
+  if (LHS.getValueType().isInteger()) {
+    assert((LHS.getValueType() == RHS.getValueType()) &&
+           (LHS.getValueType() == MVT::i32));
     SDValue ARMcc;
     SDValue Cmp = getARMCmp(LHS, RHS, CC, ARMcc, DAG, dl);
     return DAG.getNode(ARMISD::BRCOND, dl, MVT::Other, Chain, Dest, ARMcc, Cmp);
@@ -5568,17 +5572,15 @@ SDValue ARMTargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) const {
       return Result;
   }
 
+  SDValue Cmp = getVFPCmp(LHS, RHS, DAG, dl);
   ARMCC::CondCodes CondCode, CondCode2;
   FPCCToARMCC(CC, CondCode, CondCode2);
-
   SDValue ARMcc = DAG.getConstant(CondCode, dl, MVT::i32);
-  SDValue Cmp = getVFPCmp(LHS, RHS, DAG, dl);
-  SDValue Ops[] = {Chain, Dest, ARMcc, Cmp};
-  SDValue Res = DAG.getNode(ARMISD::BRCOND, dl, MVT::Other, Ops);
+  SDValue Res =
+      DAG.getNode(ARMISD::BRCOND, dl, MVT::Other, Chain, Dest, ARMcc, Cmp);
   if (CondCode2 != ARMCC::AL) {
-    ARMcc = DAG.getConstant(CondCode2, dl, MVT::i32);
-    SDValue Ops[] = {Res, Dest, ARMcc, Cmp};
-    Res = DAG.getNode(ARMISD::BRCOND, dl, MVT::Other, Ops);
+    SDValue ARMcc2 = DAG.getConstant(CondCode2, dl, MVT::i32);
+    return DAG.getNode(ARMISD::BRCOND, dl, MVT::Other, Res, Dest, ARMcc2, Cmp);
   }
   return Res;
 }

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

🐧 Linux x64 Test Results

  • 195080 tests passed
  • 5193 tests skipped

✅ The build succeeded and all tests passed.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

🪟 Windows x64 Test Results

  • 134476 tests passed
  • 3256 tests skipped

✅ The build succeeded and all tests passed.

@LumioseSil LumioseSil marked this pull request as draft May 8, 2026 19:46
@LumioseSil LumioseSil marked this pull request as ready for review May 8, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant