[llvm] [GISel] Support narrowing G_ICMP with more than 2 parts. (PR #119335)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 23:07:35 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff ef2e590e7b6fb5b0478e5e087006895a07d185c8 fa8e465a27f00e5d6209f604357db093dc8a3baa --extensions cpp -- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index a6997b7a27..dc659aea22 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -1785,12 +1785,11 @@ LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
         }
 
         if (!CmpIn) {
-          MIRBuilder.buildICmp(PartPred, CmpOut,
-                               LHSPartRegs[I], RHSPartRegs[I]);
+          MIRBuilder.buildICmp(PartPred, CmpOut, LHSPartRegs[I],
+                               RHSPartRegs[I]);
         } else {
-          auto Cmp =
-              MIRBuilder.buildICmp(PartPred, ResTy,
-                                   LHSPartRegs[I], RHSPartRegs[I]);
+          auto Cmp = MIRBuilder.buildICmp(PartPred, ResTy, LHSPartRegs[I],
+                                          RHSPartRegs[I]);
           auto CmpEq = MIRBuilder.buildICmp(CmpInst::Predicate::ICMP_EQ, ResTy,
                                             LHSPartRegs[I], RHSPartRegs[I]);
           MIRBuilder.buildSelect(CmpOut, CmpEq, CmpIn, Cmp);
@@ -1812,14 +1811,14 @@ LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
         }
 
         if (!CmpIn) {
-          MIRBuilder.buildICmp(PartPred, CmpOut,
-                               LHSLeftoverRegs[I], RHSLeftoverRegs[I]);
+          MIRBuilder.buildICmp(PartPred, CmpOut, LHSLeftoverRegs[I],
+                               RHSLeftoverRegs[I]);
         } else {
-          auto Cmp =
-              MIRBuilder.buildICmp(PartPred, ResTy,
+          auto Cmp = MIRBuilder.buildICmp(PartPred, ResTy, LHSLeftoverRegs[I],
+                                          RHSLeftoverRegs[I]);
+          auto CmpEq =
+              MIRBuilder.buildICmp(CmpInst::Predicate::ICMP_EQ, ResTy,
                                    LHSLeftoverRegs[I], RHSLeftoverRegs[I]);
-          auto CmpEq = MIRBuilder.buildICmp(CmpInst::Predicate::ICMP_EQ, ResTy,
-                                            LHSLeftoverRegs[I], RHSLeftoverRegs[I]);
           MIRBuilder.buildSelect(CmpOut, CmpEq, CmpIn, Cmp);
         }
 

``````````

</details>


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


More information about the llvm-commits mailing list