[gcc(refs/vendors/ibm/heads/mmaplus-new)] Add the -mdense-math option.
kishan parmar
kishan@gcc.gnu.org
Tue Apr 28 18:12:22 GMT 2026
https://gcc.gnu.org/g:65c61affce7fc26239d8fa2bbb9d213ac4bb0b17
commit 65c61affce7fc26239d8fa2bbb9d213ac4bb0b17
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Tue Mar 3 23:30:04 2026 -0500
Add the -mdense-math option.
This patch adds the -mdense-math option for -mcpu=future. The next set of
patches will support for using dense math registers with the MMA instructions.
All this patch does is add the option. A future patch will implement support
for dense math registers, and another patch will then switch the MMA
instructions to use dense math registers.
The patches have been tested on both little and big endian systems. Can I check
it into the master branch?
This is version 4 of the patches. The previous patches were:
* https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707452.html
* https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707453.html
* https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707454.html
* https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707455.html
* https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707456.html
gcc/
2026-03-03 Michael Meissner <meissner@linux.ibm.com>
* config/rs6000/rs6000-c.cc (rs6000_define_or_undefine_macro): Define
__DENSE_MATH__ if we have dense math registers.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Do not
allow -mdense-math unless -mcpu=future is used.
(rs6000_opt_masks): Add -mdense-math support.
* config/rs6000/rs6000.opt (-mdense-math): New option.
* doc/invoke.texi (RS/6000 and PowerPC Options): Add -mdense-math.
Diff:
---
gcc/ChangeLog.mmaplus-new | 34 ++++++++++++++++++++++++++++++++++
gcc/config/rs6000/rs6000-c.cc | 4 ++++
gcc/config/rs6000/rs6000.cc | 10 ++++++++++
gcc/config/rs6000/rs6000.opt | 4 ++++
gcc/doc/invoke.texi | 7 +++++++
5 files changed, 59 insertions(+)
diff --git a/gcc/ChangeLog.mmaplus-new b/gcc/ChangeLog.mmaplus-new
index 47a849e7d4a3..8a3c6e71470c 100644
--- a/gcc/ChangeLog.mmaplus-new
+++ b/gcc/ChangeLog.mmaplus-new
@@ -1,5 +1,39 @@
2026-03-03 Michael Meissner <meissner@linux.ibm.com>
+Add the -mdense-math option.
+
+This patch adds the -mdense-math option for -mcpu=future. The next set of
+patches will support for using dense math registers with the MMA instructions.
+All this patch does is add the option. A future patch will implement support
+for dense math registers, and another patch will then switch the MMA
+instructions to use dense math registers.
+
+The patches have been tested on both little and big endian systems. Can I check
+it into the master branch?
+
+This is version 4 of the patches. The previous patches were:
+
+ * https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707452.html
+ * https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707453.html
+ * https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707454.html
+ * https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707455.html
+ * https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707456.html
+
+gcc/
+
+2026-03-03 Michael Meissner <meissner@linux.ibm.com>
+
+ * config/rs6000/rs6000-c.cc (rs6000_define_or_undefine_macro): Define
+ __DENSE_MATH__ if we have dense math registers.
+ * config/rs6000/rs6000.cc (rs6000_option_override_internal): Do not
+ allow -mdense-math unless -mcpu=future is used.
+ (rs6000_opt_masks): Add -mdense-math support.
+ * config/rs6000/rs6000.opt (-mdense-math): New option.
+ * doc/invoke.texi (RS/6000 and PowerPC Options): Add -mdense-math.
+---
+
+2026-03-03 Michael Meissner <meissner@linux.ibm.com>
+
Add wD constraint.
This patch adds a new constraint ('wD') that matches the accumulator registers
diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc
index 3fa7c04a7ce2..e2903b41ed8b 100644
--- a/gcc/config/rs6000/rs6000-c.cc
+++ b/gcc/config/rs6000/rs6000-c.cc
@@ -590,6 +590,10 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags)
/* Tell the user if we support the MMA instructions. */
if ((flags & OPTION_MASK_MMA) != 0)
rs6000_define_or_undefine_macro (define_p, "__MMA__");
+ /* Tell the user if we support the dense math registers for use with MMA and
+ cryptography. */
+ if ((flags & OPTION_MASK_DENSE_MATH) != 0)
+ rs6000_define_or_undefine_macro (define_p, "__DENSE_MATH__");
/* Whether pc-relative code is being generated. */
if ((flags & OPTION_MASK_PCREL) != 0)
rs6000_define_or_undefine_macro (define_p, "__PCREL__");
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 637233965588..f5ba84a108e9 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -4410,6 +4410,15 @@ rs6000_option_override_internal (bool global_init_p)
if (!TARGET_PCREL && TARGET_PCREL_OPT)
rs6000_isa_flags &= ~OPTION_MASK_PCREL_OPT;
+ /* Turn off dense math register support on non-future systems. */
+ if (TARGET_DENSE_MATH && !TARGET_FUTURE)
+ {
+ if ((rs6000_isa_flags_explicit & OPTION_MASK_DENSE_MATH) != 0)
+ error ("%qs requires %qs", "-mdense-math", "-mcpu=future");
+
+ rs6000_isa_flags &= ~OPTION_MASK_DENSE_MATH;
+ }
+
if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags);
@@ -24463,6 +24472,7 @@ static struct rs6000_opt_mask const rs6000_opt_masks[] =
false, true },
{ "cmpb", OPTION_MASK_CMPB, false, true },
{ "crypto", OPTION_MASK_CRYPTO, false, true },
+ { "dense-math", OPTION_MASK_DENSE_MATH, false, true },
{ "direct-move", 0, false, true },
{ "dlmzb", OPTION_MASK_DLMZB, false, true },
{ "efficient-unaligned-vsx", OPTION_MASK_EFFICIENT_UNALIGNED_VSX,
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index 9f3519da77b2..f836d1982877 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -639,6 +639,10 @@ mieee128-constant
Target Var(TARGET_IEEE128_CONSTANT) Init(1) Save
Generate (do not generate) code that uses the LXVKQ instruction.
+mdense-math
+Target Mask(DENSE_MATH) Var(rs6000_isa_flags)
+Generate (do not generate) instructions that use dense math registers.
+
; Documented parameters
-param=rs6000-vect-unroll-limit=
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 20c07f837473..d5a2496d2a20 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -32764,6 +32764,13 @@ This option is enabled by default.
Enable or disable warnings about deprecated @samp{vector long ...} Altivec
type usage. This option is enabled by default.
+@opindex mdense-math
+@opindex mno-dense-math
+@item -mdense-math
+@itemx -mno-dense-math
+Generate (do not generate) code that uses the dense math registers.
+This option is enabled by default.
+
@end table
@node RX Options
More information about the Gcc-cvs
mailing list