https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84912

--- Comment #3 from Peter Bergner <bergner at gcc dot gnu.org> ---
The following patch changes the ICE to an error:

[bergner@makalu-lp1 PR84912]$ cat divde.i
long
div_de (long a, long b)
{
  return __builtin_divde (a, b);
}
[bergner@makalu-lp1 PR84912]$
/home/bergner/gcc/build/gcc-fsf-mainline-mcpu-debug/./gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-mcpu-debug/./gcc/ -m32 -O1 -S
-mcpu=power7 divde.i
divde.i: In function ‘div_de’:
divde.i:4:10: error: builtin ‘__builtin_divde’ is only valid in 64-bit mode
   return __builtin_divde (a, b);
          ^~~~~~~~~~~~~~~~~~~~~~

Ditto for the other builtins.

Index: rs6000.c
===================================================================
--- rs6000.c    (revision 258722)
+++ rs6000.c    (working copy)
@@ -14076,6 +14076,21 @@ rs6000_expand_binop_builtin (enum insn_c
   if (arg0 == error_mark_node || arg1 == error_mark_node)
     return const0_rtx;

+  if (!TARGET_POWERPC64
+      && (icode == CODE_FOR_dive_di
+         || icode == CODE_FOR_diveo_di
+         || icode == CODE_FOR_diveu_di
+         || icode == CODE_FOR_diveuo_di))
+    {
+      tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
+      bool nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
+      enum rs6000_builtins fcode = (enum rs6000_builtins) DECL_FUNCTION_CODE
(fndecl);
+      size_t uns_fcode = (size_t)fcode;
+      const char *name = rs6000_builtin_info[uns_fcode].name;
+      error ("builtin %qs is only valid in 64-bit mode", name);
+      return const0_rtx;
+    }
+
   if (icode == CODE_FOR_altivec_vcfux
       || icode == CODE_FOR_altivec_vcfsx
       || icode == CODE_FOR_altivec_vctsxs

Reply via email to