[llvm] FEAT : Added InvertedFPClassTest in LegalizerHelper (PR #133651)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 30 12:19:59 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-globalisel
Author: None (sumesh-s-mcw)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/133651.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (+10-3)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/133651
More information about the llvm-commits
mailing list