https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126363
Bug ID: 126363
Summary: fold_builtin_atomic_always_lock_free uses `INTVAL
(expand_normal (arg0))` for INTEGER_CST
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: compile-time-hog, easyhack
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
The code in fold_builtin_atomic_always_lock_free does:
if (TREE_CODE (arg0) != INTEGER_CST)
return NULL_TREE;
/* We need a corresponding integer mode for the access to be lock-free. */
size = INTVAL (expand_normal (arg0)) * BITS_PER_UNIT;
But should use tree_fits_shwi_p/tree_to_shwi instead.
That would be faster than going through expand.
Likewise this:
if (TREE_CODE (arg1) == INTEGER_CST)
{
unsigned HOST_WIDE_INT val = UINTVAL (expand_normal (arg1));
Well this one should using ushwi instead.