From 56c6a499944339ea8748a3343c33464de188dd89 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 16 Jan 2009 16:01:24 +0100 Subject: 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 --- gcc/tree-ssa-threadedge.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'gcc/tree-ssa-threadedge.c') diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index a193d94b010..1429c18c998 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 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; } -- cgit v1.2.1