https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117526
Bug ID: 117526
Summary: gcc.dg/tree-ssa/pr108357.c fails without integer
argument promotion
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
If TARGET_PROMOTE_PROTOTYPES returns false or the C frontend doesn't promote
integer argument as implemented in
https://patchwork.sourceware.org/project/gcc/list/?series=40497
gcc.dg/tree-ssa/pr108357.c fails if char is signed. The difference starts
at the ccp1 pass:
1. With signed char:
;; Function main (main, funcdef_no=2, decl_uid=2806, cgraph_uid=3,
symbol_order=
4)
Adding destination of edge (0 -> 2) to worklist
Simulating block 2
Visiting statement:
b.2_1 = b;
which is likely CONSTANT
Lattice value changed to VARYING. Adding SSA edges to worklist.
Visiting statement:
_2 = (short int) b.2_1;
which is likely CONSTANT
Lattice value changed to VARYING. Adding SSA edges to worklist.
2. With unsigned char:
;; Function main (main, funcdef_no=2, decl_uid=4429, cgraph_uid=3,
symbol_order=
4)
Adding destination of edge (0 -> 2) to worklist
Simulating block 2
Visiting statement:
b.2_1 = b;
which is likely CONSTANT
Lattice value changed to VARYING. Adding SSA edges to worklist.
Visiting statement:
_2 = (short int) b.2_1;
which is likely CONSTANT
Lattice value changed to CONSTANT 0x0 (0xff). Adding SSA edges to worklist.
marking stmt to be not simulated again
It is due to
static ccp_prop_value_t
get_value_for_expr (tree expr, bool for_bits_p)
{
...
if (val.lattice_val == VARYING
&& INTEGRAL_TYPE_P (TREE_TYPE (expr))
&& TYPE_UNSIGNED (TREE_TYPE (expr)))
val.mask = wi::zext (val.mask, TYPE_PRECISION (TREE_TYPE (expr)));
return val;
}