public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
@ 2021-09-22 12:30 danglin at gcc dot gnu.org
  2021-09-22 13:14 ` [Bug ada/102450] " rguenth at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: danglin at gcc dot gnu.org @ 2021-09-22 12:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

            Bug ID: 102450
           Summary: GCC error: in
                    set_min_and_max_values_for_integral_type, at
                    stor-layout.c:2851
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: danglin at gcc dot gnu.org
  Target Milestone: ---
              Host: hppa*-*-* (32-bit)
            Target: hppa*-*-* (32-bit)
             Build: hppa*-*-* (32-bit)

/home/dave/gnu/gcc/objdir/./gcc/xgcc -B/home/dave/gnu/gcc/objdir/./gcc/
-B/opt/g
nu/gcc/gcc-12/hppa2.0w-hp-hpux11.11/bin/
-B/opt/gnu/gcc/gcc-12/hppa2.0w-hp-hpux1
1.11/lib/ -isystem /opt/gnu/gcc/gcc-12/hppa2.0w-hp-hpux11.11/include -isystem
/o
pt/gnu/gcc/gcc-12/hppa2.0w-hp-hpux11.11/sys-include   -fchecking=1 -c -g -O2 
-f
PIC  -W -Wall -gnatpg -nostdinc   s-regpat.adb -o s-regpat.o
during GIMPLE pass: lower
+===========================GNAT BUG DETECTED==============================+
| 12.0.0 20210922 (experimental) (hppa2.0w-hp-hpux11.11) GCC error:        |
| in set_min_and_max_values_for_integral_type, at stor-layout.c:2851       |
| Error detected around s-regpat.adb:345:4                                 |
| Compiling s-regpat.adb                                                   |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact command that you entered.                              |
| Also include sources listed below.                                       |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

system.ads
s-regpat.adb
s-regpat.ads
s-io.ads
ada.ads
a-charac.ads
a-chahan.ads
a-unccon.ads
s-exctab.ads
s-stalib.ads
a-except.ads
s-parame.ads
s-traent.ads
s-valint.ads
s-unstyp.ads
s-valuns.ads
s-valueu.ads
s-valuei.ads
s-imgcha.ads
s-secsta.ads
s-stoele.ads
s-imgint.ads
s-imagei.ads


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:414
make[7]: *** [../gcc-interface/Makefile:300: s-regpat.o] Error 1
make[7]: Leaving directory '/home/dave/gnu/gcc/objdir/gcc/ada/rts'
make[6]: *** [gcc-interface/Makefile:627: gnatlib] Error 2
make[6]: Leaving directory '/home/dave/gnu/gcc/objdir/gcc/ada'
make[5]: *** [gcc-interface/Makefile:662: gnatlib-shared-default] Error 2
make[5]: Leaving directory '/home/dave/gnu/gcc/objdir/gcc/ada'

Also occurs on Linux:
https://buildd.debian.org/status/fetch.php?pkg=gcc-snapshot&arch=hppa&ver=1%3A20210918-1&stamp=1632002454&raw=0

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
@ 2021-09-22 13:14 ` rguenth at gcc dot gnu.org
  2021-09-22 13:47 ` dave.anglin at bell dot net
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-22 13:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2021-09-22
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
what's MAX_BITSIZE_MODE_ANY_INT in insn-modes.h?  (in the build directory)
I think it should correspond to TImode and thus be 16 * BITS_PER_UNIT which
means that we're building an INTEGER_TYPE bigger than TImode - can you confirm
that?

Unfortunately gnat doesn't provide backtraces, so a backtrace from gdb would
also be nice.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
  2021-09-22 13:14 ` [Bug ada/102450] " rguenth at gcc dot gnu.org
