diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-01-16 16:01:24 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2009-01-16 16:01:24 +0100 |
commit | 56c6a499944339ea8748a3343c33464de188dd89 (patch) | |
tree | 9df33194fd81217f9ff87cf28b63baefa8eae26c /gcc | |
parent | cd3f1729088b40dfaca41acf2cd238c0a1e81fcd (diff) | |
download | gcc-56c6a499944339ea8748a3343c33464de188dd89.zip gcc-56c6a499944339ea8748a3343c33464de188dd89.tar.gz gcc-56c6a499944339ea8748a3343c33464de188dd89.tar.bz2 |
re PR tree-optimization/38789 (__builtin_constant_p appears to evaluate to true for non-constant arguments.)
PR tree-optimization/38789
* tree-ssa-threadedge.c
(record_temporary_equivalences_from_stmts_at_dest): Ignore calls to
__builtin_constant_p.
* gcc.c-torture/compile/pr38789.c: New test.
From-SVN: r143435
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr38789.c | 18 | ||||
-rw-r--r-- | gcc/tree-ssa-threadedge.c | 16 |
4 files changed, 43 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3a7a72c..d2f9fe7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-01-16 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/38789 + * tree-ssa-threadedge.c + (record_temporary_equivalences_from_stmts_at_dest): Ignore calls to + __builtin_constant_p. + 2009-01-16 Kenneth Zadeck <zadeck@naturalbridge.com> * dce.c (delete_unmarked_insns): Reversed the order that insns are diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac03e17..e8a3cc3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-16 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/38789 + * gcc.c-torture/compile/pr38789.c: New test. + 2009-01-16 Janus Weil <janus@gcc.gnu.org> PR fortran/38152 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38789.c b/gcc/testsuite/gcc.c-torture/compile/pr38789.c new file mode 100644 index 0000000..9179f6c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr38789.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/38789 */ + +void +baz (int v) +{ + unsigned a = (v == 1) ? 1 : 2; + + if (__builtin_constant_p (a)) + asm volatile ("# constant %0" :: "i" (a)); + else + asm volatile ("# register %0" :: "r" (a)); + + a = 6; + if (__builtin_constant_p (a)) + asm volatile ("# constant %0" :: "i" (a)); + else + asm volatile ("# register %0" :: "r" (a)); +} diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index a193d94..1429c18 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -1,5 +1,5 @@ /* SSA Jump Threading - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Contributed by Jeff Law <law@redhat.com> This file is part of GCC. @@ -320,12 +320,22 @@ record_temporary_equivalences_from_stmts_at_dest (edge e, The result of __builtin_object_size is defined to be the maximum of remaining bytes. If we use only one edge on the phi, the result will - change to be the remaining bytes for the corresponding phi argument. */ + change to be the remaining bytes for the corresponding phi argument. + + Similarly for __builtin_constant_p: + + r = PHI <1(2), 2(3)> + __builtin_constant_p (r) + + Both PHI arguments are constant, but x ? 1 : 2 is still not + constant. */ if (is_gimple_call (stmt)) { tree fndecl = gimple_call_fndecl (stmt); - if (fndecl && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_OBJECT_SIZE) + if (fndecl + && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_OBJECT_SIZE + || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CONSTANT_P)) continue; } |