Hi! These builtins are: DEF_SYNC_BUILTIN (BUILT_IN_ATOMIC_ALWAYS_LOCK_FREE, "__atomic_always_lock_free", BT_FN_BOOL_SIZE_CONST_VPTR, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_SYNC_BUILTIN (BUILT_IN_ATOMIC_IS_LOCK_FREE, "__atomic_is_lock_free", BT_FN_BOOL_SIZE_CONST_VPTR, ATTR_CONST_NOTHROW_LEAF_LIST) therefore return bool rather than int, but apparently the folders returned integer constants anyway, which e.g. on the following testcase leads to checking ICEs. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-02-10 Jakub Jelinek <ja...@redhat.com> PR middle-end/52177 * builtins.c (fold_builtin_atomic_always_lock_free, expand_builtin_atomic_always_lock_free, fold_builtin_atomic_is_lock_free, expand_builtin_atomic_is_lock_free): Return and/or test boolean_true_node/boolean_false_node instead of integer_one_node/integer_zero_node. * c-c++-common/pr52177.c: New test. --- gcc/builtins.c.jj 2012-01-30 00:10:01.000000000 +0100 +++ gcc/builtins.c 2012-02-10 09:37:37.719936106 +0100 @@ -5639,15 +5639,15 @@ fold_builtin_atomic_always_lock_free (tr /* If the object has smaller alignment, the the lock free routines cannot be used. */ if (type_align < mode_align) - return integer_zero_node; + return boolean_false_node; /* Check if a compare_and_swap pattern exists for the mode which represents the required size. The pattern is not allowed to fail, so the existence of the pattern indicates support is present. */ if (can_compare_and_swap_p (mode, true)) - return integer_one_node; + return boolean_true_node; else - return integer_zero_node; + return boolean_false_node; } /* Return true if the parameters to call EXP represent an object which will @@ -5671,7 +5671,7 @@ expand_builtin_atomic_always_lock_free ( } size = fold_builtin_atomic_always_lock_free (arg0, arg1); - if (size == integer_one_node) + if (size == boolean_true_node) return const1_rtx; return const0_rtx; } @@ -5686,8 +5686,8 @@ fold_builtin_atomic_is_lock_free (tree a return NULL_TREE; /* If it isn't always lock free, don't generate a result. */ - if (fold_builtin_atomic_always_lock_free (arg0, arg1) == integer_one_node) - return integer_one_node; + if (fold_builtin_atomic_always_lock_free (arg0, arg1) == boolean_true_node) + return boolean_true_node; return NULL_TREE; } @@ -5717,7 +5717,7 @@ expand_builtin_atomic_is_lock_free (tree /* If the value is known at compile time, return the RTX for it. */ size = fold_builtin_atomic_is_lock_free (arg0, arg1); - if (size == integer_one_node) + if (size == boolean_true_node) return const1_rtx; return NULL_RTX; --- gcc/testsuite/c-c++-common/pr52177.c.jj 2012-02-10 09:46:27.175770110 +0100 +++ gcc/testsuite/c-c++-common/pr52177.c 2012-02-10 09:46:01.000000000 +0100 @@ -0,0 +1,23 @@ +/* PR middle-end/52177 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-ccp" } */ + +int *s; + +static inline int +foo () +{ + return sizeof (int); +} + +int +bar () +{ + return __atomic_always_lock_free (foo (), s); +} + +int +baz () +{ + return __atomic_is_lock_free (foo (), s); +} Jakub