re PR middle-end/35265 (__builtin_popcount expansion bug)
authorRichard Guenther <rguenther@suse.de>
Wed, 20 Feb 2008 17:25:52 +0000 (17:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 20 Feb 2008 17:25:52 +0000 (17:25 +0000)
2008-02-20  Richard Guenther  <rguenther@suse.de>

PR middle-end/35265
* builtins.c (validate_arg): If we want an INTEGER_TYPE,
be happy with INTEGRAL_TYPE_P.

* gcc.dg/builtins-66.c: New testcase.

From-SVN: r132485

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-66.c [new file with mode: 0644]

index 5fa81dc782d6dc0a26c17720e8ae233cbe2e98fb..495a4769a5a5dee9428ec0a5c8c00d7818453120 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-20  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/35265
+       * builtins.c (validate_arg): If we want an INTEGER_TYPE,
+       be happy with INTEGRAL_TYPE_P.
+
 2008-02-20  Richard Guenther  <rguenther@suse.de>
 
        * fold-const.c (split_tree): Associate floatig-point expressions
index 1c140508a5336ea5bb21d0e117af9d78636fb400..5e6ebf5d116c56da1d43ba213ef3ef7c1c577fda 100644 (file)
@@ -5192,6 +5192,7 @@ expand_builtin_fabs (tree exp, rtx target, rtx subtarget)
     return NULL_RTX;
 
   arg = CALL_EXPR_ARG (exp, 0);
+  CALL_EXPR_ARG (exp, 0) = arg = builtin_save_expr (arg);
   mode = TYPE_MODE (TREE_TYPE (arg));
   op0 = expand_expr (arg, subtarget, VOIDmode, EXPAND_NORMAL);
   return expand_abs (mode, op0, target, 0, safe_from_p (target, arg, 1));
@@ -10749,6 +10750,8 @@ validate_arg (const_tree arg, enum tree_code code)
     return false;
   else if (code == POINTER_TYPE)
     return POINTER_TYPE_P (TREE_TYPE (arg));
+  else if (code == INTEGER_TYPE)
+    return INTEGRAL_TYPE_P (TREE_TYPE (arg));
   return code == TREE_CODE (TREE_TYPE (arg));
 }
 
index 8b9fb37624da2587a5b59c23c9e1adfd864a000d..04c799fe178e8a579439ee56f5822b0b90e8699d 100644 (file)
@@ -1,3 +1,8 @@
+2008-02-20  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/35265
+       * gcc.dg/builtins-66.c: New testcase.
+
 2008-02-20  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/fold-reassoc-1.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/builtins-66.c b/gcc/testsuite/gcc.dg/builtins-66.c
new file mode 100644 (file)
index 0000000..87bea3f
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+enum { E0 = 0, E1 = 1, E2 = 2 } e;
+
+int
+foo (void)
+{
+  return __builtin_popcount ((int) e);
+}
+
+/* { dg-final { scan-assembler-not "__builtin_popcount" } } */