Skip to content

Conversation

@sumesh-s-mcw
Copy link

No description provided.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Mar 30, 2025

@llvm/pr-subscribers-llvm-globalisel

Author: None (sumesh-s-mcw)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (+10-3)
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index ac68eb55a6fd5..cef6f446f9854 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
+#include "llvm/CodeGen/CodeGenCommonISel.h"
 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
 #include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
 #include "llvm/CodeGen/GlobalISel/GISelValueTracking.h"
@@ -9100,8 +9101,12 @@ LegalizerHelper::lowerISFPCLASS(MachineInstr &MI) {
     return Legalized;
   }
 
-  // TODO: Try inverting the test with getInvertedFPClassTest like the DAG
-  // version
+  bool isInverted = false;
+  FPClassTest InvertedTest = llvm::invertFPClassTestIfSimpler(Mask, false);
+  if (Inverse != fcNone) {
+    Mask = InvertedTest;
+    isInverted = true;
+  }
 
   unsigned BitSize = SrcTy.getScalarSizeInBits();
   const fltSemantics &Semantics = getFltSemanticForLLT(SrcTy.getScalarType());
@@ -9252,7 +9257,9 @@ LegalizerHelper::lowerISFPCLASS(MachineInstr &MI) {
     }
     appendToRes(NormalRes);
   }
-
+  if (isInverted) {
+    Res = MIRBuilder.buildNot(DstTy, Res);
+  }
   MIRBuilder.buildCopy(DstReg, Res);
   MI.eraseFromParent();
   return Legalized;

@sumesh-s-mcw sumesh-s-mcw reopened this Mar 30, 2025
@sumesh-s-mcw sumesh-s-mcw marked this pull request as draft March 30, 2025 19:25
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.

2 participants