[flang-commits] [flang] [flang] Support -mvscale-min and mvscale-max on all targets (PR #74633)

Philip Reames via flang-commits flang-commits at lists.llvm.org
Wed Dec 6 09:43:31 PST 2023


https://github.com/preames created https://github.com/llvm/llvm-project/pull/74633

We have other targets with scalable vectors (e.g.RISC-V), and there doesn't seem to be any particular reason these options can't be used on those targets.

>From d2dfaf4b956ae80871d7b7963546748828c70635 Mon Sep 17 00:00:00 2001
From: Philip Reames <preames at rivosinc.com>
Date: Wed, 6 Dec 2023 09:36:39 -0800
Subject: [PATCH] [flang] Support -mvscale-min and mvscale-max on all targets

We have other targets with scalable vectors (e.g.RISC-V), and there doesn't
seem to be any particular reason these options can't be used on those targets.
---
 flang/lib/Frontend/FrontendActions.cpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 1be95cc27f42c..a9eaae6dd1c49 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -824,8 +824,8 @@ void CodeGenAction::lowerHLFIRToFIR() {
 // TODO: We should get this from TargetInfo. However, that depends on
 // too much of clang, so for now, replicate the functionality.
 static std::optional<std::pair<unsigned, unsigned>>
-getVScaleRange(CompilerInstance &ci,
-               const Fortran::frontend::LangOptions &langOpts) {
+getVScaleRange(CompilerInstance &ci) {
+  const auto &langOpts = ci.getInvocation().getLangOpts();
   if (langOpts.VScaleMin || langOpts.VScaleMax)
     return std::pair<unsigned, unsigned>(
         langOpts.VScaleMin ? langOpts.VScaleMin : 1, langOpts.VScaleMax);
@@ -860,13 +860,9 @@ void CodeGenAction::generateLLVMIR() {
   const auto targetOpts = ci.getInvocation().getTargetOpts();
   const llvm::Triple triple(targetOpts.triple);
 
-  // Only get the vscale range if AArch64.
-  if (triple.isAArch64()) {
-    auto langOpts = ci.getInvocation().getLangOpts();
-    if (auto vsr = getVScaleRange(ci, langOpts)) {
-      config.VScaleMin = vsr->first;
-      config.VScaleMax = vsr->second;
-    }
+  if (auto vsr = getVScaleRange(ci)) {
+    config.VScaleMin = vsr->first;
+    config.VScaleMax = vsr->second;
   }
 
   // Create the pass pipeline



More information about the flang-commits mailing list