Re: [PATCH 1/2] [frange] Enable sub-ranges.

"H.J. Lu" <[email protected]> Thu, 6 Aug 2026 13:03:39 +0800
Newsgroups gmane.comp.gcc.patches
Message-ID <CAMe9rOr_NHx-CTDgJjcm84iHFtUkGObPTUaRKyw7yuxMe65SKA@mail.gmail.com>
On Tue, Aug 4, 2026 at 4:06 PM Jakub Jelinek <[email protected]> wrote:
>
> On Mon, Aug 03, 2026 at 11:21:06PM +0200, Aldy Hernandez wrote:
> > On Mon, Aug 03, 2026 at 11:59:13AM +0200, Jakub Jelinek wrote:
> >
> > > I'm surprised float_widen_lhs_range hasn't been changed for this.
> > > When we support 2 pairs, I think we need to widen each pair individually
> > > and then combine them in case the widening would now cause overlap etc.
> >
> > Probably cause it didn't show up in any missing optimizations for the
> > DOM audit I did :-P.  But TBH, I didn't convert any range-ops operators to
> > multi-range.
> >
> > However, float_widen_lhs_range seems simple enough.  If we refactor
> > the bounds logic out, the change seems very simple.  See attached two
> > patches.
> >
> > I'm flying blind here (i.e. I have no clue), so I'm *NOT* committing
> > this.
> >
> > I've tested on ppc64le, but will only push if you review and approve
> > it :).
>
> Both patches LGTM, ok for trunk.
> Thanks.
>
> As for ops, guess the easiest would to change range_operator::fold_range
> to iterate over the pairs with rv_fold first, that would cover quite a lot,
> but then we have tons of ops which don't use that (especially reverse ones).
> Something I've been touching recently are e.g. the int -> float casts,
> there I think having more than one pair would be quite frequent (if the
> integer range has more than one pair).
>
>         Jakub
>

commit 1e5aaad93d8426a4112873e6ff7266f49153c535
Author:     Aldy Hernandez <[email protected]>
AuthorDate: Mon Aug 3 11:02:38 2026 +0000
Commit:     Aldy Hernandez <[email protected]>
CommitDate: Tue Aug 4 14:12:14 2026 +0200

    [frange] Convert float_widen_lhs_range to sub-ranges.

breaks bootstrap with Ada on Linux/x86-64:

/export/build/gnu/tools-build/gcc-native-gitlab/build-x86_64-linux/./gcc/xgcc
-B/export/build/gnu/tools-build/gcc-native-gitlab/build-x86_64-linux/./gcc/
-B/usr/gcc-17.0.0-native/x86_64-pc-linux-gnu/bin/
-B/usr/gcc-17.0.0-native/x86_64-pc-linux-gnu/lib/ -isystem
/usr/gcc-17.0.0-native/x86_64-pc-linux-gnu/include -isystem
/usr/gcc-17.0.0-native/x86_64-pc-linux-gnu/sys-include   -fchecking=1
-c -g -O2   -W -Wall -gnatpg -nostdinc   a-nlelfu.ads -o a-nlelfu.o


raised STORAGE_ERROR : stack overflow or erroneous memory access

(gdb) r
Starting program:
/export/build/gnu/tools-build/gcc-native-gitlab/build-x86_64-linux/gcc/gnat1
-quiet -nostdinc -O2 -Wextra -Wall -dumpbase a-nlelfu.ads
-dumpbase-ext .ads -gnatwa -fchecking=1 -g -gnatpg -mtune=native
-march=native -mtls-dialect=gnu2 -march=znver4 -mmmx -mpopcnt -msse
-msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -msse4a -mno-fma4
-mno-xop -mfma -mavx512f -mbmi -mbmi2 -maes -mpclmul -mavx512vl
-mavx512bw -mavx512dq -mavx512cd -mavx512vbmi -mavx512ifma
-mavx512vpopcntdq -mavx512vbmi2 -mgfni -mvpclmulqdq -mavx512vnni
-mavx512bitalg -mavx512bf16 -mno-avx512vp2intersect -mno-3dnow -madx
-mabm -mno-cldemote -mclflushopt -mclwb -mclzero -mcx16 -mno-enqcmd
-mf16c -mfsgsbase -mfxsr -mno-hle -msahf -mno-lwp -mlzcnt -mmovbe
-mno-movdir64b -mno-movdiri -mmwaitx -mno-pconfig -mpku -mprfchw
-mno-ptwrite -mrdpid -mrdrnd -mrdseed -mno-rtm -mno-serialize -mno-sgx
-msha -mshstk -mno-tbm -mno-tsxldtrk -mvaes -mno-waitpkg -mwbnoinvd
-mxsave -mxsavec -mxsaveopt -mxsaves -mno-amx-tile -mno-amx-int8
-mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl -mno-widekl -mno-avxvnni
-mno-avx512fp16 -mno-avxifma -mno-avxvnniint8 -mno-avxneconvert
-mno-cmpccxadd -mno-amx-fp16 -mno-prefetchi -mno-raoint
-mno-amx-complex -mno-avxvnniint16 -mno-sm3 -mno-sha512 -mno-sm4
-mno-apxf -mno-usermsr -mno-avx10.1 -mno-avx10.2 -mno-amx-avx512
-mno-amx-fp8 -mno-movrs -mno-amx-movrs -mno-avx512bmm -mno-avx10v2aux
--param l1-cache-size=32 --param l1-cache-line-size=64 --param
l2-cache-size=1024 -mtune=znver4 a-nlelfu.ads -o a-nlelfu.s
Python Exception <class 'SyntaxError'>: Missing parentheses in call to
'print'. Did you mean print(...)? (libisl.so.15.1.1-gdb.py, line 67)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00000000022cbb9e in frange_nextafter (mode=<optimized out>,
    mode@entry=E_DFmode, value=..., inf=...)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/range-op-float.cc:315
