Index: gcc/config/rs6000/rs6000-protos.h
===================================================================
--- gcc/config/rs6000/rs6000-protos.h    (revision 259316)
+++ gcc/config/rs6000/rs6000-protos.h    (working copy)
@@ -212,6 +212,7 @@
 extern void rs6000_aix_asm_output_dwarf_table_ref (char *);
 extern void get_ppc476_thunk_name (char name[32]);
 extern bool rs6000_overloaded_builtin_p (enum rs6000_builtins);
+extern bool rs6000_builtin_is_supported_p (enum rs6000_builtins);
 extern const char *rs6000_overloaded_builtin_name (enum rs6000_builtins);
 extern int rs6000_store_data_bypass_p (rtx_insn *, rtx_insn *);
 extern HOST_WIDE_INT rs6000_builtin_mask_calculate (void);
Index: gcc/config/rs6000/rs6000-c.c
===================================================================
--- gcc/config/rs6000/rs6000-c.c    (revision 259316)
+++ gcc/config/rs6000/rs6000-c.c    (working copy)
@@ -6885,6 +6885,8 @@
 
   {
     bool unsupported_builtin = false;
+    enum rs6000_builtins overloaded_code;
+    tree result = NULL;
     for (desc = altivec_overloaded_builtins;
      desc->code && desc->code != fcode; desc++)
       continue;
@@ -6897,7 +6899,6 @@
        discrimination between the desired forms of the function.  */
     if (fcode == P6_OV_BUILTIN_CMPB)
       {
-    int overloaded_code;
     machine_mode arg1_mode = TYPE_MODE (types[0]);
     machine_mode arg2_mode = TYPE_MODE (types[1]);
 
@@ -6932,14 +6933,20 @@
         && rs6000_builtin_type_compatible (types[1], desc->op2))
       {
         if (rs6000_builtin_decls[desc->overloaded_code] != NULL_TREE)
-          return altivec_build_resolved_builtin (args, n, desc);
+          {
+        result = altivec_build_resolved_builtin (args, n, desc);
+        /* overloaded_code is set above */
+        if (!rs6000_builtin_is_supported_p (overloaded_code))
+          unsupported_builtin = true;
+        else
+          return result;
+          }
         else
           unsupported_builtin = true;
       }
       }
     else if (fcode == P9V_BUILTIN_VEC_VSIEDP)
       {
-    int overloaded_code;
     machine_mode arg1_mode = TYPE_MODE (types[0]);
 
     if (nargs != 2)
@@ -6974,12 +6981,20 @@
     while (desc->code && desc->code == fcode
            && desc->overloaded_code != overloaded_code)
       desc++;
+
     if (desc->code && (desc->code == fcode)
         && rs6000_builtin_type_compatible (types[0], desc->op1)
         && rs6000_builtin_type_compatible (types[1], desc->op2))
       {
         if (rs6000_builtin_decls[desc->overloaded_code] != NULL_TREE)
-          return altivec_build_resolved_builtin (args, n, desc);
+          {
+        result = altivec_build_resolved_builtin (args, n, desc);
+        /* overloaded_code is set above.  */
+        if (!rs6000_builtin_is_supported_p (overloaded_code))
+          unsupported_builtin = true;
+        else
+          return result;
+          }
         else
           unsupported_builtin = true;
       }
@@ -6998,7 +7013,18 @@
             || rs6000_builtin_type_compatible (types[2], desc->op3)))
           {
         if (rs6000_builtin_decls[desc->overloaded_code] != NULL_TREE)
-          return altivec_build_resolved_builtin (args, n, desc);
+          {
+            result = altivec_build_resolved_builtin (args, n, desc);
+            if (!rs6000_builtin_is_supported_p (desc->overloaded_code))
+              {
+            /* Allow loop to continue in case a different
+               definition is supported.  */
+            overloaded_code = desc->overloaded_code;
+            unsupported_builtin = true;
+              }
+            else
+              return result;
+          }
         else
           unsupported_builtin = true;
           }
@@ -7008,9 +7034,24 @@
     if (unsupported_builtin)
       {
     const char *name = rs6000_overloaded_builtin_name (fcode);
-    error ("builtin function %qs not supported in this compiler "
-           "configuration", name);
-    return error_mark_node;
+    if (result != NULL)
+      {
+        const char *internal_name
+          = rs6000_overloaded_builtin_name (overloaded_code);
+        /* An error message making reference to the name of the
+           non-overloaded function has already been issued.  Add
+           clarification of the previous message.  */
+        rich_location richloc (line_table, input_location);
+        inform (&richloc, "builtin %qs requires builtin %qs",
+            name, internal_name);
+      }
+    else
+      /* on 64-bit, i seem to end up here */
+      error ("builtin function %qs not supported in this compiler "
+         "configuration", name);
+    /* If an error-representing  result tree was returned from
+       altivec_build_resolved_builtin above, use it.  */
+    return (result != NULL)? result: error_mark_node;
       }
   }
  bad:
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c    (revision 259316)
+++ gcc/config/rs6000/rs6000.c    (working copy)
@@ -15897,6 +15897,18 @@
   return target;
 }
 
+/* Check whether a builtin function is supported in this target
+   configuration.  */
+bool
+rs6000_builtin_is_supported_p (enum rs6000_builtins fncode)
+{
+  HOST_WIDE_INT fnmask = rs6000_builtin_info[fncode].mask;
+  if ((fnmask & rs6000_builtin_mask) != fnmask)
+    return false;
+  else
+    return true;
+}
+
 /* Raise an error message for a builtin function that is called without the
    appropriate target options being set.  */
 
