GCC maintianers:
The following patch add a check to make sure the user did not specify
-mno_fprnd with the builtins __builtin_vsx_xsrdpim and
__builtin_vsx_xsrdpip. These builtins are incompatible with the
-mno_fprnd command line. The check prevents GCC crashing under these
conditions.
Manually tested the patch on
powerpc64le-unknown-linux-gnu (Power 8 LE)
powerpc64le-unknown-linux-gnu (Power 9 LE)
as follows:
gcc -mno-fprnd -g -c vsx-builtin-3.c
vsx-builtin-3.c: In function ‘do_math’:
vsx-builtin-3.c:145:3: error: __builtin_vsx_xsrdpim is incompatible
with mno-fprnd option
145 | z[i][0] = __builtin_vsx_xsrdpim (z[i][1]); i++;
| ^
vsx-builtin-3.c:146:3: error: __builtin_vsx_xsrdpip is incompatible
with mno-fprnd option
146 | z[i][0] = __builtin_vsx_xsrdpip (z[i][1]); i++;
| ^
I read thru the source code looking for other builtins with the same
issue. I also created a script to compile all of the tests in
gcc/testsuite/gcc.target/powerpc with the -mno-fprnd option to check
for additional builtins that are incompatible with the -mno-fprnd
option. These were the only two builtins that were identified as being
incompatible with the -mno-fprnd option.
Please let me know if the patch looks OK for mainline. Thanks.
Carl Love
-----------------------------------------------------------------------
rs6000: Add command line and builtin compatibility check
PR/target 87583
gcc/ChangeLog
2020-03-10 Carl Love <[email protected]>
* gcc/config/rs6000/rs6000-c.c
(altivec_resolve_overloaded_builtin):
Add check for TARGET_FRND and VSX_BUILTIN_XSRDPIM,
VSX_BUILTIN_XSRDPIP
compatibility.
---
gcc/config/rs6000/rs6000-c.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-
c.c
index 8c1fbbf..6820782 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -915,6 +915,14 @@ altivec_resolve_overloaded_builtin (location_t
loc, tree fndecl,
const struct altivec_builtin_types *desc;
unsigned int n;
+ /* Check builtin for command line argument conflicts. */
+ if (!TARGET_FPRND &&
+ (fcode == VSX_BUILTIN_XSRDPIM || fcode == VSX_BUILTIN_XSRDPIP))
{
+ error ("%s is incompatible with mno-fprnd option",
+ IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+ return error_mark_node;
+ }
+
if (!rs6000_overloaded_builtin_p (fcode))
return NULL_TREE;
--
2.7.4