[llvm] [GlobalISel] Combine [S,U]SUBO (PR #116489)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 16 09:54:40 PST 2024


================
@@ -84,3 +84,75 @@ bool CombinerHelper::matchMergeXAndZero(const MachineInstr &MI,
   };
   return true;
 }
+
+bool CombinerHelper::matchSuboCarryOut(const MachineInstr &MI,
+                                       BuildFnTy &MatchInfo) {
+  const GSubCarryOut *Subo = cast<GSubCarryOut>(&MI);
+
+  Register Dst = Subo->getReg(0);
+  Register LHS = Subo->getLHSReg();
+  Register RHS = Subo->getRHSReg();
+  Register Carry = Subo->getCarryOutReg();
+  LLT DstTy = MRI.getType(Dst);
+  LLT CarryTy = MRI.getType(Carry);
+
+  // Check legality before known bits.
+  if (!isLegalOrBeforeLegalizer({TargetOpcode::G_SUB, {DstTy}}) ||
+      !isConstantLegalOrBeforeLegalizer(CarryTy))
+    return false;
+
+  if (Subo->isSigned()) {
+    // G_SSUBO
+    ConstantRange KBLHS = ConstantRange::fromKnownBits(KB->getKnownBits(LHS),
+                                                       /* IsSigned= */ true);
+    ConstantRange KBRHS = ConstantRange::fromKnownBits(KB->getKnownBits(RHS),
+                                                       /* IsSigned= */ true);
----------------
arsenm wrote:

```suggestion
                                                       /*IsSigned=*/ true);
    ConstantRange KBRHS = ConstantRange::fromKnownBits(KB->getKnownBits(RHS),
                                                       /*IsSigned=*/ true);
```

I think clang-format wants these to be spaceless 

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


More information about the llvm-commits mailing list