315       value = tmp;
Missing rpms, try: dnf --enablerepo='*debug*' install
isl-debuginfo-0.16.1-24.0.fc44.x86_64
libmpc-debuginfo-1.4.1-1.fc44.x86_64
mpfr-debuginfo-4.2.2-3.fc44.x86_64 gmp-debuginfo-6.3.0-5.0.fc44.x86_64
zlib-ng-compat-debuginfo-2.3.3-3.fc44.x86_64
libzstd-debuginfo-1.5.7-5.fc44.x86_64
glibc-debuginfo-2.43-8.0.fc44.x86_64
(gdb) bt
#0  0x00000000022cbb9e in frange_nextafter (mode=<optimized out>,
    mode@entry=E_DFmode, value=..., inf=...)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/range-op-float.cc:315
#1  0x00000000027a6f4e in frange_fusible_p (mode=E_DFmode, a_max=...,
    b_min=...) at /export/gnu/import/git/gitlab/x86-gcc/gcc/value-range.cc:1041
#2  frange_fusible_p (mode=<optimized out>, a_max=..., b_min=...)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/value-range.cc:1035
#3  frange::set_pairs (this=0x7fffffff8520, pairs=0x7fffffff82c0,
    n=<optimized out>)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/value-range.cc:1129
#4  0x00000000027a79c6 in frange::union_ (this=<optimized out>, v=...)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/value-range.cc:1394
#5  0x00000000022cda91 in float_widen_lhs_range (
    type=type@entry=0x7fffe7cd21f8, lhs=...)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/range-op-float.cc:2430
#6  0x00000000022cdbf0 in operator_plus::op1_range (r=...,
    type=0x7fffe7cd21f8, lhs=..., op2=..., this=<optimized out>)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/range-op-float.cc:2445
#7  0x0000000001fa881a in gori_compute::compute_operand1_range (
    this=this@entry=0x4653610, r=..., handler=..., lhs=..., src=...,
    rel=rel@entry=0x0)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-range-gori.cc:1192
#8  0x0000000001fab032 in gori_compute::compute_operand_range (this=0x4653610,
--Type <RET> for more, q to quit, c to continue without paging--
    r=..., stmt=0x7fffe7b0c600, lhs=..., name=0x7fffe7ded840, src=...,
    rel=<optimized out>)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-range-gori.cc:677
#9  0x0000000001faaf85 in gori_compute::compute_operand_range (this=0x4653610,
    r=..., stmt=0x7fffe7df0e18, lhs=..., name=0x7fffe7ded840, src=...,
    rel=<optimized out>)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-range-gori.cc:791
#10 0x0000000001fad0e0 in gori_compute::edge_range_p (this=0x4653610, r=...,
    e=0x7fffe7a18ee0, name=0x7fffe7ded840, q=...)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-range-gori.cc:1443
#11 0x00000000025c242a in path_range_query::compute_ranges_in_block (
    this=0x7fffffffbcd0, bb=0x7fffe7b0c9c0)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-range-path.cc:421
#12 0x00000000025c2a89 in path_range_query::compute_ranges (
    this=0x7fffffffbcd0, dependencies=<optimized out>)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-range-path.cc:588
#13 0x00000000026632c4 in back_threader::find_taken_edge_cond (
    this=<optimized out>, path=..., cond=0x7fffe7dede18)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/tree-ssa-threadbackward.cc:321
#14 0x0000000002663dc5 in back_threader::maybe_register_path (
    this=this@entry=0x7fffffffcdc0, profit=...)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/tree-ssa-threadbackward.cc:245
#15 0x0000000002664176 in back_threader::find_paths_to_names (

-- 
H.J.