https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128783
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2026-12-01
Blocks|120763 |
Ever confirmed|0 |1
CC| |amacleod at redhat dot com,
| |jakub at gcc dot gnu.org
Status|UNCONFIRMED |NEW
--- Comment #1 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Seems like this has been broken since the introduction of using Ranger during
expansion:
commit 8154fc95f097a146f9c80edcaafb2baff73065b5 (HEAD)
Author: Jakub Jelinek <[email protected]>
Date: Tue Jun 10 20:04:52 2025 +0200
expand, ranger: Use ranger during expansion [PR120434]
As the following testcase shows, during expansion we use value range info
in lots of places, but sadly currently use only the global ranges.
It is mostly through get_range_pos_neg function, which uses
get_global_range_query ()->range_of_expr (arg1, arg2)
but other spots use it directly.
[ ... ]
The symptom is f() gets compiled down into a trivial return 0.
I *think* ranger is goofing this up.
As we enter expansion we have this for -march=rv64gc -mabi=lp64d -O2:
<bb 2> [local count: 1073741824]:
_6 = (uint128_t) b_7(D);
_9 = (unsigned long) _6;
_1 = (signed long) x_8(D);
_3 = _9 w* _1;
t_10 = (signed char) _3;
_2 = .MUL_OVERFLOW (t_10, t_10);
_5 = IMAGPART_EXPR <_2>;
_11 = (int) _5;
return _11;
>From within expand_arith_overflow we ask for the min precision of t_10 and get
back "1". If I trace that into get_min_precision we call range_of_expr for
t_10 and we get back:
(gdb) p debug_tree (arg)
<ssa_name 0x7ffff7234438
type <integer_type 0x7ffff7217498 signed char sizes-gimplified public QI
size <integer_cst 0x7ffff7240498 constant 8>
unit-size <integer_cst 0x7ffff72404b0 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7217498 precision:8 min <integer_cst 0x7ffff7240450 -128> max
<integer_cst 0x7ffff7240480 127>>
visited var <var_decl 0x7ffff73c1c78 t>
def_stmt t_10 = (signed char) _3;
version:10>
$38 = void
(gdb) p debug(r)
[irange] signed char [-1, 0]
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120763
[Bug 120763] [meta-bug] Tracker for bugs to visit during weekly RISC-V meeting