===================================================================
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+
+/* This formerly ICEd when trying to expand pow as a built-in with
+ the wrong number of arguments. */
+
+extern double pow (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__));
+extern double __pow (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__));
+
+typedef int int64_t __attribute__ ((__mode__ (__DI__)));
+
+typedef struct {
+ int64_t data;
+ int tag;
+} Object;
+
+extern Object Make_Flonum (double);
+extern Object P_Pow (Object, Object);
+
+Object General_Function (Object x, Object y, double (*fun)()) {
+ double d, ret;
+
+ d = 1.0;
+
+ if (y.tag >> 1)
+ ret = (*fun) (d);
+ else
+ ret = (*fun) (d, 0.0);
+
+ return Make_Flonum (ret);
+}
+
+Object P_Pow (Object x, Object y) { return General_Function (x, y, pow); }
===================================================================
@@ -3860,6 +3860,8 @@ estimate_num_insns (gimple stmt, eni_weights *weig
case BUILT_IN_POW:
case BUILT_IN_POWF:
case BUILT_IN_POWL:
+ if (!gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
+ break;
if (TREE_CODE (gimple_call_arg (stmt, 1)) == REAL_CST
&& REAL_VALUES_EQUAL
(TREE_REAL_CST (gimple_call_arg (stmt, 1)), dconst2))
===================================================================
@@ -1437,7 +1437,7 @@ execute_cse_sincos (void)
if (is_gimple_call (stmt)
&& gimple_call_lhs (stmt)
&& (fndecl = gimple_call_fndecl (stmt))
- && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+ && gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
{
tree arg, arg0, arg1, result;
HOST_WIDE_INT n;
@@ -2867,6 +2867,8 @@ execute_optimize_widening_mul (void)
case BUILT_IN_POWF:
case BUILT_IN_POW:
case BUILT_IN_POWL:
+ if (!gimple_call_builtin_p (stmt))
+ break;
if (TREE_CODE (gimple_call_arg (stmt, 1)) == REAL_CST
&& REAL_VALUES_EQUAL
(TREE_REAL_CST (gimple_call_arg (stmt, 1)),