@ 2021-09-22 13:47 ` dave.anglin at bell dot net
  2021-09-22 15:04 ` dave.anglin at bell dot net
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: dave.anglin at bell dot net @ 2021-09-22 13:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #2 from dave.anglin at bell dot net ---
On 2021-09-22 9:14 a.m., rguenth at gcc dot gnu.org wrote:
> what's MAX_BITSIZE_MODE_ANY_INT in insn-modes.h?  (in the build directory)
> I think it should correspond to TImode and thus be 16 * BITS_PER_UNIT which
> means that we're building an INTEGER_TYPE bigger than TImode - can you confirm
> that?
#define BITS_PER_UNIT (8)
#define MAX_BITSIZE_MODE_ANY_INT (16*BITS_PER_UNIT)
#define MAX_BITSIZE_MODE_ANY_MODE (32*BITS_PER_UNIT)

However, TImode is not supported on this target.

(gdb) ignor 1 325
Will ignore next 325 crossings of breakpoint 1.
(gdb) r
Starting program: /home/dave/gnu/gcc/objdir/gcc/gnat1 -quiet -nostdinc -O2
-Wext                                                              
ra -Wall -dumpbase s-regpat.adb -dumpbase-ext .adb -gnatwa -fchecking=1 -g
-fPIC                                                               
-gnatpg -gnatO s-regpat.o s-regpat.adb -o s-regpat.s

Breakpoint 1, _Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop
    (type=<incomplete type>, precision=256, sgn=UNSIGNED)
    at ../../gcc/gcc/stor-layout.c:2851
2851      gcc_assert (precision <= WIDE_INT_MAX_PRECISION);
(gdb) p precision
$2 = 256
(gdb) disass $pc-16,$pc+16
Dump of assembler code from 0xfbc244 to 0xfbc264:
   0x00fbc244
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+36>:     stw
r7,-70(sp)
   0x00fbc248
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+40>:     stw
r6,-6c(sp)
   0x00fbc24c
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+44>:    
cmpib,>= 0,r25,0xfbc2d4
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+180>
   0x00fbc250
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+48>:     copy
r26,r3
=> 0x00fbc254
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+52>:     ldi
c0,ret0
   0x00fbc258
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+56>:    
cmpb,< ret0,r25,0xfbc2fc
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+220>
   0x00fbc25c
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+60>:     copy
r24,r25
   0x00fbc260
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+64>:     ldo
-98(sp),r6
End of assembler dump.
(gdb) p $ret0
$3 = 8388608
(gdb) p 0xc0
$4 = 192
(gdb) p $r25
$5 = 256
(gdb) bt
#0  _Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop (
    type=<incomplete type>, precision=256, sgn=UNSIGNED)
    at ../../gcc/gcc/stor-layout.c:2851
#1  0x00fc0b9c in _Z18make_unsigned_typei (precision=256)
    at ../../gcc/gcc/stor-layout.c:2885
#2  0x000da2b4 in _Z18gnat_type_for_sizeji (precision=256, unsignedp=256)
    at ../../gcc/gcc/ada/gcc-interface/utils.c:3670
#3  0x00b05c2c in gimple_fold_builtin_memory_op(gimple_stmt_iterator*,
tree_node*, tree_node*, built_in_function) (v=@0x79aebb68, reserve=256,
exact=true)
    at ../../gcc/gcc/gimple-fold.c:1004
#4  0x00afffac in _ZL11fold_stmt_1P20gimple_stmt_iteratorbPFP9tree_nodeS2_E (
    gsi=0x7a001018, inplace=true, valueize=0x79ae8b58)
    at ../../gcc/gcc/gimple-fold.c:5054
#5  0x00b13668 in _ZL10lower_stmtP20gimple_stmt_iteratorP10lower_data (
    gsi=..., data=0x7a000fa4) at ../../gcc/gcc/gimple-low.c:390
#6  0x00b1405c in _ZL17lower_gimple_bindP20gimple_stmt_iteratorP10lower_data (
    gsi=0x7a000f98, data=0x7a000fa4) at ../../gcc/gcc/gimple-low.c:217
