[llvm] Newpm/expand large fp convert (PR #71027)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 16:35:59 PDT 2023


https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/71027

>From b87d84041c3cec746ea6f82a1893123a4b249e51 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 2 Nov 2023 15:06:39 +0900
Subject: [PATCH] CodeGen: Port ExpandLargeFpConvert to new PM

---
 .../llvm/CodeGen/ExpandLargeFpConvert.h       | 31 +++++++++++++++++++
 llvm/lib/CodeGen/ExpandLargeFpConvert.cpp     |  8 +++++
 llvm/lib/Passes/PassBuilder.cpp               |  1 +
 llvm/lib/Passes/PassRegistry.def              |  1 +
 .../X86/expand-large-fp-convert-fptosi129.ll  |  1 +
 .../X86/expand-large-fp-convert-fptoui129.ll  |  1 +
 .../X86/expand-large-fp-convert-si129tofp.ll  |  1 +
 .../X86/expand-large-fp-convert-ui129tofp.ll  |  1 +
 8 files changed, 45 insertions(+)
 create mode 100644 llvm/include/llvm/CodeGen/ExpandLargeFpConvert.h

diff --git a/llvm/include/llvm/CodeGen/ExpandLargeFpConvert.h b/llvm/include/llvm/CodeGen/ExpandLargeFpConvert.h
new file mode 100644
index 000000000000000..72e31f04209ddf7
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/ExpandLargeFpConvert.h
@@ -0,0 +1,31 @@
+//===- ExpandLargeFpConvert.h -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
+#define LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class TargetMachine;
+
+class ExpandLargeFpConvertPass
+    : public PassInfoMixin<ExpandLargeFpConvertPass> {
+private:
+  const TargetMachine *TM;
+
+public:
+  explicit ExpandLargeFpConvertPass(const TargetMachine *TM_) : TM(TM_) {}
+
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
diff --git a/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp b/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
index ca8056a53139721..78ad2a25d0e47a9 100644
--- a/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
+++ b/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
@@ -14,6 +14,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/CodeGen/ExpandLargeFpConvert.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Analysis/GlobalsModRef.h"
@@ -653,6 +654,13 @@ class ExpandLargeFpConvertLegacyPass : public FunctionPass {
 };
 } // namespace
 
+PreservedAnalyses ExpandLargeFpConvertPass::run(Function &F,
+                                                FunctionAnalysisManager &FAM) {
+  const TargetSubtargetInfo *STI = TM->getSubtargetImpl(F);
+  return runImpl(F, *STI->getTargetLowering()) ? PreservedAnalyses::none()
+                                               : PreservedAnalyses::all();
+}
+
 char ExpandLargeFpConvertLegacyPass::ID = 0;
 INITIALIZE_PASS_BEGIN(ExpandLargeFpConvertLegacyPass, "expand-large-fp-convert",
                       "Expand large fp convert", false, false)
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index baf7f5590c9fc9c..0d7cac19d44c3a8 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -73,6 +73,7 @@
 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
 #include "llvm/Analysis/UniformityAnalysis.h"
 #include "llvm/CodeGen/ExpandLargeDivRem.h"
+#include "llvm/CodeGen/ExpandLargeFpConvert.h"
 #include "llvm/CodeGen/HardwareLoops.h"
 #include "llvm/CodeGen/TypePromotion.h"
 #include "llvm/IR/DebugInfo.h"
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 5c58e4c9e5fd9db..eb51ccef68c827d 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -446,6 +446,7 @@ FUNCTION_PASS("tsan", ThreadSanitizerPass())
 FUNCTION_PASS("memprof", MemProfilerPass())
 FUNCTION_PASS("declare-to-assign", llvm::AssignmentTrackingPass())
 FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass(TM));
+FUNCTION_PASS("expand-large-fp-convert", ExpandLargeFpConvertPass(TM));
 #undef FUNCTION_PASS
 
 #ifndef FUNCTION_PASS_WITH_PARAMS
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll
index ff460c155c5dba0..77bbd5f0bb4258b 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
+; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
 
 define i129 @halftosi129(half %a) {
 ; CHECK-LABEL: @halftosi129(
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll
index 48c39bbff007b48..67d9eb533a3e7b4 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
+; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
 
 define i129 @halftoui129(half %a) {
 ; CHECK-LABEL: @halftoui129(
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
index d68126a39ad24c9..3961fec5b3be188 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
+; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
 
 define half @si129tohalf(i129 %a) {
 ; CHECK-LABEL: @si129tohalf(
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll
index f7ff2172ea28b6e..e05ff198ecc33b8 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
+; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
 
 define half @ui129tohalf(i129 %a) {
 ; CHECK-LABEL: @ui129tohalf(



More information about the llvm-commits mailing list