Skip to content

Newpm/expand large fp convert #71027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions llvm/include/llvm/CodeGen/ExpandLargeFpConvert.h
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//
//===----------------------------------------------------------------------===//

#include "llvm/CodeGen/ExpandLargeFpConvert.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/GlobalsModRef.h"
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Passes/PassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down