#7  0x00b146a0 in _ZN12_GLOBAL__N_113pass_lower_cf7executeEP8function (
    this=0x79ab92a0) at ../../gcc/gcc/gimple-low.c:110
#8  0x00e8b140 in _Z16execute_one_passP8opt_pass (pass=0x40716078)
    at ../../gcc/gcc/passes.c:2567
#9  0x00e8ba2c in _ZL19execute_pass_list_1P8opt_pass (pass=0x40716078)
    at ../../gcc/gcc/passes.c:2656
---Type <return> to continue, or q <return> to quit---
#10 0x00e8bad0 in _Z17execute_pass_listP8functionP8opt_pass (fn=0x79ab92a0,
    pass=0x100) at ../../gcc/gcc/passes.c:2667
#11 0x00906578 in _ZN11cgraph_node7analyzeEv (this=<incomplete type>)
    at ../../gcc/gcc/cgraphunit.c:680
#12 0x009098e0 in _ZL17analyze_functionsb (first_time=148)
    at ../../gcc/gcc/cgraphunit.c:1234
#13 0x0090a6c8 in _ZN12symbol_table25finalize_compilation_unitEv (
    this=0x79c59000) at ../../gcc/gcc/cgraphunit.c:2508
#14 0x00fcd444 in _ZL12compile_filev () at ../../gcc/gcc/toplev.c:483
#15 0x00fd0d5c in _ZN6toplev4mainEiPPc (this=0x7a000a98, argc=0, argv=0x0)
    at ../../gcc/gcc/toplev.c:2233
#16 0x01461b40 in main (argc=20, argv=0x7a0008f4) at ../../gcc/gcc/main.c:39

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
  2021-09-22 13:14 ` [Bug ada/102450] " rguenth at gcc dot gnu.org
  2021-09-22 13:47 ` dave.anglin at bell dot net
@ 2021-09-22 15:04 ` dave.anglin at bell dot net
  2021-09-24  9:44 ` rdapp at linux dot ibm.com
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: dave.anglin at bell dot net @ 2021-09-22 15:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #3 from dave.anglin at bell dot net ---
This occurs in stage3, so it's probably an optimization bug.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-09-22 15:04 ` dave.anglin at bell dot net
@ 2021-09-24  9:44 ` rdapp at linux dot ibm.com
  2021-09-24 14:37 ` rdapp at linux dot ibm.com
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rdapp at linux dot ibm.com @ 2021-09-24  9:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

rdapp at linux dot ibm.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rdapp at linux dot ibm.com

--- Comment #4 from rdapp at linux dot ibm.com ---
Also happens on s390 with -m31 in stage 3:

/home/rdapp/projects/gcc/build/./gcc/xgcc
-B/home/rdapp/projects/gcc/build/./gcc/
-B/home/rdapp/gcc-fail/s390x-ibm-linux-gnu/bin/
-B/home/rdapp/gcc-fail/s390x-ibm-linux-gnu/lib/ -isystem
/home/rdapp/gcc-fail/s390x-ibm-linux-gnu/include -isystem
/home/rdapp/gcc-fail/s390x-ibm-linux-gnu/sys-include   -fchecking=1 -c -g -O2
-m31 -fPIC  -W -Wall -gnatpg -nostdinc -m31  g-sehash.adb -o g-sehash.o         
during GIMPLE pass: lower                                                       
+===========================GNAT BUG DETECTED==============================+    
| 12.0.0 20210923 (experimental) (s390x-ibm-linux-gnu) GCC error:          |    
| in set_min_and_max_values_for_integral_type, at stor-layout.c:2851       |    
| Error detected around g-sehash.adb:98:4                                  |    
| Compiling g-sehash.adb                                                   |    
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |    
| Use a subject line meaningful to you and us to track the bug.            |    
| Include the entire contents of this bug box in the report.               |    
| Include the exact command that you entered.                              |    
| Also include sources listed below.                                       |    
+==========================================================================+    

