From 8ce13bc93be423d2a368f804ed18edf21b489c2e Mon Sep 17 00:00:00 2001 From: Masoud Ataei Date: Fri, 4 Feb 2022 13:24:22 -0800 Subject: [PATCH] [PowerPC] Option controling scalar MASS convertion differential: https://reviews.llvm.org/D119035 reviewer: bmahjour --- llvm/include/llvm/Target/TargetOptions.h | 5 ++++- llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 3 ++- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | 11 ++++++++++- llvm/test/CodeGen/PowerPC/O3-pipeline.ll | 1 - llvm/test/CodeGen/PowerPC/lower-intrinsics-afn-mass.ll | 4 ++-- llvm/test/CodeGen/PowerPC/lower-intrinsics-fast-mass.ll | 4 ++-- llvm/test/CodeGen/PowerPC/lower-intrinsics-nofast-mass.ll | 4 ++-- llvm/test/CodeGen/PowerPC/lower-scalar-mass-afn.ll | 4 ++-- llvm/test/CodeGen/PowerPC/lower-scalar-mass-fast.ll | 4 ++-- llvm/test/CodeGen/PowerPC/lower-scalar-mass-nofast.ll | 4 ++-- .../CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-afn.ll | 4 ++-- .../CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll | 4 ++-- .../PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll | 4 ++-- 13 files changed, 34 insertions(+), 22 deletions(-) diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index a636c48..caa6823 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -142,7 +142,7 @@ namespace llvm { SupportsDebugEntryValues(false), EnableDebugEntryValues(false), ValueTrackingVariableLocations(false), ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false), DebugStrictDwarf(false), - Hotpatch(false), + Hotpatch(false), PPCGenScalarMASSEntries(false), FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {} /// DisableFramePointerElim - This returns true if frame pointer elimination @@ -345,6 +345,9 @@ namespace llvm { /// Emit the hotpatch flag in CodeView debug. unsigned Hotpatch : 1; + /// Enables scalar MASS conversions + unsigned PPCGenScalarMASSEntries : 1; + /// Name of the stack usage file (i.e., .su file) if user passes /// -fstack-usage. If empty, it can be implied that -fstack-usage is not /// passed on the command line. diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 10d59d1..9e08487f0 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -382,7 +382,8 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM, // MASS transformation for LLVM intrinsics with replicating fast-math flag // to be consistent to PPCGenScalarMASSEntries pass - if (TM.getOptLevel() == CodeGenOpt::Aggressive){ + if (TM.getOptLevel() == CodeGenOpt::Aggressive && + TM.Options.PPCGenScalarMASSEntries) { setOperationAction(ISD::FSIN , MVT::f64, Custom); setOperationAction(ISD::FCOS , MVT::f64, Custom); setOperationAction(ISD::FPOW , MVT::f64, Custom); diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp index 1efd196..b64eec1 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -97,6 +97,13 @@ static cl::opt ReduceCRLogical("ppc-reduce-cr-logicals", cl::desc("Expand eligible cr-logical binary ops to branches"), cl::init(true), cl::Hidden); + +static cl::opt EnablePPCGenScalarMASSEntries( + "enable-ppc-gen-scalar-mass", cl::init(false), + cl::desc("Enable lowering math functions to their corresponding MASS " + "(scalar) entries"), + cl::Hidden); + extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTarget() { // Register the targets RegisterTargetMachine A(getThePPC32Target()); @@ -432,7 +439,9 @@ void PPCPassConfig::addIRPasses() { // Generate PowerPC target-specific entries for scalar math functions // that are available in IBM MASS (scalar) library. - if (TM->getOptLevel() == CodeGenOpt::Aggressive) { + if (TM->getOptLevel() == CodeGenOpt::Aggressive && + EnablePPCGenScalarMASSEntries) { + TM->Options.PPCGenScalarMASSEntries = EnablePPCGenScalarMASSEntries; addPass(createPPCGenScalarMASSEntriesPass()); } diff --git a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll index 86c67bd..1fa60d7 100644 --- a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll +++ b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll @@ -21,7 +21,6 @@ ; CHECK-NEXT: Convert i1 constants to i32/i64 if they are returned ; CHECK-NEXT: Expand Atomic instructions ; CHECK-NEXT: PPC Lower MASS Entries -; CHECK-NEXT: PPC Generate Scalar MASS Entries ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/CodeGen/PowerPC/lower-intrinsics-afn-mass.ll b/llvm/test/CodeGen/PowerPC/lower-intrinsics-afn-mass.ll index 30310fa..6ae8511 100644 --- a/llvm/test/CodeGen/PowerPC/lower-intrinsics-afn-mass.ll +++ b/llvm/test/CodeGen/PowerPC/lower-intrinsics-afn-mass.ll @@ -1,5 +1,5 @@ -; RUN: llc -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s declare float @llvm.cos.f32(float) declare float @llvm.exp.f32(float) diff --git a/llvm/test/CodeGen/PowerPC/lower-intrinsics-fast-mass.ll b/llvm/test/CodeGen/PowerPC/lower-intrinsics-fast-mass.ll index 951eb6b..f5adace 100644 --- a/llvm/test/CodeGen/PowerPC/lower-intrinsics-fast-mass.ll +++ b/llvm/test/CodeGen/PowerPC/lower-intrinsics-fast-mass.ll @@ -1,5 +1,5 @@ -; RUN: llc -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s declare float @llvm.cos.f32(float) declare float @llvm.exp.f32(float) diff --git a/llvm/test/CodeGen/PowerPC/lower-intrinsics-nofast-mass.ll b/llvm/test/CodeGen/PowerPC/lower-intrinsics-nofast-mass.ll index c0594e6..3d6e6da 100644 --- a/llvm/test/CodeGen/PowerPC/lower-intrinsics-nofast-mass.ll +++ b/llvm/test/CodeGen/PowerPC/lower-intrinsics-nofast-mass.ll @@ -1,5 +1,5 @@ -; RUN: llc -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s declare float @llvm.cos.f32(float) declare float @llvm.exp.f32(float) diff --git a/llvm/test/CodeGen/PowerPC/lower-scalar-mass-afn.ll b/llvm/test/CodeGen/PowerPC/lower-scalar-mass-afn.ll index 6ea44ef..018fbe9 100644 --- a/llvm/test/CodeGen/PowerPC/lower-scalar-mass-afn.ll +++ b/llvm/test/CodeGen/PowerPC/lower-scalar-mass-afn.ll @@ -1,5 +1,5 @@ -; RUN: llc -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s declare float @acosf (float); declare float @acoshf (float); diff --git a/llvm/test/CodeGen/PowerPC/lower-scalar-mass-fast.ll b/llvm/test/CodeGen/PowerPC/lower-scalar-mass-fast.ll index e298383..8c22d43 100644 --- a/llvm/test/CodeGen/PowerPC/lower-scalar-mass-fast.ll +++ b/llvm/test/CodeGen/PowerPC/lower-scalar-mass-fast.ll @@ -1,5 +1,5 @@ -; RUN: llc -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s declare float @acosf (float); declare float @acoshf (float); diff --git a/llvm/test/CodeGen/PowerPC/lower-scalar-mass-nofast.ll b/llvm/test/CodeGen/PowerPC/lower-scalar-mass-nofast.ll index 3c79280..6624b57 100644 --- a/llvm/test/CodeGen/PowerPC/lower-scalar-mass-nofast.ll +++ b/llvm/test/CodeGen/PowerPC/lower-scalar-mass-nofast.ll @@ -1,5 +1,5 @@ -; RUN: llc -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -enable-ppc-gen-scalar-mass -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck %s declare float @acosf (float); declare float @acoshf (float); diff --git a/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-afn.ll b/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-afn.ll index 41d3849..bc732df 100644 --- a/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-afn.ll +++ b/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-afn.ll @@ -1,5 +1,5 @@ -; RUN: llc -verify-machineinstrs -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK-LNX %s -; RUN: llc -verify-machineinstrs -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK-AIX %s +; RUN: llc -enable-ppc-gen-scalar-mass -verify-machineinstrs -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK-LNX %s +; RUN: llc -enable-ppc-gen-scalar-mass -verify-machineinstrs -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK-AIX %s declare float @llvm.pow.f32 (float, float); declare double @llvm.pow.f64 (double, double); diff --git a/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll b/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll index 4ac6059..05f7324 100644 --- a/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll +++ b/llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -verify-machineinstrs -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK-LNX %s -; RUN: llc -verify-machineinstrs -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK-AIX %s +; RUN: llc -enable-ppc-gen-scalar-mass -verify-machineinstrs -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK-LNX %s +; RUN: llc -enable-ppc-gen-scalar-mass -verify-machineinstrs -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK-AIX %s declare float @llvm.pow.f32 (float, float); declare double @llvm.pow.f64 (double, double); diff --git a/llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll b/llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll index 8a51e6e..70441d5 100644 --- a/llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll +++ b/llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -verify-machineinstrs -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK-LNX %s -; RUN: llc -verify-machineinstrs -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK-AIX %s +; RUN: llc -enable-ppc-gen-scalar-mass -verify-machineinstrs -O3 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck --check-prefix=CHECK-LNX %s +; RUN: llc -enable-ppc-gen-scalar-mass -verify-machineinstrs -O3 -mtriple=powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK-AIX %s declare float @powf (float, float); declare double @pow (double, double); -- 2.7.4