https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121249
Bug ID: 121249
Summary: build_constant_desc has some obvious dead code in it
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Keywords: internal-improvement
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
build_constant_desc does:
```
/* Construct the VAR_DECL associated with the constant. */
decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (label),
TREE_TYPE (exp));
...
DECL_IN_CONSTANT_POOL (decl) = 1;
...
int align = (TREE_CODE (decl) == CONST_DECL
|| (VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl))
? DECL_ALIGN (decl)
: symtab_node::get (decl)->definition_alignment ());
```
So `VAR_P (decl) && DECL_IN_CONSTANT_POOL (decl)` will always be true as
nothing modifies the tree code nor DECL_IN_CONSTANT_POOL after building/setting
them.
This dead code was added with r5-7630-g7185ec2cb42ab0. I think it was a search
and replace of DECL_ALIGN (decl) and not noticing that `VAR_P (decl) &&
DECL_IN_CONSTANT_POOL (decl)` would always be true here.