Please include these source files with error report                             
Note that list may not be accurate in some cases,                               
so please double check that the problem can still                               
be reproduced with the set of files listed.                                     
Consider also -gnatd.n switch (see debug.adb).                                  

system.ads                                                                      
g-sehash.adb                                                                    
g-sehash.ads                                                                    
g-sechas.ads                                                                    
gnat.ads                                       
ada.ads                                        
a-stream.ads                                   
interfac.ads                                   
g-bytswa.ads                                   
a-sttebu.ads                                   
a-string.ads                                   
a-stuten.ads                                   
unchconv.ads                                   
s-exctab.ads                                   
s-stalib.ads                                   
a-unccon.ads                                   
a-tags.ads                                     
s-stoele.ads                                   
s-soflin.ads                                   
a-except.ads                                   
s-parame.ads                                   
s-traent.ads                                   
s-secsta.ads                                   
s-stache.ads                                   
s-putima.ads                                                                    
s-unstyp.ads                                                                    
g-sechas.adb                                                                    
s-stoele.adb                                                                    


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:414

precision=512 though, backtrace:#0  set_min_and_max_values_for_integral_type
(type=type@entry=0x3fffb7c3000, precision=512, sgn=sgn@entry=UNSIGNED) at
../../gcc/stor-layout.c:2851
#1  0x0000000001f141a8 in fixup_unsigned_type (type=type@entry=0x3fffb7c3000)
at ../../gcc/stor-layout.c:2885
#2  0x0000000001f14248 in make_unsigned_type (precision=<optimized out>) at
../../gcc/stor-layout.c:2708
#3  0x00000000013c0698 in gnat_type_for_size (precision=<optimized out>,
unsignedp=<optimized out>) at ../../gcc/ada/gcc-interface/utils.c:3670
#4  0x0000000001b6584e in gimple_fold_builtin_memory_op
(gsi=gsi@entry=0x3ffffffded8, dest=0x3fffb76f760, src=0x3fffb76e510,
code=code@entry=BUILT_IN_MEMMOVE)
    at ../../gcc/gimple-fold.c:1004
#5  0x0000000001b67a9e in gimple_fold_builtin (gsi=0x3ffffffded8) at
../../gcc/gimple.h:3297
#6  gimple_fold_call (gsi=gsi@entry=0x3ffffffded8, inplace=inplace@entry=false)
at ../../gcc/gimple-fold.c:5588
#7  0x0000000001b69732 in fold_stmt_1 (gsi=gsi@entry=0x3ffffffded8,
inplace=inplace@entry=false, valueize=valueize@entry=0x1b500b0
<no_follow_ssa_edges(tree_node*)>)
    at ../../gcc/gimple-fold.c:6290
#8  0x0000000001b6b260 in fold_stmt (gsi=gsi@entry=0x3ffffffded8) at
../../gcc/gimple-fold.c:6386
#9  0x00000000029188ca in lower_stmt (gsi=gsi@entry=0x3ffffffded8,
data=data@entry=0x3ffffffe060) at ../../gcc/gimple-low.c:390

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-09-24  9:44 ` rdapp at linux dot ibm.com
@ 2021-09-24 14:37 ` rdapp at linux dot ibm.com
  2021-09-24 15:24 ` rearnsha at gcc dot gnu.org
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rdapp at linux dot ibm.com @ 2021-09-24 14:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #5 from rdapp at linux dot ibm.com ---
git bisect bad5f6a6c91d7c592cb49f7c519f289777eac09bb74 is the first bad commit  
commit 5f6a6c91d7c592cb49f7c519f289777eac09bb74                                 
Author: Richard Earnshaw <rearnsha@arm.com>
Date:   Fri Sep 3 17:06:15 2021 +0100

    gimple: allow more folding of memcpy [PR102125]
[..]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-09-24 14:37 ` rdapp at linux dot ibm.com
@ 2021-09-24 15:24 ` rearnsha at gcc dot gnu.org
  2021-09-24 15:29 ` rearnsha at gcc dot gnu.org
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2021-09-24 15:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #6 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
So I think we need a way of checking that this won't fail before we call it.

