[llvm] Added InvertedFPClassTest in legalizerHelper (PR #133403)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 30 12:34:58 PDT 2025
https://github.com/sumesh-s-mcw updated https://github.com/llvm/llvm-project/pull/133403
>From 0ffc7410e5c6cada94e3876eab2a9dad0b0cc49a Mon Sep 17 00:00:00 2001
From: sumesh-s-mcw <sumesh.suresh at multicorewareinc.com>
Date: Mon, 31 Mar 2025 00:59:28 +0530
Subject: [PATCH] FEAT : Added InvertedFPClassTest in LegalizerHelper
---
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index ac68eb55a6fd5..093b975fc9154 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 (InvertedTest != 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;
More information about the llvm-commits
mailing list