Any idea?

              tree type = lang_hooks.types.type_for_size (ilen * 8, 1);

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-09-24 15:24 ` rearnsha at gcc dot gnu.org
@ 2021-09-24 15:29 ` rearnsha at gcc dot gnu.org
  2021-09-24 15:41 ` rearnsha at gcc dot gnu.org
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2021-09-24 15:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #7 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
(In reply to Richard Earnshaw from comment #6)
> So I think we need a way of checking that this won't fail before we call it.
> 
> Any idea?
> 
> 	      tree type = lang_hooks.types.type_for_size (ilen * 8, 1);

Or alternatively, perhaps this should just return NULL if there is no such
type, we already test for that.  In which case this is a bug in the Ada
type_for_size routine.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-09-24 15:29 ` rearnsha at gcc dot gnu.org
@ 2021-09-24 15:41 ` rearnsha at gcc dot gnu.org
  2021-09-27  6:10 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2021-09-24 15:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #8 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
I suspect go has a similar issue, but it looks as though c, c++, fortran and d
are all ok.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-09-24 15:41 ` rearnsha at gcc dot gnu.org
@ 2021-09-27  6:10 ` rguenth at gcc dot gnu.org
  2021-09-27 10:34 ` ebotcazou at gcc dot gnu.org
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-27  6:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
                 CC|                            |ebotcazou at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yeah, type_for_size should return any of the _standard_ integer types with the
given precision/size.  It is not an replacement for random integer type
construction.

OTOH the gimple folding code doing

              tree type = lang_hooks.types.type_for_size (ilen * 8, 1);

could eventually instead use mode_for_size (and check that size == precision)
and then type_for_mode.  The code already looks at the mode for verification
and it would avoid the Ada issue at least (I still think the Ada FE shouldn't
ICE when being passed not supported precisions):

              if (type
                  && is_a <scalar_int_mode> (TYPE_MODE (type), &mode)
                  && GET_MODE_SIZE (mode) * BITS_PER_UNIT == ilen * 8
                  && have_insn_for (SET, mode)

Eric?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-09-27  6:10 ` rguenth at gcc dot gnu.org
@ 2021-09-27 10:34 ` ebotcazou at gcc dot gnu.org
  2021-09-27 10:37 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-09-27 10:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> #define BITS_PER_UNIT (8)
> #define MAX_BITSIZE_MODE_ANY_INT (16*BITS_PER_UNIT)
> #define MAX_BITSIZE_MODE_ANY_MODE (32*BITS_PER_UNIT)
> 
> However, TImode is not supported on this target.

So what's the 16-byte integer mode for this target (MAX_MODE_INT)?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2021-09-27 10:34 ` ebotcazou at gcc dot gnu.org
@ 2021-09-27 10:37 ` rguenth at gcc dot gnu.org
  2021-09-27 10:46 ` ebotcazou at gcc dot gnu.org
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-27 10:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #10)
> > #define BITS_PER_UNIT (8)
> > #define MAX_BITSIZE_MODE_ANY_INT (16*BITS_PER_UNIT)
> > #define MAX_BITSIZE_MODE_ANY_MODE (32*BITS_PER_UNIT)
> > 
> > However, TImode is not supported on this target.
> 
> So what's the 16-byte integer mode for this target (MAX_MODE_INT)?

  MIN_MODE_INT = E_QImode,
  MAX_MODE_INT = E_TImode,

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2021-09-27 10:37 ` rguenth at gcc dot gnu.org
@ 2021-09-27 10:46 ` ebotcazou at gcc dot gnu.org
  2021-09-27 11:03 ` ebotcazou at gcc dot gnu.org
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-09-27 10:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #12 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> > So what's the 16-byte integer mode for this target (MAX_MODE_INT)?
> 
>   MIN_MODE_INT = E_QImode,
>   MAX_MODE_INT = E_TImode,

So the problem is with OImode, not TImode, in the end?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2021-09-27 10:46 ` ebotcazou at gcc dot gnu.org
@ 2021-09-27 11:03 ` ebotcazou at gcc dot gnu.org
  2021-09-27 11:26 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-09-27 11:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #13 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> OTOH the gimple folding code doing
> 
>               tree type = lang_hooks.types.type_for_size (ilen * 8, 1);
> 
> could eventually instead use mode_for_size (and check that size == precision)
> and then type_for_mode.  The code already looks at the mode for verification
> and it would avoid the Ada issue at least (I still think the Ada FE shouldn't
> ICE when being passed not supported precisions):
> 
>               if (type
>                   && is_a <scalar_int_mode> (TYPE_MODE (type), &mode)
>                   && GET_MODE_SIZE (mode) * BITS_PER_UNIT == ilen * 8
>                   && have_insn_for (SET, mode)

Yes, I'd agree, the int_mode_for_size interface has exists().

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (12 preceding siblings ...)
  2021-09-27 11:03 ` ebotcazou at gcc dot gnu.org
@ 2021-09-27 11:26 ` rguenth at gcc dot gnu.org
  2021-09-27 11:29 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-27 11:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #12)
> > > So what's the 16-byte integer mode for this target (MAX_MODE_INT)?
> > 
> >   MIN_MODE_INT = E_QImode,
> >   MAX_MODE_INT = E_TImode,
> 
> So the problem is with OImode, not TImode, in the end?

the folding is capped to MOVE_MAX * MOVE_RATIO which for pa is
8 * (TARGET_64BIT ? 8 : 4), which would be up to XImode.  So the code
really relies on type_for_size returning NULL for unsupported types
at the moment.

That works fine with all but Ada (and maybe Go) because everybody else
just compares against standard type precisions/signs and never builds a
new type in type_for_size.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (13 preceding siblings ...)
  2021-09-27 11:26 ` rguenth at gcc dot gnu.org
@ 2021-09-27 11:29 ` rguenth at gcc dot gnu.org
  2021-09-27 11:48 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-27 11:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #14)
> (In reply to Eric Botcazou from comment #12)
> > > > So what's the 16-byte integer mode for this target (MAX_MODE_INT)?
> > > 
> > >   MIN_MODE_INT = E_QImode,
> > >   MAX_MODE_INT = E_TImode,
> > 
> > So the problem is with OImode, not TImode, in the end?
> 
> the folding is capped to MOVE_MAX * MOVE_RATIO which for pa is
> 8 * (TARGET_64BIT ? 8 : 4), which would be up to XImode.  So the code
> really relies on type_for_size returning NULL for unsupported types
> at the moment.
> 
> That works fine with all but Ada (and maybe Go) because everybody else
> just compares against standard type precisions/signs and never builds a
> new type in type_for_size.

the only documentation for type_for_size seems to be the comment in
langhooks.h:

  /* Given PRECISION and UNSIGNEDP, return a suitable type-tree for an
     integer type with at least that precision.  */
  tree (*type_for_size) (unsigned, int);

which doesn't even say the langhook may fail.

Let me avoid the issue in gimple-fold.c.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (14 preceding siblings ...)
  2021-09-27 11:29 ` rguenth at gcc dot gnu.org
@ 2021-09-27 11:48 ` rguenth at gcc dot gnu.org
  2021-09-27 13:04 ` cvs-commit at gcc dot gnu.org
  2021-09-27 13:05 ` rguenth at gcc dot gnu.org
  17 siblings, 0 replies; 19+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-27 11:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
Like the following - what's missing in realizing full opportunities is
eventually allowing vector integer modes for the move as well, like with

  (int_mode_for_size (ilen * 8, 0).exists (&mode)
   || mode_for_size (ilen * 8, MODE_VECTOR_INT, 0).exists (&mode))

but the previous implementation didn't do that and so it's not part of a
fix for this particular problem.  It would also require building a
vector type of course.

diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 6fea8a6f9fd..474d0f44375 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1001,9 +1001,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
                  return false;

              scalar_int_mode mode;
-             tree type = lang_hooks.types.type_for_size (ilen * 8, 1);
-             if (type
-                 && is_a <scalar_int_mode> (TYPE_MODE (type), &mode)
+             if (int_mode_for_size (ilen * 8, 0).exists (&mode)
                  && GET_MODE_SIZE (mode) * BITS_PER_UNIT == ilen * 8
                  && have_insn_for (SET, mode)
                  /* If the destination pointer is not aligned we must be able
@@ -1013,6 +1011,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
                      || (optab_handler (movmisalign_optab, mode)
                          != CODE_FOR_nothing)))
                {
+                 tree type = build_nonstandard_integer_type (ilen * 8, 1);
                  tree srctype = type;
                  tree desttype = type;
                  if (src_align < GET_MODE_ALIGNMENT (mode))

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (15 preceding siblings ...)
  2021-09-27 11:48 ` rguenth at gcc dot gnu.org
@ 2021-09-27 13:04 ` cvs-commit at gcc dot gnu.org
  2021-09-27 13:05 ` rguenth at gcc dot gnu.org
  17 siblings, 0 replies; 19+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-27 13:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:d06dc8a2c73735e9496f434787ba4c93ceee5eea

commit r12-3899-gd06dc8a2c73735e9496f434787ba4c93ceee5eea
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Sep 27 13:36:12 2021 +0200

    middle-end/102450 - avoid type_for_size for non-existing modes

    This avoids asking type_for_size for types with sizes for which
    no scalar integer mode exists.  Instead the following uses
    int_mode_for_size to get the same result.

    2021-09-27  Richard Biener  <rguenther@suse.de>

            PR middle-end/102450
            * gimple-fold.c (gimple_fold_builtin_memory_op): Avoid using
            type_for_size, instead use int_mode_for_size.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
                   ` (16 preceding siblings ...)
  2021-09-27 13:04 ` cvs-commit at gcc dot gnu.org
@ 2021-09-27 13:05 ` rguenth at gcc dot gnu.org
  17 siblings, 0 replies; 19+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-09-27 13:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> ---
The reported issue should be fixed now.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-09-27 13:05 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 12:30 [Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 danglin at gcc dot gnu.org
2021-09-22 13:14 ` [Bug ada/102450] " rguenth at gcc dot gnu.org
2021-09-22 13:47 ` dave.anglin at bell dot net
2021-09-22 15:04 ` dave.anglin at bell dot net
2021-09-24  9:44 ` rdapp at linux dot ibm.com
2021-09-24 14:37 ` rdapp at linux dot ibm.com
2021-09-24 15:24 ` rearnsha at gcc dot gnu.org
2021-09-24 15:29 ` rearnsha at gcc dot gnu.org
2021-09-24 15:41 ` rearnsha at gcc dot gnu.org
2021-09-27  6:10 ` rguenth at gcc dot gnu.org
2021-09-27 10:34 ` ebotcazou at gcc dot gnu.org
2021-09-27 10:37 ` rguenth at gcc dot gnu.org
2021-09-27 10:46 ` ebotcazou at gcc dot gnu.org
2021-09-27 11:03 ` ebotcazou at gcc dot gnu.org
2021-09-27 11:26 ` rguenth at gcc dot gnu.org
2021-09-27 11:29 ` rguenth at gcc dot gnu.org
2021-09-27 11:48 ` rguenth at gcc dot gnu.org
2021-09-27 13:04 ` cvs-commit at gcc dot gnu.org
2021-09-27 13:05 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).