[gcc r15-2741] middle-end/111821 - compile-time/memory-hog with large copy
https://gcc.gnu.org/g:8f3d0c8c3dd02d94635517c68fd314cbceed8373 commit r15-2741-g8f3d0c8c3dd02d94635517c68fd314cbceed8373 Author: Richard Biener Date: Fri Aug 2 13:49:34 2024 +0200 middle-end/111821 - compile-time/memory-hog with large copy The following fixes a compile-time/memory-hog when performing a large aggregate copy to a small object allocated to a register. While store_bit_field_1 called by store_integral_bit_field will do nothign for accesses outside of the target the loop over the source in store_integral_bit_field will still code-generate the read parts for all words in the source. The following copies the noop condition from store_bit_field_1 and terminates the loop when it runs forward or avoid code-generating the read parts when not. PR middle-end/111821 * expmed.cc (store_integral_bit_field): Terminate the word-wise copy loop when we get out of the destination and do a forward copy. Skip the word if it would be outside of the destination in case of a backward copy. * gcc.dg/torture/pr111821.c: New testcase. Diff: --- gcc/expmed.cc | 12 gcc/testsuite/gcc.dg/torture/pr111821.c | 9 + 2 files changed, 21 insertions(+) diff --git a/gcc/expmed.cc b/gcc/expmed.cc index 154964bd0687..2ca93e30e8f2 100644 --- a/gcc/expmed.cc +++ b/gcc/expmed.cc @@ -986,6 +986,18 @@ store_integral_bit_field (rtx op0, opt_scalar_int_mode op0_mode, = backwards ^ reverse ? MAX ((int) bitsize - (i + 1) * BITS_PER_WORD, 0) : i * BITS_PER_WORD; + + /* No further action is needed if the target is a register and if +this field lies completely outside that register. */ + if (REG_P (op0) && known_ge (bitnum + bit_offset, + GET_MODE_BITSIZE (GET_MODE (op0 + { + if (backwards ^ reverse) + continue; + /* For forward operation we are finished. */ + return true; + } + /* Starting word number in the value. */ const unsigned int wordnum = backwards diff --git a/gcc/testsuite/gcc.dg/torture/pr111821.c b/gcc/testsuite/gcc.dg/torture/pr111821.c new file mode 100644 index ..eec6eed6c8ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr111821.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +typedef union { char a[__INT_MAX__ / 4]; } T; +unsigned short f(const void *p) +{ + unsigned short v; + *(T *)(void *)(&v) = *(const T *)p; + return v; +}
[gcc r15-2742] libgomp: Device load_image - improve minor num-funcs/vars check
https://gcc.gnu.org/g:0c56fd6a1fe086e038e61041b82df63e98958e9c commit r15-2742-g0c56fd6a1fe086e038e61041b82df63e98958e9c Author: Tobias Burnus Date: Tue Aug 6 10:34:28 2024 +0200 libgomp: Device load_image - improve minor num-funcs/vars check The run time library loads the offload functions and variable and optionally the ICV variable and returns the number of loaded items, which has to match the host side. The plugin returns "+1" (since GCC 12) for the ICV variable entry, independently whether it was loaded or not, but the var's value (start == end == 0) can be used to detect when this failed. Thus, we can tighten the assert check - which this commit does together with making the output less surprising - and simplify the condition further below. libgomp/ChangeLog: * target.c (gomp_load_image_to_device): Extend fatal-error message; simplify a condition. Diff: --- libgomp/target.c | 78 +--- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/libgomp/target.c b/libgomp/target.c index efed6ad68ff4..fb9a6fb5c79e 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -2362,15 +2362,14 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version, num_ind_funcs ? (uint64_t *) host_ind_func_table : NULL); - if (num_target_entries != num_funcs + num_vars - /* "+1" due to the additional ICV struct. */ - && num_target_entries != num_funcs + num_vars + 1) + /* The "+1" is due to the additional ICV struct. */ + if (num_target_entries != num_funcs + num_vars + 1) { gomp_mutex_unlock (&devicep->lock); if (is_register_lock) gomp_mutex_unlock (®ister_lock); gomp_fatal ("Cannot map target functions or variables" - " (expected %u, have %u)", num_funcs + num_vars, + " (expected %u + %u + 1, have %u)", num_funcs, num_vars, num_target_entries); } @@ -2454,48 +2453,41 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version, array++; } - /* Last entry is for a ICVs variable. - Tolerate case where plugin does not return those entries. */ - if (num_funcs + num_vars < num_target_entries) + /* Last entry is for the ICV struct variable; if absent, start = end = 0. */ + struct addr_pair *icv_var = &target_table[num_funcs + num_vars]; + if (icv_var->start != 0) { - struct addr_pair *var = &target_table[num_funcs + num_vars]; - - /* Start address will be non-zero for the ICVs variable if -the variable was found in this image. */ - if (var->start != 0) + /* The index of the devicep within devices[] is regarded as its +'device number', which is different from the per-device type +devicep->target_id. */ + int dev_num = (int) (devicep - &devices[0]); + struct gomp_offload_icvs *icvs = get_gomp_offload_icvs (dev_num); + size_t var_size = icv_var->end - icv_var->start; + if (var_size != sizeof (struct gomp_offload_icvs)) { - /* The index of the devicep within devices[] is regarded as its -'device number', which is different from the per-device type -devicep->target_id. */ - int dev_num = (int) (devicep - &devices[0]); - struct gomp_offload_icvs *icvs = get_gomp_offload_icvs (dev_num); - size_t var_size = var->end - var->start; - if (var_size != sizeof (struct gomp_offload_icvs)) - { - gomp_mutex_unlock (&devicep->lock); - if (is_register_lock) - gomp_mutex_unlock (®ister_lock); - gomp_fatal ("offload plugin managed 'icv struct' not of expected " - "format"); - } - /* Copy the ICVs variable to place on device memory, hereby -actually designating its device number into effect. */ - gomp_copy_host2dev (devicep, NULL, (void *) var->start, icvs, - var_size, false, NULL); - splay_tree_key k = &array->key; - k->host_start = (uintptr_t) icvs; - k->host_end = - k->host_start + (size_mask & sizeof (struct gomp_offload_icvs)); - k->tgt = tgt; - k->tgt_offset = var->start; - k->refcount = REFCOUNT_INFINITY; - k->dynamic_refcount = 0; - k->aux = NULL; - array->left = NULL; - array->right = NULL; - splay_tree_insert (&devicep->mem_map, array); - array++; + gomp_mutex_unlock (&devicep->lock); + if (is_register_lock) + gomp_mutex_unlock (®ister_lock); + gomp_fatal ("offload plugin managed 'icv struct' not of expected " + "format"); } + /* Copy the ICVs variable to place on device memory, hereby +
[gcc r15-2743] ada: Reject use-clause conflicts in the run-time library
https://gcc.gnu.org/g:070f973cd3b99ed57cd40582fa90eb08dc5f84c4 commit r15-2743-g070f973cd3b99ed57cd40582fa90eb08dc5f84c4 Author: Bob Duff Date: Wed Jul 17 19:42:57 2024 -0400 ada: Reject use-clause conflicts in the run-time library This patch fixes a bug where GNAT would fail to detect certain errors when compiling the run-time library. In particular, if two overloaded homographs are both directly visible, it would pick one, rather than complaining about the ambiguity. The problem was that some special-purpose code in Sem_Ch8 was trying to make a user name take precedence over some run-time library declaration that (incorrectly) appears to be visible because of rtsfind. The solution is to disable that code while compiling the run-time library itself. In addition, we fix the newly-found errors in the run-time library. gcc/ada/ * sem_ch8.adb (Find_Direct_Name): Disable the special-purpose code when we are actually compiling the run-time library itself. * libgnarl/a-exetim__posix.adb: Fix newly-found use-clause conflicts. * libgnat/a-direct.adb: Likewise. * libgnat/a-nbnbin.adb: Likewise. * libgnat/a-timoio__128.adb: Likewise. * libgnat/a-timoio.adb: Likewise. * libgnat/a-wtmoio__128.adb: Likewise. * libgnat/a-wtmoio.adb: Likewise. * libgnat/a-ztmoio__128.adb: Likewise. * libgnat/a-ztmoio.adb: Likewise. Diff: --- gcc/ada/libgnarl/a-exetim__posix.adb | 4 ++-- gcc/ada/libgnat/a-direct.adb | 4 ++-- gcc/ada/libgnat/a-nbnbin.adb | 3 ++- gcc/ada/libgnat/a-timoio.adb | 5 + gcc/ada/libgnat/a-timoio__128.adb| 8 gcc/ada/libgnat/a-wtmoio.adb | 5 + gcc/ada/libgnat/a-wtmoio__128.adb| 8 gcc/ada/libgnat/a-ztmoio.adb | 5 + gcc/ada/libgnat/a-ztmoio__128.adb| 8 gcc/ada/sem_ch8.adb | 4 +++- 10 files changed, 48 insertions(+), 6 deletions(-) diff --git a/gcc/ada/libgnarl/a-exetim__posix.adb b/gcc/ada/libgnarl/a-exetim__posix.adb index 05c55c567fa7..6f3eecb2fe6d 100644 --- a/gcc/ada/libgnarl/a-exetim__posix.adb +++ b/gcc/ada/libgnarl/a-exetim__posix.adb @@ -113,14 +113,14 @@ package body Ada.Execution_Time is function clock_gettime (clock_id : Interfaces.C.int; tp : access timespec) - return int; + return Interfaces.C.int; pragma Import (C, clock_gettime, "clock_gettime"); -- Function from the POSIX.1b Realtime Extensions library function pthread_getcpuclockid (tid : Thread_Id; clock_id : access Interfaces.C.int) - return int; + return Interfaces.C.int; pragma Import (C, pthread_getcpuclockid, "pthread_getcpuclockid"); -- Function from the Thread CPU-Time Clocks option diff --git a/gcc/ada/libgnat/a-direct.adb b/gcc/ada/libgnat/a-direct.adb index adff12277e89..fbf249cd35e7 100644 --- a/gcc/ada/libgnat/a-direct.adb +++ b/gcc/ada/libgnat/a-direct.adb @@ -1292,7 +1292,7 @@ package body Ada.Directories is Dir_Pointer : Dir_Type_Value; File_Name_Addr : Address; File_Name_Len: aliased Integer; - Pattern_Regex: Regexp; + Pattern_Regex: System.Regexp.Regexp; Call_Result : Integer; pragma Warnings (Off, Call_Result); @@ -1377,7 +1377,7 @@ package body Ada.Directories is Compose (Directory, File_Name) & ASCII.NUL; Path : String renames Path_C (Path_C'First .. Path_C'Last - 1); - Attr : aliased File_Attributes; + Attr : aliased System.File_Attributes.File_Attributes; Exists : Integer; Error : Integer; diff --git a/gcc/ada/libgnat/a-nbnbin.adb b/gcc/ada/libgnat/a-nbnbin.adb index 91074cfbc5c3..2d140a49e530 100644 --- a/gcc/ada/libgnat/a-nbnbin.adb +++ b/gcc/ada/libgnat/a-nbnbin.adb @@ -69,7 +69,8 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is package Bignums is new System.Generic_Bignums (Bignum, Allocate_Bignum, Free_Bignum, To_Bignum); - use Bignums, System; + use System, Bignums; + subtype Bignum is Bignums.Bignum; function Get_Bignum (Arg : Big_Integer) return Bignum is (if Arg.Value.C = System.Null_Address diff --git a/gcc/ada/libgnat/a-timoio.adb b/gcc/ada/libgnat/a-timoio.adb index 65222c1ea0d8..eec92e3959ac 100644 --- a/gcc/ada/libgnat/a-timoio.adb +++ b/gcc/ada/libgnat/a-timoio.adb @@ -36,11 +36,14 @@ with System.Img_LLB; use System.Img_LLB; with System.Img_LLU; use System.Img_LLU; with System.Img_LLW; use System.Img_LLW; with System.Img_WIU; use System.Img_WIU; +with System.Unsigned_Types; with System.Val_Uns; use System.Val_Uns; with System.Val_LLU; use System.Val_LLU; package body Ada.Text
[gcc r15-2744] ada: Fix propagation of SPARK_Mode for renaming-as-body
https://gcc.gnu.org/g:439af1ef21d0d96b1f48d86e8c978e9af81490bc commit r15-2744-g439af1ef21d0d96b1f48d86e8c978e9af81490bc Author: Yannick Moy Date: Mon Jul 22 11:31:03 2024 +0200 ada: Fix propagation of SPARK_Mode for renaming-as-body The value of SPARK_Mode associated with a renaming-as-body might not be the correct one, when the private part of the package containing the declaration has SPARK_Mode Off while the public part has SPARK_Mode On. This may lead to analysis of code by GNATprove that should not be analyzed. gcc/ada/ * freeze.adb (Build_Renamed_Body): Propagate SPARK_Pragma to body build from renaming, so that locally relevant value is taken into account. * sem_ch6.adb (Analyze_Expression_Function): Propagate SPARK_Pragma to body built from expression function, so that locally relevant value is taken into account. Diff: --- gcc/ada/freeze.adb | 7 +++ gcc/ada/sem_ch6.adb | 9 + 2 files changed, 16 insertions(+) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index c8d20d020c70..a947018052c9 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -586,6 +586,13 @@ package body Freeze is Next (Param_Spec); end loop; + -- Copy SPARK pragma from renaming declaration + + Set_SPARK_Pragma +(Defining_Unit_Name (Spec), SPARK_Pragma (New_S)); + Set_SPARK_Pragma_Inherited +(Defining_Unit_Name (Spec), SPARK_Pragma_Inherited (New_S)); + -- In GNATprove, prefer to generate an expression function whenever -- possible, to benefit from the more precise analysis in that case -- (as if an implicit postcondition had been generated). diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 0988fad97e8a..d3912ffc9d5d 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -333,6 +333,15 @@ package body Sem_Ch6 is New_Spec := Copy_Subprogram_Spec (Spec); Prev := Current_Entity_In_Scope (Defining_Entity (Spec)); + -- Copy SPARK pragma from expression function + + Set_SPARK_Pragma +(Defining_Unit_Name (New_Spec), + SPARK_Pragma (Defining_Unit_Name (Spec))); + Set_SPARK_Pragma_Inherited +(Defining_Unit_Name (New_Spec), + SPARK_Pragma_Inherited (Defining_Unit_Name (Spec))); + -- If there are previous overloadable entities with the same name, -- check whether any of them is completed by the expression function. -- In a generic context a formal subprogram has no completion.
[gcc r15-2745] ada: Use fully qualified in the runtime library
https://gcc.gnu.org/g:b25472f38da013d9a0575473db4522bc81d32781 commit r15-2745-gb25472f38da013d9a0575473db4522bc81d32781 Author: Viljar Indus Date: Mon Jul 22 12:10:51 2024 +0300 ada: Use fully qualified in the runtime library gcc/ada/ * libgnarl/s-taprop__mingw.adb: Use fully qualified names to avoid ambiguity. * libgnarl/s-taprop__posix.adb: Likewise. * libgnarl/s-taprop__qnx.adb: Likewise. * libgnarl/s-taprop__rtems.adb: Likewise. Diff: --- gcc/ada/libgnarl/s-taprop__mingw.adb | 2 +- gcc/ada/libgnarl/s-taprop__posix.adb | 2 +- gcc/ada/libgnarl/s-taprop__qnx.adb | 16 gcc/ada/libgnarl/s-taprop__rtems.adb | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/ada/libgnarl/s-taprop__mingw.adb b/gcc/ada/libgnarl/s-taprop__mingw.adb index f77d71970b8c..8c7f59f1c5d2 100644 --- a/gcc/ada/libgnarl/s-taprop__mingw.adb +++ b/gcc/ada/libgnarl/s-taprop__mingw.adb @@ -1035,7 +1035,7 @@ package body System.Task_Primitives.Operations is --- function RT_Resolution return Duration is - Ticks_Per_Second : aliased LARGE_INTEGER; + Ticks_Per_Second : aliased System.OS_Interface.LARGE_INTEGER; begin QueryPerformanceFrequency (Ticks_Per_Second'Access); return Duration (1.0 / Ticks_Per_Second); diff --git a/gcc/ada/libgnarl/s-taprop__posix.adb b/gcc/ada/libgnarl/s-taprop__posix.adb index fb70aaf4976e..3d76679ad4a3 100644 --- a/gcc/ada/libgnarl/s-taprop__posix.adb +++ b/gcc/ada/libgnarl/s-taprop__posix.adb @@ -209,7 +209,7 @@ package body System.Task_Primitives.Operations is new Ada.Unchecked_Conversion (Task_Id, System.Address); function GNAT_pthread_condattr_setup - (attr : access pthread_condattr_t) return int; + (attr : access pthread_condattr_t) return Interfaces.C.int; pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); diff --git a/gcc/ada/libgnarl/s-taprop__qnx.adb b/gcc/ada/libgnarl/s-taprop__qnx.adb index f475c05c562a..39e6983f4382 100644 --- a/gcc/ada/libgnarl/s-taprop__qnx.adb +++ b/gcc/ada/libgnarl/s-taprop__qnx.adb @@ -119,7 +119,7 @@ package body System.Task_Primitives.Operations is function Initialize_Lock (L: not null access RTS_Lock; - Prio : Any_Priority) return int; + Prio : Any_Priority) return Interfaces.C.int; -- Initialize the lock L. If Ceiling_Support is True, then set the ceiling -- to Prio. Returns 0 for success, or ENOMEM for out-of-memory. @@ -220,7 +220,7 @@ package body System.Task_Primitives.Operations is new Ada.Unchecked_Conversion (Task_Id, System.Address); function GNAT_pthread_condattr_setup - (attr : access pthread_condattr_t) return int; + (attr : access pthread_condattr_t) return Interfaces.C.int; pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); @@ -333,11 +333,11 @@ package body System.Task_Primitives.Operations is function Initialize_Lock (L: not null access RTS_Lock; - Prio : Any_Priority) return int + Prio : Any_Priority) return Interfaces.C.int is Attributes : aliased pthread_mutexattr_t; - Result : int; - Result_2 : aliased int; + Result : Interfaces.C.int; + Result_2 : aliased Interfaces.C.int; begin Result := pthread_mutexattr_init (Attributes'Access); @@ -425,9 +425,9 @@ package body System.Task_Primitives.Operations is (L : not null access Lock; Ceiling_Violation : out Boolean) is Self: constant pthread_t := pthread_self; - Result : int; - Policy : aliased int; - Ceiling : aliased int; + Result : Interfaces.C.int; + Policy : aliased Interfaces.C.int; + Ceiling : aliased Interfaces.C.int; Sched : aliased struct_sched_param; begin diff --git a/gcc/ada/libgnarl/s-taprop__rtems.adb b/gcc/ada/libgnarl/s-taprop__rtems.adb index ea8422cb4543..0a33c194ec1f 100644 --- a/gcc/ada/libgnarl/s-taprop__rtems.adb +++ b/gcc/ada/libgnarl/s-taprop__rtems.adb @@ -200,7 +200,7 @@ package body System.Task_Primitives.Operations is new Ada.Unchecked_Conversion (Task_Id, System.Address); function GNAT_pthread_condattr_setup - (attr : access pthread_condattr_t) return int; + (attr : access pthread_condattr_t) return Interfaces.C.int; pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); @@ -304,7 +304,7 @@ package body System.Task_Primitives.Operations is Res := mprotect (Stack_Base - (Stack_Base mod Page_Size) + Page_Size, - size_t (Page_Size), + Interfaces.C.size_t (Page_Size), prot => (if On then PROT_ON else PROT_OFF)); pragma Assert (Res = 0); end if;
[gcc r15-2747] ada: Use fully qualified in more library files
https://gcc.gnu.org/g:b9be798a007a824376dc2995684cbaeb523aac92 commit r15-2747-gb9be798a007a824376dc2995684cbaeb523aac92 Author: Viljar Indus Date: Tue Jul 23 10:47:20 2024 +0300 ada: Use fully qualified in more library files gcc/ada/ * libgnarl/s-interr__hwint.adb: Use fully qualified names to avoid ambiguity. * libgnarl/s-taprop__qnx.adb: Likewise. Diff: --- gcc/ada/libgnarl/s-interr__hwint.adb | 11 ++- gcc/ada/libgnarl/s-taprop__qnx.adb | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gcc/ada/libgnarl/s-interr__hwint.adb b/gcc/ada/libgnarl/s-interr__hwint.adb index 12dde452ff4c..0cccf6fd2947 100644 --- a/gcc/ada/libgnarl/s-interr__hwint.adb +++ b/gcc/ada/libgnarl/s-interr__hwint.adb @@ -482,9 +482,10 @@ package body System.Interrupts is Handler : System.OS_Interface.Interrupt_Handler) is Vec : constant Interrupt_Vector := - Interrupt_Number_To_Vector (int (Interrupt)); + Interrupt_Number_To_Vector +(Interfaces.C.int (Interrupt)); - Status : int; + Status : Interfaces.C.int; begin -- Only install umbrella handler when no Ada handler has already been @@ -613,7 +614,7 @@ package body System.Interrupts is procedure Notify_Interrupt (Param : System.Address) is Interrupt : constant Interrupt_ID := Interrupt_ID (Param); Id: constant Binary_Semaphore_Id := Semaphore_ID_Map (Interrupt); - Status: int; + Status: Interfaces.C.int; begin if Id /= 0 then Status := Binary_Semaphore_Release (Id); @@ -744,7 +745,7 @@ package body System.Interrupts is procedure Unbind_Handler (Interrupt : Interrupt_ID) is - Status : int; + Status : Interfaces.C.int; begin -- Flush server task off semaphore, allowing it to terminate @@ -1024,7 +1025,7 @@ package body System.Interrupts is Tmp_Handler : Parameterless_Handler; Tmp_ID : Task_Id; Tmp_Entry_Index : Task_Entry_Index; - Status : int; + Status : Interfaces.C.int; begin Semaphore_ID_Map (Interrupt) := Int_Sema; diff --git a/gcc/ada/libgnarl/s-taprop__qnx.adb b/gcc/ada/libgnarl/s-taprop__qnx.adb index 39e6983f4382..d6680b58dba2 100644 --- a/gcc/ada/libgnarl/s-taprop__qnx.adb +++ b/gcc/ada/libgnarl/s-taprop__qnx.adb @@ -300,7 +300,7 @@ package body System.Task_Primitives.Operations is Res := mprotect (Stack_Base - (Stack_Base mod Page_Size) + Page_Size, - size_t (Page_Size), + Interfaces.C.size_t (Page_Size), prot => (if On then PROT_ON else PROT_OFF)); pragma Assert (Res = 0); end if;
[gcc r15-2746] ada: Assert failure in repinfo
https://gcc.gnu.org/g:59276c4d98a62e19622dc9ff9905f6d113497811 commit r15-2746-g59276c4d98a62e19622dc9ff9905f6d113497811 Author: Javier Miranda Date: Mon Jul 22 10:26:41 2024 + ada: Assert failure in repinfo Using switch gnatR4, the frontend crashes when generating information for a private record type. gcc/ada/ * repinfo.adb (List_Record_Info): Handle private record types. Diff: --- gcc/ada/repinfo.adb | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 7dada5358f7a..c08a232a3ab0 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -521,7 +521,11 @@ package body Repinfo is elsif Is_Record_Type (E) then if List_Representation_Info >= 1 then - List_Record_Info (E, Bytes_Big_Endian); + if Is_Private_Type (E) then +List_Record_Info (Full_View (E), Bytes_Big_Endian); + else +List_Record_Info (E, Bytes_Big_Endian); + end if; -- Recurse into entities local to a record type
[gcc r15-2749] ada: GNAT-LLVM compiler crash on container aggregates with iterators
https://gcc.gnu.org/g:c0c1e02070f3b05eb9cd0001028be45bbe847ced commit r15-2749-gc0c1e02070f3b05eb9cd0001028be45bbe847ced Author: Gary Dismukes Date: Tue Jul 23 21:05:29 2024 + ada: GNAT-LLVM compiler crash on container aggregates with iterators Recent fixes for container aggregates with iterated element associations exposed a latent bug with loops that are wrapped in blocks, where the loop entity's scope was not adjusted to reflect the new enclosing block scope. gcc/ada/ * sem_ch5.adb (Analyze_Loop_Statement.Wrap_Loop_Statement): Remove the loop Entity_Id from its old scope and insert it in the new block scope that wraps it. Diff: --- gcc/ada/sem_ch5.adb | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index d44a12d1dd14..30fee6e65001 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -3800,8 +3800,9 @@ package body Sem_Ch5 is procedure Wrap_Loop_Statement (Manage_Sec_Stack : Boolean) is Loc : constant Source_Ptr := Sloc (N); -Blk: Node_Id; -Blk_Id : Entity_Id; +Blk : Node_Id; +Blk_Id : Entity_Id; +Loop_Id : constant Entity_Id := Entity (Identifier (N)); begin Blk := @@ -3816,6 +3817,12 @@ package body Sem_Ch5 is Rewrite (N, Blk); Analyze (N); + +-- Transfer the loop entity from its old scope to the new block +-- scope. + +Remove_Entity (Loop_Id); +Append_Entity (Loop_Id, Blk_Id); end Wrap_Loop_Statement; -- Local variables
[gcc r15-2748] ada: Spurious error on the default value of a derived scalar type
https://gcc.gnu.org/g:3e2b3dd728d851480bb752055bb0937cd4812ef1 commit r15-2748-g3e2b3dd728d851480bb752055bb0937cd4812ef1 Author: Javier Miranda Date: Tue Jul 23 11:46:19 2024 + ada: Spurious error on the default value of a derived scalar type When the aspect Default_Value is inherited by a derived scalar type, and both the parent type T and the derived type DT are declared in the same scope, a spurious error may be reported. This occurs if a subprogram declared in the same scope has a parameter of type DT with a default value, leading the compiler to incorrectly flag the default value specified in the aspect of type T as having the wrong type. gcc/ada/ * freeze.adb (Freeze_Entity): For scalar derived types that inherit the aspect Default_Value, do not analyze and resolve the inherited aspect, as the type of the aspect remains the parent type. Diff: --- gcc/ada/freeze.adb | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index a947018052c9..7d5be6b67445 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -7820,7 +7820,24 @@ package body Freeze is -- type itself, and we treat Default_Component_Value similarly for -- the sake of uniformity). - if Is_First_Subtype (E) and then Has_Default_Aspect (E) then + -- But for an inherited Default_Value aspect specification, the type + -- of the aspect remains the parent type. RM 3.3.1(11.1), a dynamic + -- semantics rule, says "The implicit initial value for a scalar + -- subtype that has the Default_Value aspect specified is the value + -- of that aspect converted to the nominal subtype". For an inherited + -- Default_Value aspect specification, no conversion is evaluated at + -- the point of the derived type declaration. + + if Is_First_Subtype (E) + and then Has_Default_Aspect (E) + and then + (not Is_Scalar_Type (E) +or else + not Is_Derived_Type (E) +or else + Default_Aspect_Value (E) +/= Default_Aspect_Value (Etype (Base_Type (E + then declare Nam : Name_Id; Exp : Node_Id;
[gcc r15-2750] ada: Implement type inference for generic parameters
https://gcc.gnu.org/g:891427f2549e38ce393efa92c760c4dd9e50f59f commit r15-2750-g891427f2549e38ce393efa92c760c4dd9e50f59f Author: Bob Duff Date: Wed Jul 24 13:29:01 2024 -0400 ada: Implement type inference for generic parameters ...based on previous work that added Gen_Assocs_Rec. Minor cleanup of that previous work. gcc/ada/ * sem_ch12.adb: Implement type inference for generic parameters. (Maybe_Infer_One): Forbid inference of anonymous subtypes and types. (Inference_Reason): Fix comment. * debug.adb: Document -gnatd_I switch. * errout.ads: Document that Empty is not allowed for "&". * errout.adb (Set_Msg_Insertion_Node): Minor: Do not allow Error_Msg_Node_1 = Empty for "&". Use "in" instead of multiple "=". Improve comment. Diff: --- gcc/ada/debug.adb| 5 +- gcc/ada/errout.adb | 23 +-- gcc/ada/errout.ads | 11 +- gcc/ada/sem_ch12.adb | 482 +-- 4 files changed, 485 insertions(+), 36 deletions(-) diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index d2546bec1b5f..fcd04dfb93bd 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -173,7 +173,7 @@ package body Debug is -- d_F Encode full invocation paths in ALI files -- d_G -- d_H - -- d_I + -- d_I Note generic formal type inference -- d_J -- d_K (Reserved) Enable reporting a warning on known-problem issues -- d_L Output trace information on elaboration checking @@ -1029,6 +1029,9 @@ package body Debug is -- an external target, offering additional information to GNATBIND for -- purposes of error diagnostics. + -- d_I Generic formal type inference: print a "note:" message for each + -- actual type that is inferred, or could be inferred. + -- d_K (Reserved) Enable reporting a warning on known-problem issues of -- previous releases. No action performed in the wavefront. diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index c6534fe2a765..c8d87f0f9bb0 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -3866,18 +3866,13 @@ package body Errout is procedure Set_Msg_Insertion_Node is + pragma Assert (Present (Error_Msg_Node_1)); K : Node_Kind; begin - Suppress_Message := -Error_Msg_Node_1 = Error - or else Error_Msg_Node_1 = Any_Type; + Suppress_Message := Error_Msg_Node_1 in Error | Any_Type; - if Error_Msg_Node_1 = Empty then - Set_Msg_Blank_Conditional; - Set_Msg_Str (""); - - elsif Error_Msg_Node_1 = Error then + if Error_Msg_Node_1 = Error then Set_Msg_Blank; Set_Msg_Str (""); @@ -3898,15 +3893,11 @@ package body Errout is K := Nkind (Error_Msg_Node_1); - -- If we have operator case, skip quotes since name of operator - -- itself will supply the required quotations. An operator can be an - -- applied use in an expression or an explicit operator symbol, or an - -- identifier whose name indicates it is an operator. + -- Skip quotes in the operator case, because the operator will supply + -- the required quotes. - if K in N_Op - or else K = N_Operator_Symbol - or else K = N_Defining_Operator_Symbol - or else ((K = N_Identifier or else K = N_Defining_Identifier) + if K in N_Op | N_Operator_Symbol | N_Defining_Operator_Symbol + or else (K in N_Identifier | N_Defining_Identifier and then Is_Operator_Name (Chars (Error_Msg_Node_1))) then Set_Msg_Node (Error_Msg_Node_1); diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads index f0e3f5d0b7cb..2b0410ae6908 100644 --- a/gcc/ada/errout.ads +++ b/gcc/ada/errout.ads @@ -173,12 +173,11 @@ package Errout is -- obtained from the Sloc field of the given node or nodes. If no Sloc -- is available (happens e.g. for nodes in package Standard), then the -- default case (see Scans spec) is used. The nodes to be used are - -- stored in Error_Msg_Node_1, Error_Msg_Node_2. No insertion occurs - -- for the Empty node, and the Error node results in the insertion of - -- the characters . In addition, if the special global variable - -- Error_Msg_Qual_Level is non-zero, then the reference will include - -- up to the given number of levels of qualification, using the scope - -- chain. + -- stored in Error_Msg_Node_1, Error_Msg_Node_2, which must not be + -- Empty. The Error node results in the insertion of "". In + -- addition, if the special global variable Error_Msg_Qual_Level is + -- non-zero, then the reference will include up to the given number of + -- levels of qualification, using the scope chain. -- --
[gcc r15-2751] ada: Fix error in GNATprove inlining with array concatenation
https://gcc.gnu.org/g:cfa788bc679bb552640493c4486dde5bd84d1400 commit r15-2751-gcfa788bc679bb552640493c4486dde5bd84d1400 Author: Yannick Moy Date: Wed Jul 24 17:36:20 2024 +0200 ada: Fix error in GNATprove inlining with array concatenation Wrong interpretation of the type of the concatenation can lead to a spurious error in GNATprove when inlining code. Now fixed. gcc/ada/ * sem_ch4.adb (Analyze_Concatenation_Rest): Do not add a wrong interpretation of the concatenation, using the type of the operand already recognized as of the element type. Diff: --- gcc/ada/sem_ch4.adb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index fc3a2a43c3c9..9b77a81e43ef 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -1995,6 +1995,7 @@ package body Sem_Ch4 is (Root_Type (LT) = Standard_String or else Scope (LT) /= Standard_Standard) and then Etype (R) = Any_String + and then not Is_Component_Left_Opnd (N) then Add_One_Interp (N, Op_Id, LT); @@ -2002,6 +2003,7 @@ package body Sem_Ch4 is (Root_Type (RT) = Standard_String or else Scope (RT) /= Standard_Standard) and then Etype (L) = Any_String + and then not Is_Component_Right_Opnd (N) then Add_One_Interp (N, Op_Id, RT);
[gcc r15-2752] wide-int: Fix up mul_internal overflow checking [PR116224]
https://gcc.gnu.org/g:69093fd8aa682a1b906e80b3c5f10956e692b7c4 commit r15-2752-g69093fd8aa682a1b906e80b3c5f10956e692b7c4 Author: Jakub Jelinek Date: Tue Aug 6 11:09:33 2024 +0200 wide-int: Fix up mul_internal overflow checking [PR116224] The following testcase is miscompiled, because wi::mul for (_BitInt(65))-15 times (_BitInt(65))-15 computes the right value (_BitInt(65))225, but sets *overflow to wi::OVF_UNKNOWN as that it overflowed when it didn't. Even signed operands are unpacked as unsigned but because they are implicitly sign-extended from the represented value (the operands obviously have len==1), we get 0xfff1, 0x, 0x1, 0x0 in both u and v (0x1 because that is exactly 65 bits). We then multiply these. Next step is because both the high and overflow handling expects the high half to start at a limb boundary the bits of the result starting with bit 65 are shifted up by 63 such that the bits relevant for high/need_overflow start at the half of the 4th half wide int limb. Because both operands are negative that part is then adjusted. The reason mul_internal says there is overflow is because of the unspecified garbage in the most significant bits of the result which the adjusting doesn't clean up. 65 bit multiplication needs 65 bits of result and 65 bits of the high part, can't produce more, so the following patch fixes it by checking for the overflow only in those first 65 bits of the high part, not anything beyond that. If it was a highpart multiply, we'd have ignored that as well (canonicalized). 2024-08-06 Jakub Jelinek PR tree-optimization/116224 * wide-int.cc (wi::mul_internal): If prec isn't multiple of HOST_BITS_PER_WIDE_INT, for need_overflow checking only look at the least significant prec bits starting with r[half_blocks_needed]. * gcc.dg/torture/bitint-72.c: New test. Diff: --- gcc/testsuite/gcc.dg/torture/bitint-72.c | 28 gcc/wide-int.cc | 19 ++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/bitint-72.c b/gcc/testsuite/gcc.dg/torture/bitint-72.c new file mode 100644 index ..101018b00eeb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/bitint-72.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/116224 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c23" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 65 +#define N 65 +#else +#define N 63 +#endif + +signed char g; + +int +foo (signed char c, int i, _BitInt(N) b) +{ + __builtin_memmove (&g, &b, 1); + return b / i / c; +} + +int +main () +{ + int x = foo (-15, -15, 900); + if (x != 4) +__builtin_abort (); +} diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc index 9c6eba807aad..5bd16a595643 100644 --- a/gcc/wide-int.cc +++ b/gcc/wide-int.cc @@ -1574,7 +1574,24 @@ wi::mul_internal (HOST_WIDE_INT *val, const HOST_WIDE_INT *op1val, top &= mask; } - for (i = half_blocks_needed; i < half_blocks_needed * 2; i++) + unsigned int end = half_blocks_needed * 2; + shift = prec % HOST_BITS_PER_WIDE_INT; + if (shift) + { + /* For overflow checking only look at the first prec bits +starting with r[half_blocks_needed]. */ + if (shift <= HOST_BITS_PER_HALF_WIDE_INT) + --end; + shift %= HOST_BITS_PER_HALF_WIDE_INT; + if (shift) + { + if (top) + r[end - 1] |= ((~(unsigned HOST_HALF_WIDE_INT) 0) << shift); + else + r[end - 1] &= (((unsigned HOST_HALF_WIDE_INT) 1) << shift) - 1; + } + } + for (i = half_blocks_needed; i < end; i++) if (((HOST_WIDE_INT)(r[i] & mask)) != top) /* FIXME: Signed overflow type is not implemented yet. */ *overflow = (sgn == UNSIGNED) ? wi::OVF_OVERFLOW : wi::OVF_UNKNOWN;
[gcc r14-10565] fortran: Fix up pasto in gfc_get_array_descr_info
https://gcc.gnu.org/g:cad2693096cd2395409aada5c26b56e3aeb6e849 commit r14-10565-gcad2693096cd2395409aada5c26b56e3aeb6e849 Author: Jakub Jelinek Date: Thu Aug 1 20:23:15 2024 +0200 fortran: Fix up pasto in gfc_get_array_descr_info A static analyzer found a pasto in gfc_get_array_descr_info. The code does t = base_decl; if (!integer_zerop (dtype_off)) t = fold_build_pointer_plus (t, dtype_off); dtype = TYPE_MAIN_VARIANT (get_dtype_type_node ()); field = gfc_advance_chain (TYPE_FIELDS (dtype), GFC_DTYPE_RANK); rank_off = byte_position (field); if (!integer_zerop (dtype_off)) t = fold_build_pointer_plus (t, rank_off); i.e. uses the same !integer_zerop check between both, while it should be checking rank_off in the latter case. This actually doesn't change anything on the generated code, because both the dtype_off and rank_off aren't zero, typedef struct dtype_type { size_t elem_len; int version; signed char rank; signed char type; signed short attribute; } dtype_type; struct { type *base_addr; size_t offset; dtype_type dtype; index_type span; descriptor_dimension dim[]; }; dtype_off is 16 on 64-bit arches and 8 on 32-bit ones and rank_off is 12 on 64-bit arches and 8 on 32-bit arches, so this patch is just to pacify those static analyzers or be prepared if the ABI changes in the future. Because in the current ABI both of those are actually non-zero, doing if (!integer_zerop (something)) t = fold_build_pointer_plus (t, something); actually isn't an optimization, it will consume more compile time. If the ABI changes and we forget to readd it, nothing bad happens, fold_build_pointer_plus handles 0 addends fine, just takes some compile time to handle that. I've kept this if (!integer_zerop (data_off)) guard earlier because data_off is 0 in the current ABI, so it is an optimization there. 2024-08-01 Jakub Jelinek * trans-types.cc (gfc_get_array_descr_info): Don't test if !integer_zerop (dtype_off), use fold_build_pointer_plus unconditionally. (cherry picked from commit 90fe402a89910d4fbe0efc15cf05cf6c0306586a) Diff: --- gcc/fortran/trans-types.cc | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 8466c595e065..61523c7d162b 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -3527,14 +3527,11 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info) { rank = 1; info->ndimensions = 1; - t = base_decl; - if (!integer_zerop (dtype_off)) - t = fold_build_pointer_plus (t, dtype_off); + t = fold_build_pointer_plus (base_decl, dtype_off); dtype = TYPE_MAIN_VARIANT (get_dtype_type_node ()); field = gfc_advance_chain (TYPE_FIELDS (dtype), GFC_DTYPE_RANK); rank_off = byte_position (field); - if (!integer_zerop (dtype_off)) - t = fold_build_pointer_plus (t, rank_off); + t = fold_build_pointer_plus (t, rank_off); t = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (field)), t); t = build1 (INDIRECT_REF, TREE_TYPE (field), t);
[gcc r14-10566] libquadmath: Fix up libquadmath/math/sqrtq.c compilation in some powerpc* configurations [PR116007]
https://gcc.gnu.org/g:3fe5720430a9ba61ed7562aac4d758cc77d49a28 commit r14-10566-g3fe5720430a9ba61ed7562aac4d758cc77d49a28 Author: Jakub Jelinek Date: Sat Aug 3 20:37:54 2024 +0200 libquadmath: Fix up libquadmath/math/sqrtq.c compilation in some powerpc* configurations [PR116007] My PR114623 change started using soft-fp.h and quad.h for the sqrtq implementation. Unfortunately, that seems to fail building in some powerpc* configurations, where TFmode isn't available. quad.h has: #ifndef TFtype typedef float TFtype __attribute__ ((mode (TF))); #endif and uses TFtype. quad.h has: /* Define the complex type corresponding to __float128 ("_Complex __float128" is not allowed) */ #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) typedef _Complex float __attribute__((mode(TC))) __complex128; #else typedef _Complex float __attribute__((mode(KC))) __complex128; #endif with the conditional and KCmode use added during porting of libquadmath to powerpc*, so I've just defined TFtype for powerpc when __LONG_DOUBLE_IEEE128__ isn't defined; I could define it to float __attribute__ ((mode (KF))) but it seemed easier to just define it to __float128 which should do the same thing. 2024-08-03 Jakub Jelinek PR target/116007 * math/sqrtq.c (TFtype): For PowerPC without __LONG_DOUBLE_IEEE128__ define to __float128 before including soft-fp.h and quad.h. (cherry picked from commit 3ac02e67503ccffa3dfeeffc0a60fce6bdaca43b) Diff: --- libquadmath/math/sqrtq.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libquadmath/math/sqrtq.c b/libquadmath/math/sqrtq.c index 8ca2828d42ce..a58998a06670 100644 --- a/libquadmath/math/sqrtq.c +++ b/libquadmath/math/sqrtq.c @@ -9,6 +9,9 @@ && defined(FE_TOWARDZERO) \ && defined(FE_INEXACT) #define USE_SOFT_FP 1 +#if defined(_ARCH_PPC) && !defined(__LONG_DOUBLE_IEEE128__) +#define TFtype __float128 +#endif #include "../../libgcc/soft-fp/soft-fp.h" #include "../../libgcc/soft-fp/quad.h" #endif
[gcc r14-10567] wide-int: Fix up mul_internal overflow checking [PR116224]
https://gcc.gnu.org/g:f2b5ca6be855cede3f0d35d2a1aff08d3c342ac2 commit r14-10567-gf2b5ca6be855cede3f0d35d2a1aff08d3c342ac2 Author: Jakub Jelinek Date: Tue Aug 6 11:09:33 2024 +0200 wide-int: Fix up mul_internal overflow checking [PR116224] The following testcase is miscompiled, because wi::mul for (_BitInt(65))-15 times (_BitInt(65))-15 computes the right value (_BitInt(65))225, but sets *overflow to wi::OVF_UNKNOWN as that it overflowed when it didn't. Even signed operands are unpacked as unsigned but because they are implicitly sign-extended from the represented value (the operands obviously have len==1), we get 0xfff1, 0x, 0x1, 0x0 in both u and v (0x1 because that is exactly 65 bits). We then multiply these. Next step is because both the high and overflow handling expects the high half to start at a limb boundary the bits of the result starting with bit 65 are shifted up by 63 such that the bits relevant for high/need_overflow start at the half of the 4th half wide int limb. Because both operands are negative that part is then adjusted. The reason mul_internal says there is overflow is because of the unspecified garbage in the most significant bits of the result which the adjusting doesn't clean up. 65 bit multiplication needs 65 bits of result and 65 bits of the high part, can't produce more, so the following patch fixes it by checking for the overflow only in those first 65 bits of the high part, not anything beyond that. If it was a highpart multiply, we'd have ignored that as well (canonicalized). 2024-08-06 Jakub Jelinek PR tree-optimization/116224 * wide-int.cc (wi::mul_internal): If prec isn't multiple of HOST_BITS_PER_WIDE_INT, for need_overflow checking only look at the least significant prec bits starting with r[half_blocks_needed]. * gcc.dg/torture/bitint-72.c: New test. (cherry picked from commit 69093fd8aa682a1b906e80b3c5f10956e692b7c4) Diff: --- gcc/testsuite/gcc.dg/torture/bitint-72.c | 28 gcc/wide-int.cc | 19 ++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/bitint-72.c b/gcc/testsuite/gcc.dg/torture/bitint-72.c new file mode 100644 index ..101018b00eeb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/bitint-72.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/116224 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c23" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 65 +#define N 65 +#else +#define N 63 +#endif + +signed char g; + +int +foo (signed char c, int i, _BitInt(N) b) +{ + __builtin_memmove (&g, &b, 1); + return b / i / c; +} + +int +main () +{ + int x = foo (-15, -15, 900); + if (x != 4) +__builtin_abort (); +} diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc index 9c6eba807aad..5bd16a595643 100644 --- a/gcc/wide-int.cc +++ b/gcc/wide-int.cc @@ -1574,7 +1574,24 @@ wi::mul_internal (HOST_WIDE_INT *val, const HOST_WIDE_INT *op1val, top &= mask; } - for (i = half_blocks_needed; i < half_blocks_needed * 2; i++) + unsigned int end = half_blocks_needed * 2; + shift = prec % HOST_BITS_PER_WIDE_INT; + if (shift) + { + /* For overflow checking only look at the first prec bits +starting with r[half_blocks_needed]. */ + if (shift <= HOST_BITS_PER_HALF_WIDE_INT) + --end; + shift %= HOST_BITS_PER_HALF_WIDE_INT; + if (shift) + { + if (top) + r[end - 1] |= ((~(unsigned HOST_HALF_WIDE_INT) 0) << shift); + else + r[end - 1] &= (((unsigned HOST_HALF_WIDE_INT) 1) << shift) - 1; + } + } + for (i = half_blocks_needed; i < end; i++) if (((HOST_WIDE_INT)(r[i] & mask)) != top) /* FIXME: Signed overflow type is not implemented yet. */ *overflow = (sgn == UNSIGNED) ? wi::OVF_OVERFLOW : wi::OVF_UNKNOWN;
[gcc r15-2753] testsuite: Fix up pr116037.c test [PR116245]
https://gcc.gnu.org/g:df4062c54b0b3c5f5c6a1f1a2454abf965100e3a commit r15-2753-gdf4062c54b0b3c5f5c6a1f1a2454abf965100e3a Author: Jakub Jelinek Date: Tue Aug 6 11:52:35 2024 +0200 testsuite: Fix up pr116037.c test [PR116245] The test FAILs on big endian targets, because VV is a vector of unsigned __int128 and VC vector of unsigned char and so ((VC) vv)[0] is 0x01 on little endian but 0xff on big endian and PDP endian. As I believe it is intentional to test it as it is written on little endian, the following patch just adds another case for big endian and for other endians instead of figuring out what exactly to fetch it fetches the whole unsigned __int128 and casts it to unsigned char. Not that pdp11 has __int128 support... 2024-08-06 Jakub Jelinek PR rtl-optimization/116037 PR testsuite/116245 * gcc.dg/torture/pr116037.c (foo): Fix up for big end middle endian. Diff: --- gcc/testsuite/gcc.dg/torture/pr116037.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/gcc/testsuite/gcc.dg/torture/pr116037.c b/gcc/testsuite/gcc.dg/torture/pr116037.c index 86ab50de4b2f..5bab24107fc2 100644 --- a/gcc/testsuite/gcc.dg/torture/pr116037.c +++ b/gcc/testsuite/gcc.dg/torture/pr116037.c @@ -16,7 +16,13 @@ VL vl; VV foo (unsigned long long x, VV vv) { +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ x &= -((VC) vv)[0]; +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + x &= -((VC) vv)[sizeof (__int128) - 1]; +#else + x &= -(unsigned char) (vv[0]); +#endif vi *= (VI) (VS){ -vs[0], vc[0], vs[1], vi[7], vs[7], vl[7], x, vi[5] }; return x + vv; }
[gcc r15-2754] tree-optimization/116241 - ICE with SLP condition reduction
https://gcc.gnu.org/g:31efd46ad8a16aa671f4502816b6b1f9946027ae commit r15-2754-g31efd46ad8a16aa671f4502816b6b1f9946027ae Author: Richard Biener Date: Tue Aug 6 09:50:00 2024 +0200 tree-optimization/116241 - ICE with SLP condition reduction When there's a conversion in front of a SLP condition reduction the code following the reduc-idx SLP chain fails because it assumes there's only COND_EXPRs. PR tree-optimization/116241 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Handle non-COND_EXPR nodes in SLP reduction chain following. * g++.dg/vect/pr116241.cc: New testcase. Diff: --- gcc/testsuite/g++.dg/vect/pr116241.cc | 13 + gcc/tree-vect-loop.cc | 15 +-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/g++.dg/vect/pr116241.cc b/gcc/testsuite/g++.dg/vect/pr116241.cc new file mode 100644 index ..7ab1ade2533a --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr116241.cc @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +short var_27; +long test_var_5; +int test_var_6; +void test(short arr_11[][4][24]) +{ + for (bool i_6 = 0;;) +for (int i_7; i_7;) + for (int i_8; i_8 < test_var_5; i_8 += 1) +var_27 *= test_var_6 && arr_11[2][1][i_8]; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 856ce491c3ec..6456220cdc9b 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -6075,6 +6075,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, while (cond_node != slp_node_instance->reduc_phis) { stmt_vec_info cond_info = SLP_TREE_REPRESENTATIVE (cond_node); + int slp_reduc_idx; if (gimple_assign_rhs_code (cond_info->stmt) == COND_EXPR) { gimple *vec_stmt @@ -6083,13 +6084,15 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, ccompares.safe_push (std::make_pair (gimple_assign_rhs1 (vec_stmt), STMT_VINFO_REDUC_IDX (cond_info) == 2)); - } - /* ??? We probably want to have REDUC_IDX on the SLP node? -We have both three and four children COND_EXPR nodes -dependent on whether the comparison is still embedded -as GENERIC. So work backwards. */ - int slp_reduc_idx = (SLP_TREE_CHILDREN (cond_node).length () - 3 + /* ??? We probably want to have REDUC_IDX on the SLP node? +We have both three and four children COND_EXPR nodes +dependent on whether the comparison is still embedded +as GENERIC. So work backwards. */ + slp_reduc_idx = (SLP_TREE_CHILDREN (cond_node).length () - 3 + STMT_VINFO_REDUC_IDX (cond_info)); + } + else + slp_reduc_idx = STMT_VINFO_REDUC_IDX (cond_info); cond_node = SLP_TREE_CHILDREN (cond_node)[slp_reduc_idx]; } }
[gcc r15-2755] gimple ssa: Put SCCOPY logic into a class
https://gcc.gnu.org/g:af1010268f81fc891a6bbf8ed9d5b8a3b5ce44cb commit r15-2755-gaf1010268f81fc891a6bbf8ed9d5b8a3b5ce44cb Author: Filip Kastl Date: Tue Aug 6 15:19:11 2024 +0200 gimple ssa: Put SCCOPY logic into a class Currently the main logic of the sccopy pass is implemented as static functions. This patch instead puts the code into a class. This also gets rid of a global variable (dead_stmts). gcc/ChangeLog: * gimple-ssa-sccopy.cc (class scc_copy_prop): New class. (replace_scc_by_value): Put into... (scc_copy_prop::replace_scc_by_value): ...scc_copy_prop. (sccopy_visit_op): Put into... (scc_copy_prop::visit_op): ...scc_copy_prop. (sccopy_propagate): Put into... (scc_copy_prop::propagate): ...scc_copy_prop. (init_sccopy): Replace by... (scc_copy_prop::scc_copy_prop): ...the construtor. (finalize_sccopy): Replace by... (scc_copy_prop::~scc_copy_prop): ...the destructor. (pass_sccopy::execute): Use scc_copy_prop. Signed-off-by: Filip Kastl Diff: --- gcc/gimple-ssa-sccopy.cc | 66 +++- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/gcc/gimple-ssa-sccopy.cc b/gcc/gimple-ssa-sccopy.cc index 191a4c0b451d..d9eaeab4abbe 100644 --- a/gcc/gimple-ssa-sccopy.cc +++ b/gcc/gimple-ssa-sccopy.cc @@ -94,11 +94,6 @@ along with GCC; see the file COPYING3. If not see namespace { -/* Bitmap tracking statements which were propagated to be removed at the end of - the pass. */ - -static bitmap dead_stmts; - /* State of vertex during SCC discovery. unvisited Vertex hasn't yet been popped from worklist. @@ -459,11 +454,33 @@ get_all_stmt_may_generate_copy (void) return result; } +/* SCC copy propagation + + 'scc_copy_prop::propagate ()' is the main function of this pass. */ + +class scc_copy_prop +{ +public: + scc_copy_prop (); + ~scc_copy_prop (); + void propagate (); + +private: + /* Bitmap tracking statements which were propagated so that they can be + removed at the end of the pass. */ + bitmap dead_stmts; + + void visit_op (tree op, hash_set &outer_ops, + hash_set &scc_set, bool &is_inner, + tree &last_outer_op); + void replace_scc_by_value (vec scc, tree val); +}; + /* For each statement from given SCC, replace its usages by value VAL. */ -static void -replace_scc_by_value (vec scc, tree val) +void +scc_copy_prop::replace_scc_by_value (vec scc, tree val) { for (gimple *stmt : scc) { @@ -476,12 +493,12 @@ replace_scc_by_value (vec scc, tree val) fprintf (dump_file, "Replacing SCC of size %d\n", scc.length ()); } -/* Part of 'sccopy_propagate ()'. */ +/* Part of 'scc_copy_prop::propagate ()'. */ -static void -sccopy_visit_op (tree op, hash_set &outer_ops, -hash_set &scc_set, bool &is_inner, -tree &last_outer_op) +void +scc_copy_prop::visit_op (tree op, hash_set &outer_ops, +hash_set &scc_set, bool &is_inner, +tree &last_outer_op) { bool op_in_scc = false; @@ -539,8 +556,8 @@ sccopy_visit_op (tree op, hash_set &outer_ops, Braun, Buchwald, Hack, Leissa, Mallon, Zwinkau, 2013, LNCS vol. 7791, Section 3.2. */ -static void -sccopy_propagate () +void +scc_copy_prop::propagate () { auto_vec useful_stmts = get_all_stmt_may_generate_copy (); scc_discovery discovery; @@ -575,14 +592,12 @@ sccopy_propagate () for (j = 0; j < gimple_phi_num_args (phi); j++) { op = gimple_phi_arg_def (phi, j); - sccopy_visit_op (op, outer_ops, scc_set, is_inner, - last_outer_op); + visit_op (op, outer_ops, scc_set, is_inner, last_outer_op); } break; case GIMPLE_ASSIGN: op = gimple_assign_rhs1 (stmt); - sccopy_visit_op (op, outer_ops, scc_set, is_inner, - last_outer_op); + visit_op (op, outer_ops, scc_set, is_inner, last_outer_op); break; default: gcc_unreachable (); @@ -613,19 +628,13 @@ sccopy_propagate () } } -/* Called when pass execution starts. */ - -static void -init_sccopy (void) +scc_copy_prop::scc_copy_prop () { /* For propagated statements. */ dead_stmts = BITMAP_ALLOC (NULL); } -/* Called before pass execution ends. */ - -static void -finalize_sccopy (void) +scc_copy_prop::~scc_copy_prop () { /* Remove all propagated statements. */ simple_dce_from_worklist (dead_stmts); @@ -668,9 +677,8 @@ public: unsigned pass_sccopy::execute (function *) { - init_sccopy (); - sccopy_propagate (); - finalize_sccopy (); + scc_copy_prop sccopy; + sccopy.pro
[gcc r15-2756] c++: fold calls to std::forward_like [PR96780]
https://gcc.gnu.org/g:180625ae72b3f733813a360fae4f0d6ce79eccdc commit r15-2756-g180625ae72b3f733813a360fae4f0d6ce79eccdc Author: Patrick Palka Date: Tue Aug 6 11:51:45 2024 -0400 c++: fold calls to std::forward_like [PR96780] This extends our folding of cast-like standard library functions to also include C++23's std::forward_like. PR c++/96780 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_fold) : Fold calls to std::forward_like as well. gcc/testsuite/ChangeLog: * g++.dg/opt/pr96780.C: Also test std::forward_like folding. Reviewed-by: Marek Polacek Reviewed-by: Jason Merrill Diff: --- gcc/cp/cp-gimplify.cc | 1 + gcc/testsuite/g++.dg/opt/pr96780.C | 5 + 2 files changed, 6 insertions(+) diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index b88c3b7f370b..0c589eeaaec4 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -3313,6 +3313,7 @@ cp_fold (tree x, fold_flags_t flags) && DECL_NAME (callee) != NULL_TREE && (id_equal (DECL_NAME (callee), "move") || id_equal (DECL_NAME (callee), "forward") + || id_equal (DECL_NAME (callee), "forward_like") || id_equal (DECL_NAME (callee), "addressof") /* This addressof equivalent is used heavily in libstdc++. */ || id_equal (DECL_NAME (callee), "__addressof") diff --git a/gcc/testsuite/g++.dg/opt/pr96780.C b/gcc/testsuite/g++.dg/opt/pr96780.C index 61e11855eeb3..a29cda8b836e 100644 --- a/gcc/testsuite/g++.dg/opt/pr96780.C +++ b/gcc/testsuite/g++.dg/opt/pr96780.C @@ -29,6 +29,10 @@ void f() { auto&& x11 = std::as_const(a); auto&& x12 = std::as_const(ca); #endif +#if __cpp_lib_forward_like + auto&& x13 = std::forward_like(a); + auto&& x14 = std::forward_like(ca); +#endif } // { dg-final { scan-tree-dump-not "= std::move" "gimple" } } @@ -36,3 +40,4 @@ void f() { // { dg-final { scan-tree-dump-not "= std::addressof" "gimple" } } // { dg-final { scan-tree-dump-not "= std::__addressof" "gimple" } } // { dg-final { scan-tree-dump-not "= std::as_const" "gimple" } } +// { dg-final { scan-tree-dump-not "= std::forward_like" "gimple" } }
[gcc r15-2757] RISC-V: Fix format-diag warning from improperly formatted url
https://gcc.gnu.org/g:4c3f476e55149f542de538e97dd9800ec9bd1011 commit r15-2757-g4c3f476e55149f542de538e97dd9800ec9bd1011 Author: Patrick O'Neill Date: Tue Aug 6 08:16:26 2024 -0700 RISC-V: Fix format-diag warning from improperly formatted url gcc/ChangeLog: PR target/116152 * config/riscv/riscv.cc (riscv_option_override): Fix url formatting. gcc/testsuite/ChangeLog: * gcc.target/riscv/predef-9.c: Update testcase. Co-authored-by: Jakub Jelinek Signed-off-by: Patrick O'Neill Diff: --- gcc/config/riscv/riscv.cc | 4 ++-- gcc/testsuite/gcc.target/riscv/predef-9.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index b005af62e61f..3f7eec8d69e1 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -9826,8 +9826,8 @@ riscv_option_override (void) if (riscv_abi == ABI_LP64E) { if (warning (OPT_Wdeprecated, "LP64E ABI is marked for deprecation in GCC")) - inform (UNKNOWN_LOCATION, "If you need LP64E please notify the GCC " - "project via https://gcc.gnu.org/PR116152";); + inform (UNKNOWN_LOCATION, "if you need LP64E please notify the GCC " + "project via %{PR116152%}", "https://gcc.gnu.org/PR116152";); } /* Zfinx require abi ilp32, ilp32e, lp64 or lp64e. */ diff --git a/gcc/testsuite/gcc.target/riscv/predef-9.c b/gcc/testsuite/gcc.target/riscv/predef-9.c index 0d9488529ea5..b173d5df57fc 100644 --- a/gcc/testsuite/gcc.target/riscv/predef-9.c +++ b/gcc/testsuite/gcc.target/riscv/predef-9.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-march=rv64em -mabi=lp64e -mno-div -mcmodel=medlow" } */ /* { dg-warning "LP64E ABI is marked for deprecation in GCC" "" { target *-*-* } 0 } */ -/* { dg-note "If you need LP64E please notify the GCC project via https://gcc.gnu.org/PR116152"; "" { target *-*-* } 0 } */ +/* { dg-note "if you need LP64E please notify the GCC project via PR116152" "" { target *-*-* } 0 } */ int main () { #if !defined(__riscv)
[gcc r15-2758] i386: Refactor V2DI arithmetic right shift expansion for STV.
https://gcc.gnu.org/g:2f759fa9f4dd78ae8d86482ccda72a335aaac404 commit r15-2758-g2f759fa9f4dd78ae8d86482ccda72a335aaac404 Author: Roger Sayle Date: Tue Aug 6 17:19:29 2024 +0100 i386: Refactor V2DI arithmetic right shift expansion for STV. This patch refactors ashrv2di RTL expansion into a function so that it may be reused by a pre-reload splitter, such that DImode right shifts may be considered candidates during the Scalar-To-Vector (STV) pass. Currently DImode arithmetic right shifts are not considered potential candidates during STV, so for the following testcase: long long m; typedef long long v2di __attribute__((vector_size (16))); void foo(v2di x) { m = x[0]>>63; } We currently see the following warning/error during STV2 > r101 use in insn 7 isn't convertible And end up generating scalar code with an interunit move: foo:movq%xmm0, %rax sarq$63, %rax movq%rax, m(%rip) ret With this patch, we can reuse the RTL expansion logic and produce: foo:psrad $31, %xmm0 pshufd $245, %xmm0, %xmm0 movq%xmm0, m(%rip) ret Or with the addition of -mavx2, the equivalent: foo:vpxor %xmm1, %xmm1, %xmm1 vpcmpgtq%xmm0, %xmm1, %xmm0 vmovq %xmm0, m(%rip) ret The only design decision of note is the choice to continue lowering V2DI into vector sequences during RTL expansion, to enable combine to optimize things if possible. Using just define_insn_and_split potentially misses optimizations, such as reusing the zero vector produced by vpxor above. It may be necessary to tweak STV's compute gain at some point, but this patch controls what's possible (rather than what's beneficial). 2024-08-06 Roger Sayle gcc/ChangeLog * config/i386/i386-expand.cc (ix86_expand_v2di_ashiftrt): New function refactored from define_expand ashrv2di3. * config/i386/i386-features.cc (general_scalar_to_vector_candidate_p) : Handle like other shifts and rotates. * config/i386/i386-protos.h (ix86_expand_v2di_ashiftrt): Prototype. * config/i386/sse.md (ashrv2di3): Call ix86_expand_v2di_ashiftrt. (*ashrv2di3): New define_insn_and_split to enable creation by stv2 pass, and splitting during split1 reusing ix86_expand_v2di_ashiftrt. gcc/testsuite/ChangeLog * gcc.target/i386/sse2-stv-2.c: New test case. Diff: --- gcc/config/i386/i386-expand.cc | 156 gcc/config/i386/i386-features.cc | 6 +- gcc/config/i386/i386-protos.h | 1 + gcc/config/i386/sse.md | 159 +++-- gcc/testsuite/gcc.target/i386/sse2-stv-2.c | 10 ++ 5 files changed, 180 insertions(+), 152 deletions(-) diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index d9ad06264aaf..bdbc14232679 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -7471,6 +7471,162 @@ ix86_expand_v1ti_ashiftrt (rtx operands[]) } } +/* Expand V2DI mode ashiftrt. */ +void +ix86_expand_v2di_ashiftrt (rtx operands[]) +{ + if (operands[2] == const0_rtx) +{ + emit_move_insn (operands[0], operands[1]); + return; +} + + if (TARGET_SSE4_2 + && CONST_INT_P (operands[2]) + && UINTVAL (operands[2]) >= 63 + && !optimize_insn_for_size_p ()) +{ + rtx zero = force_reg (V2DImode, CONST0_RTX (V2DImode)); + emit_insn (gen_sse4_2_gtv2di3 (operands[0], zero, operands[1])); + return; +} + + if (CONST_INT_P (operands[2]) + && (!TARGET_XOP || UINTVAL (operands[2]) >= 63)) +{ + vec_perm_builder sel (4, 4, 1); + sel.quick_grow (4); + rtx arg0, arg1; + rtx op1 = lowpart_subreg (V4SImode, + force_reg (V2DImode, operands[1]), + V2DImode); + rtx target = gen_reg_rtx (V4SImode); + if (UINTVAL (operands[2]) >= 63) + { + arg0 = arg1 = gen_reg_rtx (V4SImode); + emit_insn (gen_ashrv4si3 (arg0, op1, GEN_INT (31))); + sel[0] = 1; + sel[1] = 1; + sel[2] = 3; + sel[3] = 3; + } + else if (INTVAL (operands[2]) > 32) + { + arg0 = gen_reg_rtx (V4SImode); + arg1 = gen_reg_rtx (V4SImode); + emit_insn (gen_ashrv4si3 (arg1, op1, GEN_INT (31))); + emit_insn (gen_ashrv4si3 (arg0, op1, + GEN_INT (INTVAL (operands[2]) - 32))); + sel[0] = 1; + sel[1] = 5; + sel[2] = 3; + sel[3] = 7; + } + else if (INTVAL (operands[2]) == 32) + { + arg0 = op1; + arg1 = gen_reg_rtx (V4SImode); + emit_insn (gen_ashrv4si3 (arg1,
[gcc r15-2759] c++: zero-init and class nttp [PR94568]
https://gcc.gnu.org/g:352c21c8a22a48d34cbd2fbfe398ee12c0a1d681 commit r15-2759-g352c21c8a22a48d34cbd2fbfe398ee12c0a1d681 Author: Jason Merrill Date: Mon Aug 5 15:04:05 2024 -0400 c++: zero-init and class nttp [PR94568] A zero-initializer should not reflect the constness of what it's initializing, as it does not for initializers with different syntax. This does have mangling implications for rare C++20 code, but it seems infeasable to make the mangling depend on -fabi-version while fixing the semantic bug, and C++20 is still experimental anyway. PR c++/94568 gcc/cp/ChangeLog: * init.cc (build_zero_init_1): Call cv_unqualified. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class36.C: Remove xfail. * g++.dg/cpp2a/nontype-class37.C: Remove xfail. * g++.dg/cpp1z/nontype-auto26.C: New test. Diff: --- gcc/cp/init.cc | 3 +++ gcc/testsuite/g++.dg/cpp1z/nontype-auto26.C | 29 gcc/testsuite/g++.dg/cpp2a/nontype-class36.C | 2 +- gcc/testsuite/g++.dg/cpp2a/nontype-class37.C | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index de82152bd1d3..20373d269882 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -173,6 +173,9 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, gcc_assert (nelts == NULL_TREE || TREE_CODE (nelts) == INTEGER_CST); + /* An initializer is unqualified. */ + type = cv_unqualified (type); + if (type == error_mark_node) ; else if (static_storage_p && zero_init_p (type)) diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto26.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto26.C new file mode 100644 index ..9abe54ed9745 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto26.C @@ -0,0 +1,29 @@ +// PR c++/94568 +// { dg-do compile { target c++20 } } + +struct A; +typedef int A::*MemPtr; + +struct B { MemPtr p; }; + +static constexpr MemPtr mp { }; + +template struct X { }; + +typedef X XB; +typedef XXB; + +struct C { int a[2]; }; +template struct D { }; + +constexpr const int i0 = 0; +constexpr const int i_{ }; + +static_assert (i0 == i_); + +// typedef D DC01; +// typedef D DC01; +typedef D DC01; + +// { dg-final { scan-assembler "_Z1f1DIXtl1CtlA2_iLi0ELi1E" } } +void f(DC01) {} diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class36.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class36.C index 8371eb96621f..2e6d76cd43af 100644 --- a/gcc/testsuite/g++.dg/cpp2a/nontype-class36.C +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class36.C @@ -59,7 +59,7 @@ typedef X XB00p; typedef X XB00p; typedef X XB00p; typedef X XB00p; -typedef X XB00p; // { dg-bogus "conflicting declaration" "pr94568" { xfail *-*-* } } +typedef X XB00p; // { dg-bogus "conflicting declaration" "pr94568" } static const constexpr MemFuncPtr mfp0 = { 0 }; static const constexpr MemFuncPtr mfpn = { nullptr }; diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class37.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class37.C index f5e9826d2431..dc054a9939aa 100644 --- a/gcc/testsuite/g++.dg/cpp2a/nontype-class37.C +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class37.C @@ -77,4 +77,4 @@ typedef DDC01; typedef D DC01; typedef D DC01; typedef D DC01; -typedef D DC01; // { dg-bogus "conflicting declaration" "pr94567" { xfail *-*-* } } +typedef D DC01; // { dg-bogus "conflicting declaration" "pr94568" }
[gcc r15-2761] c++: more non-type template parms [PR116223]
https://gcc.gnu.org/g:b2a8ee0e5d8cfa92bafd0db4b03626b26ac21948 commit r15-2761-gb2a8ee0e5d8cfa92bafd0db4b03626b26ac21948 Author: Jason Merrill Date: Mon Aug 5 13:20:17 2024 -0400 c++: more non-type template parms [PR116223] Building on the last patch, deduction should probably look through all IMPLICIT_CONV_EXPR like we do other conversions. One resulting regression turned out to be due to PR94568, fixed separately. The one other regression was for a seeming mismatch between a function and its address, handled here. Before this change we treated the IMPLICIT_CONV_EXPR as dependent because the template parameter has dependent type. PR c++/116223 gcc/cp/ChangeLog: * pt.cc (deducible_expression): Strip all IMPLICIT_CONV_EXPR. (unify): Likewise. Handle resulting function/addr mismatch. Diff: --- gcc/cp/pt.cc | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index cf65b347f6ca..677ed7d12896 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23031,8 +23031,7 @@ deducible_expression (tree expr) /* Strip implicit conversions and implicit INDIRECT_REFs. */ while (CONVERT_EXPR_P (expr) || TREE_CODE (expr) == VIEW_CONVERT_EXPR -|| (TREE_CODE (expr) == IMPLICIT_CONV_EXPR -&& IMPLICIT_CONV_EXPR_FORCED (expr)) +|| TREE_CODE (expr) == IMPLICIT_CONV_EXPR || REFERENCE_REF_P (expr)) expr = TREE_OPERAND (expr, 0); return (TREE_CODE (expr) == TEMPLATE_PARM_INDEX); @@ -24563,8 +24562,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, okay. VIEW_CONVERT_EXPR can appear with class NTTP, thanks to finish_id_expression_1, and are also OK. */ while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR -|| (TREE_CODE (parm) == IMPLICIT_CONV_EXPR -&& IMPLICIT_CONV_EXPR_FORCED (parm))) +|| TREE_CODE (parm) == IMPLICIT_CONV_EXPR) parm = TREE_OPERAND (parm, 0); if (arg == error_mark_node) @@ -24578,6 +24576,12 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, if (parm == any_targ_node || arg == any_targ_node) return unify_success (explain_p); + /* Stripping IMPLICIT_CONV_EXPR above can produce this mismatch + (g++.dg/abi/mangle57.C). */ + if (TREE_CODE (parm) == FUNCTION_DECL + && TREE_CODE (arg) == ADDR_EXPR) +arg = TREE_OPERAND (arg, 0); + /* If PARM uses template parameters, then we can't bail out here, even if ARG == PARM, since we won't record unifications for the template parameters. We might need them if we're trying to
[gcc r15-2760] c++: alias and non-type template parm [PR116223]
https://gcc.gnu.org/g:4add6cd341a779e980e41ed6fb49175fca37496e commit r15-2760-g4add6cd341a779e980e41ed6fb49175fca37496e Author: Jason Merrill Date: Mon Aug 5 11:21:05 2024 -0400 c++: alias and non-type template parm [PR116223] My r14-8291 for PR112632 introduced IMPLICIT_CONV_EXPR_FORCED to express conversions to the type of an alias template parameter. In this example, that broke deduction of X in the call to foo, so let's teach deduction to look through it. PR c++/116223 PR c++/112632 gcc/cp/ChangeLog: * pt.cc (deducible_expression): Also look through IMPLICIT_CONV_EXPR_FORCED. (unify): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/nontype-auto25.C: New test. Diff: --- gcc/cp/pt.cc| 6 +- gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C | 18 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 35a9c5619f96..cf65b347f6ca 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23031,6 +23031,8 @@ deducible_expression (tree expr) /* Strip implicit conversions and implicit INDIRECT_REFs. */ while (CONVERT_EXPR_P (expr) || TREE_CODE (expr) == VIEW_CONVERT_EXPR +|| (TREE_CODE (expr) == IMPLICIT_CONV_EXPR +&& IMPLICIT_CONV_EXPR_FORCED (expr)) || REFERENCE_REF_P (expr)) expr = TREE_OPERAND (expr, 0); return (TREE_CODE (expr) == TEMPLATE_PARM_INDEX); @@ -24560,7 +24562,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, signedness is the only information lost, and I think that will be okay. VIEW_CONVERT_EXPR can appear with class NTTP, thanks to finish_id_expression_1, and are also OK. */ - while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR) + while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR +|| (TREE_CODE (parm) == IMPLICIT_CONV_EXPR +&& IMPLICIT_CONV_EXPR_FORCED (parm))) parm = TREE_OPERAND (parm, 0); if (arg == error_mark_node) diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C new file mode 100644 index ..36b38b48ec2d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C @@ -0,0 +1,18 @@ +// PR c++/116223 +// { dg-do compile { target c++17 } } + +template struct A { int value = T; }; + +template using B = A; + +template +void foo(B& mat) noexcept +{ + //std::cout << mat.value << "\n"; +} + +int main() +{ +A<2> mat; +foo(mat); +}
[gcc r15-2762] c++: further concept_check_p clean-up
https://gcc.gnu.org/g:68e269092ee405832998b735a796c1953039d5f3 commit r15-2762-g68e269092ee405832998b735a796c1953039d5f3 Author: Marek Polacek Date: Tue Aug 6 09:34:02 2024 -0400 c++: further concept_check_p clean-up Patrick noticed a few more concept_check_p checks that can be removed now. gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Remove concept_check_p check. (cxx_eval_outermost_constant_expr): Likewise. * cp-gimplify.cc (cp_genericize_r) : Likewise. * except.cc (check_noexcept_r): Likewise. Diff: --- gcc/cp/constexpr.cc | 20 ++-- gcc/cp/cp-gimplify.cc | 9 - gcc/cp/except.cc | 2 -- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 8d994f0ee536..b0adbb9036d9 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -2797,10 +2797,6 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, value_cat lval, bool *non_constant_p, bool *overflow_p) { - /* Handle concept checks separately. */ - if (concept_check_p (t)) -return evaluate_concept_check (t); - location_t loc = cp_expr_loc_or_input_loc (t); tree fun = get_function_named_in_call (t); constexpr_call new_call @@ -8774,16 +8770,12 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant, || TREE_CODE (t) == AGGR_INIT_EXPR || TREE_CODE (t) == TARGET_EXPR)) { - /* For non-concept checks, determine if it is consteval. */ - if (!concept_check_p (t)) - { - tree x = t; - if (TREE_CODE (x) == TARGET_EXPR) - x = TARGET_EXPR_INITIAL (x); - tree fndecl = cp_get_callee_fndecl_nofold (x); - if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl)) - is_consteval = true; - } + tree x = t; + if (TREE_CODE (x) == TARGET_EXPR) + x = TARGET_EXPR_INITIAL (x); + tree fndecl = cp_get_callee_fndecl_nofold (x); + if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl)) + is_consteval = true; } if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type)) { diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index 0c589eeaaec4..003e68f1ea72 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -2092,15 +2092,6 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) break; case CALL_EXPR: - /* Evaluate function concept checks instead of treating them as -normal functions. */ - if (concept_check_p (stmt)) - { - *stmt_p = evaluate_concept_check (stmt); - * walk_subtrees = 0; - break; - } - if (!wtd->no_sanitize_p && sanitize_flags_p ((SANITIZE_NULL | SANITIZE_ALIGNMENT | SANITIZE_VPTR))) diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc index 3c69ab695028..0231bd2507d5 100644 --- a/gcc/cp/except.cc +++ b/gcc/cp/except.cc @@ -1074,8 +1074,6 @@ check_noexcept_r (tree *tp, int *walk_subtrees, void *) We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */ tree fn = cp_get_callee (t); - if (concept_check_p (fn)) - return NULL_TREE; tree type = TREE_TYPE (fn); gcc_assert (INDIRECT_TYPE_P (type)); type = TREE_TYPE (type);
[gcc r15-2763] RISC-V: Fix comment typos
https://gcc.gnu.org/g:8089cb8540e780c10bb1279dfae39a4a7c25c83a commit r15-2763-g8089cb8540e780c10bb1279dfae39a4a7c25c83a Author: Patrick O'Neill Date: Mon Aug 5 14:13:12 2024 -0700 RISC-V: Fix comment typos This fixes most of the typos I found when reading various parts of the RISC-V backend. gcc/ChangeLog: * config/riscv/arch-canonicalize: Fix typos in comments. * config/riscv/autovec.md: Ditto. * config/riscv/riscv-avlprop.cc (avl_can_be_propagated_p): Ditto. (pass_avlprop::get_vlmax_ta_preferred_avl): Ditto. * config/riscv/riscv-modes.def (ADJUST_FLOAT_FORMAT): Ditto. (VLS_MODES): Ditto. * config/riscv/riscv-opts.h (TARGET_ZICOND_LIKE): Ditto. (enum rvv_vector_bits_enum): Ditto. * config/riscv/riscv-protos.h (enum insn_flags): Ditto. (enum insn_type): Ditto. * config/riscv/riscv-sr.cc (riscv_sr_match_epilogue): Ditto. * config/riscv/riscv-string.cc (expand_block_move): Ditto. * config/riscv/riscv-v.cc (rvv_builder::is_repeating_sequence): Ditto. (rvv_builder::single_step_npatterns_p): Ditto. (calculate_ratio): Ditto. (expand_const_vector): Ditto. (shuffle_merge_patterns): Ditto. (shuffle_compress_patterns): Ditto. (expand_select_vl): Ditto. * config/riscv/riscv-vector-builtins-functions.def (REQUIRED_EXTENSIONS): Ditto. * config/riscv/riscv-vector-builtins-shapes.h: Ditto. * config/riscv/riscv-vector-builtins.cc (function_builder::add_function): Ditto. (resolve_overloaded_builtin): Ditto. * config/riscv/riscv-vector-builtins.def (vbool1_t): Ditto. (vuint8m8_t): Ditto. (vuint16m8_t): Ditto. (vfloat16m8_t): Ditto. (unsigned_vector): Ditto. * config/riscv/riscv-vector-builtins.h (enum required_ext): Ditto. * config/riscv/riscv-vector-costs.cc (get_store_value): Ditto. (costs::analyze_loop_vinfo): Ditto. (costs::add_stmt_cost): Ditto. * config/riscv/riscv.cc (riscv_build_integer): Ditto. (riscv_vector_type_p): Ditto. * config/riscv/thead.cc (th_mempair_output_move): Ditto. * config/riscv/thead.md: Ditto. * config/riscv/vector-iterators.md: Ditto. * config/riscv/vector.md: Ditto. * config/riscv/zc.md: Ditto. Signed-off-by: Patrick O'Neill Diff: --- gcc/config/riscv/arch-canonicalize | 2 +- gcc/config/riscv/autovec.md| 2 +- gcc/config/riscv/riscv-avlprop.cc | 8 +++--- gcc/config/riscv/riscv-modes.def | 4 +-- gcc/config/riscv/riscv-opts.h | 6 ++--- gcc/config/riscv/riscv-protos.h| 4 +-- gcc/config/riscv/riscv-sr.cc | 4 +-- gcc/config/riscv/riscv-string.cc | 6 ++--- gcc/config/riscv/riscv-v.cc| 24 - .../riscv/riscv-vector-builtins-functions.def | 2 +- gcc/config/riscv/riscv-vector-builtins-shapes.h| 2 +- gcc/config/riscv/riscv-vector-builtins.cc | 8 +++--- gcc/config/riscv/riscv-vector-builtins.def | 10 gcc/config/riscv/riscv-vector-builtins.h | 6 ++--- gcc/config/riscv/riscv-vector-costs.cc | 8 +++--- gcc/config/riscv/riscv.cc | 6 ++--- gcc/config/riscv/thead.cc | 2 +- gcc/config/riscv/thead.md | 2 +- gcc/config/riscv/vector-iterators.md | 2 +- gcc/config/riscv/vector.md | 30 +++--- gcc/config/riscv/zc.md | 2 +- 21 files changed, 70 insertions(+), 70 deletions(-) diff --git a/gcc/config/riscv/arch-canonicalize b/gcc/config/riscv/arch-canonicalize index 35e0f46b6bd3..95cfe17f9124 100755 --- a/gcc/config/riscv/arch-canonicalize +++ b/gcc/config/riscv/arch-canonicalize @@ -140,7 +140,7 @@ def arch_canonicalize(arch, isa_spec): any_change = True # Single letter extension might appear in the long_exts list, - # becasue we just append extensions list to the arch string. + # because we just append extensions list to the arch string. std_exts += list(filter(lambda x:len(x) == 1, long_exts)) def longext_sort (exts): diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index d5793acc..0423d7bee137 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -794,7 +794,7 @@ }) ;; - -;; Truncation to a mode whose inner mode size is an eigth of mode's. +;; Truncation to a mode whose inner mode size is an eighth of mode's. ;; We
[gcc r15-2764] RISC-V: Fix typos in code
https://gcc.gnu.org/g:6b8e46d93a76055087071204fe5ae1dfbf5ef613 commit r15-2764-g6b8e46d93a76055087071204fe5ae1dfbf5ef613 Author: Patrick O'Neill Date: Mon Aug 5 14:19:58 2024 -0700 RISC-V: Fix typos in code This fixes typos in function names and executed code. gcc/ChangeLog: * config/riscv/riscv-target-attr.cc (num_occurences_in_str): Rename... (num_occurrences_in_str): here. (riscv_process_target_attr): Update num_occurences_in_str callsite. * config/riscv/riscv-v.cc (emit_vec_widden_cvt_x_f): widden -> widen. (emit_vec_widen_cvt_x_f): Ditto. (emit_vec_widden_cvt_f_f): Ditto. (emit_vec_widen_cvt_f_f): Ditto. (emit_vec_rounding_to_integer): Update *widden* callsites. * config/riscv/riscv-vector-builtins.cc (expand_builtin): Update required_ext_to_isa_name callsite and fix xtheadvector typo. * config/riscv/riscv-vector-builtins.h (reqired_ext_to_isa_name): Rename... (required_ext_to_isa_name): here. * config/riscv/riscv_th_vector.h: Fix endif label. * config/riscv/vector-crypto.md: boardcast_scalar -> broadcast_scalar. * config/riscv/vector.md: Ditto. Signed-off-by: Patrick O'Neill Diff: --- gcc/config/riscv/riscv-target-attr.cc | 4 +- gcc/config/riscv/riscv-v.cc | 10 ++--- gcc/config/riscv/riscv-vector-builtins.cc | 2 +- gcc/config/riscv/riscv-vector-builtins.h | 4 +- gcc/config/riscv/riscv_th_vector.h| 2 +- gcc/config/riscv/vector-crypto.md | 8 ++-- gcc/config/riscv/vector.md| 74 +++ 7 files changed, 52 insertions(+), 52 deletions(-) diff --git a/gcc/config/riscv/riscv-target-attr.cc b/gcc/config/riscv/riscv-target-attr.cc index 1645a6692177..bf14ade5ce08 100644 --- a/gcc/config/riscv/riscv-target-attr.cc +++ b/gcc/config/riscv/riscv-target-attr.cc @@ -290,7 +290,7 @@ riscv_process_one_target_attr (char *arg_str, NULL-terminated string STR. */ static unsigned int -num_occurences_in_str (char c, char *str) +num_occurrences_in_str (char c, char *str) { unsigned int res = 0; while (*str != '\0') @@ -347,7 +347,7 @@ riscv_process_target_attr (tree args, location_t loc) /* Used to catch empty spaces between semi-colons i.e. attribute ((target ("attr1;;attr2"))). */ - unsigned int num_semicolons = num_occurences_in_str (';', str_to_check); + unsigned int num_semicolons = num_occurrences_in_str (';', str_to_check); /* Handle multiple target attributes separated by ';'. */ char *token = strtok_r (str_to_check, ";", &str_to_check); diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 577e8c8315cb..1370ac489fe4 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -4599,7 +4599,7 @@ emit_vec_narrow_cvt_x_f (rtx op_dest, rtx op_src, insn_type type, } static void -emit_vec_widden_cvt_x_f (rtx op_dest, rtx op_src, insn_type type, +emit_vec_widen_cvt_x_f (rtx op_dest, rtx op_src, insn_type type, machine_mode vec_mode) { rtx ops[] = {op_dest, op_src}; @@ -4609,7 +4609,7 @@ emit_vec_widden_cvt_x_f (rtx op_dest, rtx op_src, insn_type type, } static void -emit_vec_widden_cvt_f_f (rtx op_dest, rtx op_src, insn_type type, +emit_vec_widen_cvt_f_f (rtx op_dest, rtx op_src, insn_type type, machine_mode vec_mode) { rtx ops[] = {op_dest, op_src}; @@ -4835,7 +4835,7 @@ emit_vec_rounding_to_integer (rtx op_0, rtx op_1, insn_type type, else if (maybe_eq (vec_fp_size, vec_int_size * 2)) /* DF => SI. */ emit_vec_narrow_cvt_x_f (op_0, op_1, type, vec_fp_mode); else if (maybe_eq (vec_fp_size * 2, vec_int_size)) /* SF => DI, HF => SI. */ -emit_vec_widden_cvt_x_f (op_0, op_1, type, vec_int_mode); +emit_vec_widen_cvt_x_f (op_0, op_1, type, vec_int_mode); else if (maybe_eq (vec_fp_size * 4, vec_int_size)) /* HF => DI. */ { gcc_assert (vec_bridge_mode != E_VOIDmode); @@ -4843,9 +4843,9 @@ emit_vec_rounding_to_integer (rtx op_0, rtx op_1, insn_type type, rtx op_sf = gen_reg_rtx (vec_bridge_mode); /* Step-1: HF => SF, no rounding here. */ - emit_vec_widden_cvt_f_f (op_sf, op_1, UNARY_OP, vec_bridge_mode); + emit_vec_widen_cvt_f_f (op_sf, op_1, UNARY_OP, vec_bridge_mode); /* Step-2: SF => DI. */ - emit_vec_widden_cvt_x_f (op_0, op_sf, type, vec_int_mode); + emit_vec_widen_cvt_x_f (op_0, op_sf, type, vec_int_mode); } else gcc_unreachable (); diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc index 7d8a289c80b5..49a1cb1708fe 100644 --- a/gcc/config/riscv/riscv-vector-builtins.cc +++ b/gcc/config/riscv/riscv-vector-builtins.cc @@ -4765,7 +4765,7 @@ expand_builtin (unsigned int code, tree exp, rtx target) error_at (EXPR_LOCATION (ex
[gcc r15-2765] hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization
https://gcc.gnu.org/g:dc01f249db5c4d08b76dc2783b1539290a800f2d commit r15-2765-gdc01f249db5c4d08b76dc2783b1539290a800f2d Author: John David Anglin Date: Tue Aug 6 13:40:26 2024 -0400 hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization The constant C must be an integral multiple of the shift value in the above optimization. Non integral values can occur evaluating IMAGPART_EXPR when the shadd constant is 8 and we have SFmode. 2024-08-06 John David Anglin gcc/ChangeLog: PR target/113384 * config/pa/pa.cc (hppa_legitimize_address): Add check to ensure constant is an integral multiple of shift the value. Diff: --- gcc/config/pa/pa.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index ab4bfc5d0c26..911b7d96e9b6 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -1410,6 +1410,7 @@ hppa_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, /* If the index adds a large constant, try to scale the constant so that it can be loaded with only one insn. */ if (GET_CODE (XEXP (idx, 1)) == CONST_INT + && INTVAL (XEXP (idx, 1)) % (1 << shift_val) == 0 && VAL_14_BITS_P (INTVAL (XEXP (idx, 1)) / INTVAL (XEXP (XEXP (idx, 0), 1))) && INTVAL (XEXP (idx, 1)) % INTVAL (XEXP (XEXP (idx, 0), 1)) == 0)
[gcc r14-10568] hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization
https://gcc.gnu.org/g:ba26c471cf6ee760e53836fd4e9bc00250b8b882 commit r14-10568-gba26c471cf6ee760e53836fd4e9bc00250b8b882 Author: John David Anglin Date: Tue Aug 6 13:40:26 2024 -0400 hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization The constant C must be an integral multiple of the shift value in the above optimization. Non integral values can occur evaluating IMAGPART_EXPR when the shadd constant is 8 and we have SFmode. 2024-08-06 John David Anglin gcc/ChangeLog: PR target/113384 * config/pa/pa.cc (hppa_legitimize_address): Add check to ensure constant is an integral multiple of shift the value. Diff: --- gcc/config/pa/pa.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index a7af6b8c121f..b24434628fa5 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -1407,6 +1407,7 @@ hppa_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, /* If the index adds a large constant, try to scale the constant so that it can be loaded with only one insn. */ if (GET_CODE (XEXP (idx, 1)) == CONST_INT + && INTVAL (XEXP (idx, 1)) % (1 << shift_val) == 0 && VAL_14_BITS_P (INTVAL (XEXP (idx, 1)) / INTVAL (XEXP (XEXP (idx, 0), 1))) && INTVAL (XEXP (idx, 1)) % INTVAL (XEXP (XEXP (idx, 0), 1)) == 0)
[gcc r13-8963] hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization
https://gcc.gnu.org/g:f6624adc535a165ab667646c57b73e213d868cca commit r13-8963-gf6624adc535a165ab667646c57b73e213d868cca Author: John David Anglin Date: Tue Aug 6 13:40:26 2024 -0400 hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization The constant C must be an integral multiple of the shift value in the above optimization. Non integral values can occur evaluating IMAGPART_EXPR when the shadd constant is 8 and we have SFmode. 2024-08-06 John David Anglin gcc/ChangeLog: PR target/113384 * config/pa/pa.cc (hppa_legitimize_address): Add check to ensure constant is an integral multiple of shift the value. Diff: --- gcc/config/pa/pa.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index 3e2ae9fa677f..8ed376a9f49a 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -1263,6 +1263,7 @@ hppa_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, /* If the index adds a large constant, try to scale the constant so that it can be loaded with only one insn. */ if (GET_CODE (XEXP (idx, 1)) == CONST_INT + && INTVAL (XEXP (idx, 1)) % (1 << shift_val) == 0 && VAL_14_BITS_P (INTVAL (XEXP (idx, 1)) / INTVAL (XEXP (XEXP (idx, 0), 1))) && INTVAL (XEXP (idx, 1)) % INTVAL (XEXP (XEXP (idx, 0), 1)) == 0)
[gcc r12-10661] hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization
https://gcc.gnu.org/g:960e42bba8d276ea31cb0b37acfa8f3739d55f1d commit r12-10661-g960e42bba8d276ea31cb0b37acfa8f3739d55f1d Author: John David Anglin Date: Tue Aug 6 13:40:26 2024 -0400 hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization The constant C must be an integral multiple of the shift value in the above optimization. Non integral values can occur evaluating IMAGPART_EXPR when the shadd constant is 8 and we have SFmode. 2024-08-06 John David Anglin gcc/ChangeLog: PR target/113384 * config/pa/pa.cc (hppa_legitimize_address): Add check to ensure constant is an integral multiple of shift the value. Diff: --- gcc/config/pa/pa.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index ec81f403a011..bd4dcc4e2b36 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -1263,6 +1263,7 @@ hppa_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, /* If the index adds a large constant, try to scale the constant so that it can be loaded with only one insn. */ if (GET_CODE (XEXP (idx, 1)) == CONST_INT + && INTVAL (XEXP (idx, 1)) % (1 << shift_val) == 0 && VAL_14_BITS_P (INTVAL (XEXP (idx, 1)) / INTVAL (XEXP (XEXP (idx, 0), 1))) && INTVAL (XEXP (idx, 1)) % INTVAL (XEXP (XEXP (idx, 0), 1)) == 0)
[gcc r15-2766] Remove MMX code path in lexer
https://gcc.gnu.org/g:eac63be1d4a0d64f918163f113ec1b339e917a0e commit r15-2766-geac63be1d4a0d64f918163f113ec1b339e917a0e Author: Andi Kleen Date: Mon Jul 29 18:48:08 2024 -0700 Remove MMX code path in lexer Host systems with only MMX and no SSE2 should be really rare now. Let's remove the MMX code path to keep the number of custom implementations the same. The SSE2 code path is also somewhat dubious now (nearly everything should have SSE4 4.2 which is >15 years old now), but the SSE2 code path is used as fallback for others and also apparently Solaris uses it due to tool chain deficiencies. libcpp/ChangeLog: * lex.cc (search_line_mmx): Remove function. (init_vectorized_lexer): Remove search_line_mmx. Diff: --- libcpp/lex.cc | 75 --- 1 file changed, 75 deletions(-) diff --git a/libcpp/lex.cc b/libcpp/lex.cc index 16f2c23af1e1..1591dcdf151a 100644 --- a/libcpp/lex.cc +++ b/libcpp/lex.cc @@ -290,71 +290,6 @@ static const char repl_chars[4][16] __attribute__((aligned(16))) = { '?', '?', '?', '?', '?', '?', '?', '?' }, }; -/* A version of the fast scanner using MMX vectorized byte compare insns. - - This uses the PMOVMSKB instruction which was introduced with "MMX2", - which was packaged into SSE1; it is also present in the AMD MMX - extension. Mark the function as using "sse" so that we emit a real - "emms" instruction, rather than the 3dNOW "femms" instruction. */ - -static const uchar * -#ifndef __SSE__ -__attribute__((__target__("sse"))) -#endif -search_line_mmx (const uchar *s, const uchar *end ATTRIBUTE_UNUSED) -{ - typedef char v8qi __attribute__ ((__vector_size__ (8))); - typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__)); - - const v8qi repl_nl = *(const v8qi *)repl_chars[0]; - const v8qi repl_cr = *(const v8qi *)repl_chars[1]; - const v8qi repl_bs = *(const v8qi *)repl_chars[2]; - const v8qi repl_qm = *(const v8qi *)repl_chars[3]; - - unsigned int misalign, found, mask; - const v8qi *p; - v8qi data, t, c; - - /* Align the source pointer. While MMX doesn't generate unaligned data - faults, this allows us to safely scan to the end of the buffer without - reading beyond the end of the last page. */ - misalign = (uintptr_t)s & 7; - p = (const v8qi *)((uintptr_t)s & -8); - data = *p; - - /* Create a mask for the bytes that are valid within the first - 16-byte block. The Idea here is that the AND with the mask - within the loop is "free", since we need some AND or TEST - insn in order to set the flags for the branch anyway. */ - mask = -1u << misalign; - - /* Main loop processing 8 bytes at a time. */ - goto start; - do -{ - data = *++p; - mask = -1; - -start: - t = __builtin_ia32_pcmpeqb(data, repl_nl); - c = __builtin_ia32_pcmpeqb(data, repl_cr); - t = (v8qi) __builtin_ia32_por ((__m64)t, (__m64)c); - c = __builtin_ia32_pcmpeqb(data, repl_bs); - t = (v8qi) __builtin_ia32_por ((__m64)t, (__m64)c); - c = __builtin_ia32_pcmpeqb(data, repl_qm); - t = (v8qi) __builtin_ia32_por ((__m64)t, (__m64)c); - found = __builtin_ia32_pmovmskb (t); - found &= mask; -} - while (!found); - - __builtin_ia32_emms (); - - /* FOUND contains 1 in bits for which we matched a relevant - character. Conversion to the byte index is trivial. */ - found = __builtin_ctz(found); - return (const uchar *)p + found; -} /* A version of the fast scanner using SSE2 vectorized byte compare insns. */ @@ -509,8 +444,6 @@ init_vectorized_lexer (void) minimum = 3; #elif defined(__SSE2__) minimum = 2; -#elif defined(__SSE__) - minimum = 1; #endif if (minimum == 3) @@ -521,14 +454,6 @@ init_vectorized_lexer (void) impl = search_line_sse42; else if (minimum == 2 || (edx & bit_SSE2)) impl = search_line_sse2; - else if (minimum == 1 || (edx & bit_SSE)) - impl = search_line_mmx; -} - else if (__get_cpuid (0x8001, &dummy, &dummy, &dummy, &edx)) -{ - if (minimum == 1 - || (edx & (bit_MMXEXT | bit_CMOV)) == (bit_MMXEXT | bit_CMOV)) - impl = search_line_mmx; } search_line_fast = impl;
[gcc r15-2767] doc: Rephrase GM2 Limitations section
https://gcc.gnu.org/g:77d232522d3eb7a6541fc91c3092c115cc535275 commit r15-2767-g77d232522d3eb7a6541fc91c3092c115cc535275 Author: Gerald Pfeifer Date: Tue Aug 6 22:38:41 2024 +0200 doc: Rephrase GM2 Limitations section gcc: * doc/gm2.texi (Limitations): Rephrase. Remove invalid link. Diff: --- gcc/doc/gm2.texi | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi index 5bff9eb3829d..bfc8dc71f235 100644 --- a/gcc/doc/gm2.texi +++ b/gcc/doc/gm2.texi @@ -2970,10 +2970,9 @@ $ @samp{directory to the sources}/contrib/test_summary @node Limitations, Objectives, Regression tests, Using @section Limitations -Logitech compatibility library is incomplete. The principle modules -for this platform exist however for a comprehensive list of completed -modules please check the documentation -@url{gm2.html}. +The Logitech compatibility library is incomplete. The primary +modules for this platform exist, though for a comprehensive list +of completed modules please check the documentation. @node Objectives, FAQ, Limitations, Using @section Objectives
[gcc r15-2768] AArch64: take gather/scatter decode overhead into account
https://gcc.gnu.org/g:a50916a6c0a6c73c1537d033509d4f7034341f75 commit r15-2768-ga50916a6c0a6c73c1537d033509d4f7034341f75 Author: Tamar Christina Date: Tue Aug 6 22:41:10 2024 +0100 AArch64: take gather/scatter decode overhead into account Gather and scatters are not usually beneficial when the loop count is small. This is because there's not only a cost to their execution within the loop but there is also some cost to enter loops with them. As such this patch models this overhead. For generic tuning we however still prefer gathers/scatters when the loop costs work out. gcc/ChangeLog: * config/aarch64/aarch64-protos.h (struct sve_vec_cost): Add gather_load_x32_init_cost and gather_load_x64_init_cost. * config/aarch64/aarch64.cc (aarch64_vector_costs): Add m_sve_gather_scatter_init_cost. (aarch64_vector_costs::add_stmt_cost): Use them. (aarch64_vector_costs::finish_cost): Likewise. * config/aarch64/tuning_models/a64fx.h: Update. * config/aarch64/tuning_models/cortexx925.h: Update. * config/aarch64/tuning_models/generic.h: Update. * config/aarch64/tuning_models/generic_armv8_a.h: Update. * config/aarch64/tuning_models/generic_armv9_a.h: Update. * config/aarch64/tuning_models/neoverse512tvb.h: Update. * config/aarch64/tuning_models/neoversen2.h: Update. * config/aarch64/tuning_models/neoversen3.h: Update. * config/aarch64/tuning_models/neoversev1.h: Update. * config/aarch64/tuning_models/neoversev2.h: Update. * config/aarch64/tuning_models/neoversev3.h: Update. * config/aarch64/tuning_models/neoversev3ae.h: Update. Diff: --- gcc/config/aarch64/aarch64-protos.h| 10 + gcc/config/aarch64/aarch64.cc | 26 ++ gcc/config/aarch64/tuning_models/a64fx.h | 2 ++ gcc/config/aarch64/tuning_models/cortexx925.h | 2 ++ gcc/config/aarch64/tuning_models/generic.h | 2 ++ gcc/config/aarch64/tuning_models/generic_armv8_a.h | 2 ++ gcc/config/aarch64/tuning_models/generic_armv9_a.h | 2 ++ gcc/config/aarch64/tuning_models/neoverse512tvb.h | 2 ++ gcc/config/aarch64/tuning_models/neoversen2.h | 2 ++ gcc/config/aarch64/tuning_models/neoversen3.h | 2 ++ gcc/config/aarch64/tuning_models/neoversev1.h | 2 ++ gcc/config/aarch64/tuning_models/neoversev2.h | 2 ++ gcc/config/aarch64/tuning_models/neoversev3.h | 2 ++ gcc/config/aarch64/tuning_models/neoversev3ae.h| 2 ++ 14 files changed, 60 insertions(+) diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index f64afe288901..44b881b5c57a 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -262,6 +262,8 @@ struct sve_vec_cost : simd_vec_cost unsigned int fadda_f64_cost, unsigned int gather_load_x32_cost, unsigned int gather_load_x64_cost, + unsigned int gather_load_x32_init_cost, + unsigned int gather_load_x64_init_cost, unsigned int scatter_store_elt_cost) : simd_vec_cost (base), clast_cost (clast_cost), @@ -270,6 +272,8 @@ struct sve_vec_cost : simd_vec_cost fadda_f64_cost (fadda_f64_cost), gather_load_x32_cost (gather_load_x32_cost), gather_load_x64_cost (gather_load_x64_cost), + gather_load_x32_init_cost (gather_load_x32_init_cost), + gather_load_x64_init_cost (gather_load_x64_init_cost), scatter_store_elt_cost (scatter_store_elt_cost) {} @@ -289,6 +293,12 @@ struct sve_vec_cost : simd_vec_cost const int gather_load_x32_cost; const int gather_load_x64_cost; + /* Additional loop initialization cost of using a gather load instruction. The x32 + value is for loads of 32-bit elements and the x64 value is for loads of + 64-bit elements. */ + const int gather_load_x32_init_cost; + const int gather_load_x64_init_cost; + /* The per-element cost of a scatter store. */ const int scatter_store_elt_cost; }; diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 9e12bd9711cd..2ac5a22c848e 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -16231,6 +16231,10 @@ private: supported by Advanced SIMD and SVE2. */ bool m_has_avg = false; + /* Additional initialization costs for using gather or scatter operation in + the current loop. */ + unsigned int m_sve_gather_scatter_init_cost = 0; + /* True if the vector body contains a store to a decl and if the function is known to have a vld1 from the same decl. @@ -17295,6 +17299,23 @@ aarch64_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
[gcc r14-10569] c++: parse error with -std=c++14 -fconcepts [PR116071]
https://gcc.gnu.org/g:987fc8174026cb3452b63d026cef686f4177526b commit r14-10569-g987fc8174026cb3452b63d026cef686f4177526b Author: Jason Merrill Date: Wed Jul 24 16:20:33 2024 -0400 c++: parse error with -std=c++14 -fconcepts [PR116071] cp_parser_simple_type_specifier tries a variety of different things that might qualify as a user-defined type: an actual type-name, a constrained auto, a CTAD placeholder. In a context where a type-specifier is optional, this is all tentative. With -std=c++14 -fconcepts, we try type-name and constrained auto in sub-tentative parses, and when we run out of things to try we haven't found anything but also haven't failed the outer tentative parse, so parse_definitely succeeds, discarding the nested-name-specifier. Fixed by failing if we didn't find anything. I said in r14-3203 that we should disable this combination of flags if further problems arise, but this seems like a more general problem that only happened to occur with just this combination of flags. So it lives on. PR c++/116071 gcc/cp/ChangeLog: * parser.cc (cp_parser_simple_type_specifier): Call cp_parser_simulate_error if nothing worked. gcc/testsuite/ChangeLog: * g++.dg/parse/pr116071.C: New test. (cherry picked from commit 8c71830b51e6fd10087ce3f6791de80eb1f10b96) Diff: --- gcc/cp/parser.cc | 10 +++--- gcc/testsuite/g++.dg/parse/pr116071.C | 18 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 00cf128522a7..adb102287827 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -20625,9 +20625,13 @@ cp_parser_simple_type_specifier (cp_parser* parser, } /* If it didn't work out, we don't have a TYPE. */ - if ((flags & CP_PARSER_FLAGS_OPTIONAL) - && !cp_parser_parse_definitely (parser)) - type = NULL_TREE; + if (flags & CP_PARSER_FLAGS_OPTIONAL) + { + if (!type) + cp_parser_simulate_error (parser); + if (!cp_parser_parse_definitely (parser)) + type = NULL_TREE; + } /* Keep track of all name-lookups performed in class scopes. */ if (type diff --git a/gcc/testsuite/g++.dg/parse/pr116071.C b/gcc/testsuite/g++.dg/parse/pr116071.C new file mode 100644 index ..7590782d5ee8 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr116071.C @@ -0,0 +1,18 @@ +// PR c++/116071 +// { dg-options "-std=c++14 -fconcepts" } + +template struct S { ~S(); }; +template S::~S() { } + +template +struct result_of; + +template +struct result_of +{ + using type = void; +}; + +struct thread { + void join() { }; +};
[gcc r14-10570] c++: alias and non-type template parm [PR116223]
https://gcc.gnu.org/g:b1102f7c478136bfe18ceaf7db9572a8a757a3d2 commit r14-10570-gb1102f7c478136bfe18ceaf7db9572a8a757a3d2 Author: Jason Merrill Date: Mon Aug 5 11:21:05 2024 -0400 c++: alias and non-type template parm [PR116223] My r14-8291 for PR112632 introduced IMPLICIT_CONV_EXPR_FORCED to express conversions to the type of an alias template parameter. In this example, that broke deduction of X in the call to foo, so let's teach deduction to look through it. PR c++/116223 PR c++/112632 gcc/cp/ChangeLog: * pt.cc (deducible_expression): Also look through IMPLICIT_CONV_EXPR_FORCED. (unify): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/nontype-auto25.C: New test. (cherry picked from commit 4add6cd341a779e980e41ed6fb49175fca37496e) Diff: --- gcc/cp/pt.cc| 6 +- gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C | 18 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ea4a6c9bf530..96a4f45909dd 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23073,6 +23073,8 @@ deducible_expression (tree expr) /* Strip implicit conversions and implicit INDIRECT_REFs. */ while (CONVERT_EXPR_P (expr) || TREE_CODE (expr) == VIEW_CONVERT_EXPR +|| (TREE_CODE (expr) == IMPLICIT_CONV_EXPR +&& IMPLICIT_CONV_EXPR_FORCED (expr)) || REFERENCE_REF_P (expr)) expr = TREE_OPERAND (expr, 0); return (TREE_CODE (expr) == TEMPLATE_PARM_INDEX); @@ -24602,7 +24604,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, signedness is the only information lost, and I think that will be okay. VIEW_CONVERT_EXPR can appear with class NTTP, thanks to finish_id_expression_1, and are also OK. */ - while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR) + while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR +|| (TREE_CODE (parm) == IMPLICIT_CONV_EXPR +&& IMPLICIT_CONV_EXPR_FORCED (parm))) parm = TREE_OPERAND (parm, 0); if (arg == error_mark_node) diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C new file mode 100644 index ..36b38b48ec2d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto25.C @@ -0,0 +1,18 @@ +// PR c++/116223 +// { dg-do compile { target c++17 } } + +template struct A { int value = T; }; + +template using B = A; + +template +void foo(B& mat) noexcept +{ + //std::cout << mat.value << "\n"; +} + +int main() +{ +A<2> mat; +foo(mat); +}
[gcc r15-2769] diagnostics: SARIF output: fix "executionSuccessful" §3.20.14 [PR116177]
https://gcc.gnu.org/g:77f36e8016e11c051aa8264f3c43ab2c27aece55 commit r15-2769-g77f36e8016e11c051aa8264f3c43ab2c27aece55 Author: David Malcolm Date: Tue Aug 6 18:24:45 2024 -0400 diagnostics: SARIF output: fix "executionSuccessful" §3.20.14 [PR116177] Previously the invocation's "executionSuccessful" property (§3.20.14) was only false if there was an ICE. Update it so that it will also be false if we will exit with a non-zero exit code (due to errors, Werror, and "sorry"). gcc/ChangeLog: PR other/116177 * diagnostic-format-sarif.cc (sarif_invocation::prepare_to_flush): If the diagnostics would lead to us exiting with a failure code, then emit "executionSuccessful": False (SARIF v2.1.0 section §3.20.14). * diagnostic.cc (diagnostic_context::execution_failed_p): New. * diagnostic.h (diagnostic_context::execution_failed_p): New decl. * toplev.cc (toplev::main): Use it for determining returned value. gcc/testsuite/ChangeLog: PR other/116177 * gcc.dg/sarif-output/include-chain-2.c: Remove pruning of "exit status is 1", as we expect this to exit with 0. * gcc.dg/sarif-output/no-diagnostics.c: New test. * gcc.dg/sarif-output/test-include-chain-1.py (test_execution_unsuccessful): Add. * gcc.dg/sarif-output/test-include-chain-2.py (test_execution_successful): Add. * gcc.dg/sarif-output/test-missing-semicolon.py (test_execution_unsuccessful): Add. * gcc.dg/sarif-output/test-no-diagnostics.py: New test. * gcc.dg/sarif-output/test-werror.py: New test. * gcc.dg/sarif-output/werror.c: New test. Signed-off-by: David Malcolm Diff: --- gcc/diagnostic-format-sarif.cc | 2 ++ gcc/diagnostic.cc | 13 gcc/diagnostic.h | 2 ++ .../gcc.dg/sarif-output/include-chain-2.c | 5 --- gcc/testsuite/gcc.dg/sarif-output/no-diagnostics.c | 13 .../gcc.dg/sarif-output/test-include-chain-1.py| 11 ++ .../gcc.dg/sarif-output/test-include-chain-2.py| 11 ++ .../gcc.dg/sarif-output/test-missing-semicolon.py | 11 ++ .../gcc.dg/sarif-output/test-no-diagnostics.py | 31 + gcc/testsuite/gcc.dg/sarif-output/test-werror.py | 39 ++ gcc/testsuite/gcc.dg/sarif-output/werror.c | 18 ++ gcc/toplev.cc | 2 +- 12 files changed, 152 insertions(+), 6 deletions(-) diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index 7c2e96f4f746..963a185f6ced 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -811,6 +811,8 @@ void sarif_invocation::prepare_to_flush (diagnostic_context &context) { /* "executionSuccessful" property (SARIF v2.1.0 section 3.20.14). */ + if (context.execution_failed_p ()) +m_success = false; set_bool ("executionSuccessful", m_success); /* "toolExecutionNotifications" property (SARIF v2.1.0 section 3.20.21). */ diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 71d2f44e40c8..3fc81ad47f56 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -399,6 +399,19 @@ diagnostic_context::finish () m_original_argv = nullptr; } +/* Return true if sufficiently severe diagnostics have been seen that + we ought to exit with a non-zero exit code. */ + +bool +diagnostic_context::execution_failed_p () const +{ + /* Equivalent to (seen_error () || werrorcount), but on + this context, rather than global_dc. */ + return (m_diagnostic_count [DK_ERROR] + || m_diagnostic_count [DK_SORRY] + || m_diagnostic_count [DK_WERROR]); +} + void diagnostic_context::set_output_format (diagnostic_output_format *output_format) { diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 79386ccbf856..83180ded414d 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -392,6 +392,8 @@ public: void finish (); + bool execution_failed_p () const; + void set_original_argv (unique_argv original_argv); const char * const *get_original_argv () { diff --git a/gcc/testsuite/gcc.dg/sarif-output/include-chain-2.c b/gcc/testsuite/gcc.dg/sarif-output/include-chain-2.c index 3f984f48979b..a04b647d259e 100644 --- a/gcc/testsuite/gcc.dg/sarif-output/include-chain-2.c +++ b/gcc/testsuite/gcc.dg/sarif-output/include-chain-2.c @@ -27,11 +27,6 @@ PATH/include-chain-2.h:6:3: warning: double-'free' of 'ptr' [CWE-415] [-Wanalyze #include "include-chain-2.h" -/* We expect a failing compile due to the errors, but the use of - -fdiagnostics-format=sarif-file means there should be no output to stderr. - DejaGnu injects this message; ignore it: - { dg-prune-output "exit status is 1" } */ - /* Verify that some JSON wa
[gcc r15-2770] libstdc++: Fix some undeclared uses of uintptr_t [PR116247]
https://gcc.gnu.org/g:3290826c190157cfa6ac1c12cce39ff746e5983a commit r15-2770-g3290826c190157cfa6ac1c12cce39ff746e5983a Author: Jonathan Wakely Date: Tue Aug 6 21:26:24 2024 +0100 libstdc++: Fix some undeclared uses of uintptr_t [PR116247] libstdc++-v3/ChangeLog: PR libstdc++/116247 * include/bits/fs_path.h: Use __UINTPTR_TYPE__ instead of uintptr_t. * include/bits/shared_ptr_atomic.h: Likewise. * include/ext/pointer.h: Include . Diff: --- libstdc++-v3/include/bits/fs_path.h | 2 +- libstdc++-v3/include/bits/shared_ptr_atomic.h | 1 + libstdc++-v3/include/ext/pointer.h| 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index a42f4bf92525..62af6d98bb7d 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -689,7 +689,7 @@ namespace __detail ~_List() = default; _Type type() const noexcept - { return _Type(reinterpret_cast(_M_impl.get()) & 0x3); } + { return _Type(reinterpret_cast<__UINTPTR_TYPE__>(_M_impl.get()) & 0x3); } void type(_Type) noexcept; diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h b/libstdc++-v3/include/bits/shared_ptr_atomic.h index 1403c6a17c5f..1e314b044bcd 100644 --- a/libstdc++-v3/include/bits/shared_ptr_atomic.h +++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h @@ -401,6 +401,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // Either __shared_count<> or __weak_count<> using __count_type = decltype(_Tp::_M_refcount); + using uintptr_t = __UINTPTR_TYPE__; // _Sp_counted_base<>* using pointer = decltype(__count_type::_M_pi); diff --git a/libstdc++-v3/include/ext/pointer.h b/libstdc++-v3/include/ext/pointer.h index 534b3c78226e..0ead6f53d5f5 100644 --- a/libstdc++-v3/include/ext/pointer.h +++ b/libstdc++-v3/include/ext/pointer.h @@ -42,6 +42,7 @@ # include #endif +#include // uintptr_t #include #include #include
[gcc r15-2771] aarch64/testsuite: Fix gcc.target/aarch64/simd/vmmla.c [PR116207]
https://gcc.gnu.org/g:d4b35dab72b161f699aede157d90446973a71c99 commit r15-2771-gd4b35dab72b161f699aede157d90446973a71c99 Author: Andrew Pinski Date: Tue Aug 6 15:43:21 2024 -0700 aarch64/testsuite: Fix gcc.target/aarch64/simd/vmmla.c [PR116207] After r15-2414-g2d105efd6f60 which fixed the dg-do directive, the testcase stopped working because there was a missing -save-temps. This adds that and now the testcase passes again. Pushed as obvious. gcc/testsuite/ChangeLog: PR testsuite/116207 * gcc.target/aarch64/simd/vmmla.c: Add -save-temps to the options. Signed-off-by: Andrew Pinski Diff: --- gcc/testsuite/gcc.target/aarch64/simd/vmmla.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/aarch64/simd/vmmla.c b/gcc/testsuite/gcc.target/aarch64/simd/vmmla.c index 777decc56a20..3a599ddb58a4 100644 --- a/gcc/testsuite/gcc.target/aarch64/simd/vmmla.c +++ b/gcc/testsuite/gcc.target/aarch64/simd/vmmla.c @@ -1,6 +1,6 @@ /* { dg-do assemble } */ /* { dg-require-effective-target arm_v8_2a_i8mm_ok } */ -/* { dg-additional-options "-march=armv8.2-a+i8mm" } */ +/* { dg-additional-options "-march=armv8.2-a+i8mm -save-temps" } */ #include "arm_neon.h"
[gcc r15-2772] Fortran: Eliminate error prone translations.
https://gcc.gnu.org/g:45fdf838a21e151c2c676c4fcd056032e59f commit r15-2772-g45fdf838a21e151c2c676c4fcd056032e59f Author: Jerry DeLisle Date: Tue Aug 6 16:10:23 2024 -0700 Fortran: Eliminate error prone translations. PR fortran/109105 gcc/fortran/ChangeLog: * resolve.cc (CHECK_INTERFACES): New helper macro. (resolve_operator): Replace use of snprintf with gfc_error. Diff: --- gcc/fortran/resolve.cc | 176 - 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 503029364c14..eb3085a05ca2 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -4137,15 +4137,23 @@ convert_to_numeric (gfc_expr *a, gfc_expr *b) } /* Resolve an operator expression node. This can involve replacing the - operation with a user defined function call. */ + operation with a user defined function call. CHECK_INTERFACES is a + helper macro. */ + +#define CHECK_INTERFACES \ + { \ +match m = gfc_extend_expr (e); \ +if (m == MATCH_YES) \ + return true; \ +if (m == MATCH_ERROR) \ + return false; \ + } static bool resolve_operator (gfc_expr *e) { gfc_expr *op1, *op2; /* One error uses 3 names; additional space for wording (also via gettext). */ - char msg[3*GFC_MAX_SYMBOL_LEN + 1 + 50]; - bool dual_locus_error; bool t = true; /* Reduce stacked parentheses to single pair */ @@ -4195,8 +4203,6 @@ resolve_operator (gfc_expr *e) if (t == false) return false; - dual_locus_error = false; - /* op1 and op2 cannot both be BOZ. */ if (op1 && op1->ts.type == BT_BOZ && op2 && op2->ts.type == BT_BOZ) @@ -4210,9 +4216,9 @@ resolve_operator (gfc_expr *e) if ((op1 && op1->expr_type == EXPR_NULL) || (op2 && op2->expr_type == EXPR_NULL)) { - snprintf (msg, sizeof (msg), - _("Invalid context for NULL() pointer at %%L")); - goto bad_op; + CHECK_INTERFACES + gfc_error ("Invalid context for NULL() pointer at %L", &e->where); + return false; } switch (e->value.op.op) @@ -4227,10 +4233,10 @@ resolve_operator (gfc_expr *e) break; } - snprintf (msg, sizeof (msg), - _("Operand of unary numeric operator %%<%s%%> at %%L is %s"), - gfc_op2string (e->value.op.op), gfc_typename (e)); - goto bad_op; + CHECK_INTERFACES + gfc_error ("Operand of unary numeric operator %<%s%> at %L is %s", +gfc_op2string (e->value.op.op), &e->where, gfc_typename (e)); + return false; case INTRINSIC_PLUS: case INTRINSIC_MINUS: @@ -4244,10 +4250,10 @@ resolve_operator (gfc_expr *e) Defer to a possibly overloading user-defined operator. */ if (!gfc_op_rank_conformable (op1, op2)) { - dual_locus_error = true; - snprintf (msg, sizeof (msg), - _("Inconsistent ranks for operator at %%L and %%L")); - goto bad_op; + CHECK_INTERFACES + gfc_error ("Inconsistent ranks for operator at %L and %L", +&op1->where, &op2->where); + return false; } gfc_type_convert_binary (e, 1); @@ -4255,16 +4261,21 @@ resolve_operator (gfc_expr *e) } if (op1->ts.type == BT_DERIVED || op2->ts.type == BT_DERIVED) - snprintf (msg, sizeof (msg), - _("Unexpected derived-type entities in binary intrinsic " - "numeric operator %%<%s%%> at %%L"), - gfc_op2string (e->value.op.op)); + { + CHECK_INTERFACES + gfc_error ("Unexpected derived-type entities in binary intrinsic " +"numeric operator %<%s%> at %L", +gfc_op2string (e->value.op.op), &e->where); + return false; + } else - snprintf (msg, sizeof(msg), - _("Operands of binary numeric operator %%<%s%%> at %%L are %s/%s"), - gfc_op2string (e->value.op.op), gfc_typename (op1), - gfc_typename (op2)); - goto bad_op; + { + CHECK_INTERFACES + gfc_error ("Operands of binary numeric operator %<%s%> at %L are %s/%s", +gfc_op2string (e->value.op.op), &e->where, gfc_typename (op1), +gfc_typename (op2)); + return false; + } case INTRINSIC_CONCAT: if (op1->ts.type == BT_CHARACTER && op2->ts.type == BT_CHARACTER @@ -4275,10 +4286,10 @@ resolve_operator (gfc_expr *e) break; } - snprintf (msg, sizeof (msg), - _("Operands of string concatenation operator at %%L are %s/%s"), - gfc_typename (op1), gfc_typename (op2)); - goto bad_op; + CHECK_INTERFACES + gfc_error ("Operands of string concatenation operator at %L are %s
[gcc r15-2774] c++: permit errors inside uninstantiated templates [PR116064]
https://gcc.gnu.org/g:596d1ed9d40b1081fcc6c6161a0135952829b88f commit r15-2774-g596d1ed9d40b1081fcc6c6161a0135952829b88f Author: Patrick Palka Date: Tue Aug 6 20:54:03 2024 -0400 c++: permit errors inside uninstantiated templates [PR116064] In recent versions of GCC we've been diagnosing more and more kinds of errors inside a template ahead of time. This is a largely good thing because it catches bugs, typos, dead code etc sooner. But if the template never gets instantiated then such errors are harmless and can be inconvenient to work around if say the code in question is third party and in maintenance mode. So it'd be handy to be able to prevent these template errors from rendering the entire TU uncompilable. (Note that such code is "ill-formed no diagnostic required" according the standard.) To that end this patch turns any errors issued within a template into permerrors associated with a new -Wtemplate-body flag so that they can be downgraded via e.g. -fpermissive or -Wno-error=template-body. If the template containing a downgraded error later needs to be instantiated, we'll issue an error then. But if the template never gets instantiated then the downgraded error won't affect validity of the rest of the TU. This is implemented via a diagnostic hook that gets called for each diagnostic, and which adjusts an error diagnostic appropriately if we detect it's occurring from a template context, and additionally flags the template as erroneous. For example the new testcase permissive-error1a.C gives: gcc/testsuite/g++.dg/template/permissive-error1a.C: In function 'void f()': gcc/testsuite/g++.dg/template/permissive-error1a.C:7:5: warning: increment of read-only variable 'n' [-Wtemplate-body] 7 | ++n; | ^ ... gcc/testsuite/g++.dg/template/permissive-error1a.C: In instantiation of 'void f() [with T = int]': gcc/testsuite/g++.dg/template/permissive-error1a.C:26:9: required from here 26 | f(); | ~~^~ gcc/testsuite/g++.dg/template/permissive-error1a.C:5:6: error: instantiating erroneous template 5 | void f() { | ^ gcc/testsuite/g++.dg/template/permissive-error1a.C:7:5: note: first error appeared here 7 | ++n; // { | ^ ... PR c++/116064 gcc/c-family/ChangeLog: * c.opt (Wtemplate-body): New warning. gcc/cp/ChangeLog: * cp-tree.h (erroneous_templates_t): Declare. (erroneous_templates): Declare. (cp_seen_error): Declare. (seen_error): #define to cp_seen_error. * error.cc (get_current_template): Define. (relaxed_template_errors): Define. (cp_adjust_diagnostic_info): Define. (cp_seen_error): Define. (cxx_initialize_diagnostics): Set diagnostic_context::m_adjust_diagnostic_info. * module.cc (finish_module_processing): Don't write the module if it contains an erroneous template. * pt.cc (maybe_diagnose_erroneous_template): Define. (instantiate_class_template): Call it. (instantiate_decl): Likewise. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::initialize): Set m_adjust_diagnostic_info. (diagnostic_context::report_diagnostic): Call m_adjust_diagnostic_info. * diagnostic.h (diagnostic_context::m_adjust_diagnostic_info): New data member. * doc/invoke.texi (-Wno-template-body): Document. (-fpermissive): Mention -Wtemplate-body. gcc/testsuite/ChangeLog: * g++.dg/ext/typedef-init.C: Downgrade error inside template to warning due to -fpermissive. * g++.dg/pr84492.C: Likewise. * g++.old-deja/g++.pt/crash51.C: Remove unneeded dg-options. * g++.dg/template/permissive-error1.C: New test. * g++.dg/template/permissive-error1a.C: New test. * g++.dg/template/permissive-error1b.C: New test. * g++.dg/template/permissive-error1c.C: New test. Reviewed-by: Jason Merrill Diff: --- gcc/c-family/c.opt | 4 ++ gcc/cp/cp-tree.h | 7 +++ gcc/cp/error.cc| 67 ++ gcc/cp/module.cc | 5 +- gcc/cp/pt.cc | 22 +++ gcc/diagnostic.cc | 4 ++ gcc/diagnostic.h | 4 ++ gcc/doc/invoke.texi| 12 +++- gcc/testsuite/g++.dg/ext/typedef-init.C| 2 +- gcc/testsuite/g++.dg/pr84492.C | 4 +- gcc/testsuite/g++.dg/templa
[gcc r15-2775] RISC-V: Update .SAT_TRUNC dump check due to middle-end change
https://gcc.gnu.org/g:1b5c57e53e7ee4087e10f51fcf74968d950d3d83 commit r15-2775-g1b5c57e53e7ee4087e10f51fcf74968d950d3d83 Author: Pan Li Date: Mon Aug 5 16:01:11 2024 +0800 RISC-V: Update .SAT_TRUNC dump check due to middle-end change Due to recent middle-end change, update the .SAT_TRUNC expand dump check from 2 to 4. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c: Adjust asm check times from 2 to 4. Signed-off-by: Pan Li Signed-off-by: Pan Li Diff: --- gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c index 7f047f3f6a2b..ae3e44cd57e8 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c @@ -16,4 +16,4 @@ */ DEF_VEC_SAT_U_TRUNC_FMT_1 (uint8_t, uint16_t) -/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 4 "expand" } } */
[gcc r15-2776] Vect: Make sure the lhs type of .SAT_TRUNC has its mode precision [PR116202]
https://gcc.gnu.org/g:06d3f31384a89039c510531cf8012caed05b2ffd commit r15-2776-g06d3f31384a89039c510531cf8012caed05b2ffd Author: Pan Li Date: Tue Aug 6 20:59:37 2024 +0800 Vect: Make sure the lhs type of .SAT_TRUNC has its mode precision [PR116202] The .SAT_TRUNC vect pattern recog is valid when the lhs type has its mode precision. For example as below, QImode with 1 bit precision like _Bool is invalid here. g_12 = (long unsigned int) _2; _13 = MIN_EXPR ; _3 = (_Bool) _13; The above pattern cannot be recog as .SAT_TRUNC (g_12) because the dest only has 1 bit precision with QImode mode. Aka the type doesn't have the mode precision. The below tests are passed for this patch. 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. PR target/116202 gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_sat_trunc_pattern): Add the type_has_mode_precision_p check for the lhs type. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr116202-run-1.c: New test. Signed-off-by: Pan Li Diff: --- .../gcc.target/riscv/rvv/base/pr116202-run-1.c | 24 ++ gcc/tree-vect-patterns.cc | 5 +++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr116202-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr116202-run-1.c new file mode 100644 index ..d150f20b5d93 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr116202-run-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -march=rv64gcv_zvl256b -fdump-rtl-expand-details" } */ + +int b[24]; +_Bool c[24]; + +int main() { + for (int f = 0; f < 4; ++f) +b[f] = 6; + + for (int f = 0; f < 24; f += 4) +c[f] = ({ + int g = ({ +unsigned long g = -b[f]; +1 < g ? 1 : g; + }); + g; +}); + + if (c[0] != 1) +__builtin_abort (); +} + +/* { dg-final { scan-rtl-dump-not ".SAT_TRUNC " "expand" } } */ diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index b2c83cfd2190..87b3dc413b8b 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -4697,11 +4697,12 @@ vect_recog_sat_trunc_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo, tree ops[1]; tree lhs = gimple_assign_lhs (last_stmt); + tree otype = TREE_TYPE (lhs); - if (gimple_unsigned_integer_sat_trunc (lhs, ops, NULL)) + if (gimple_unsigned_integer_sat_trunc (lhs, ops, NULL) + && type_has_mode_precision_p (otype)) { tree itype = TREE_TYPE (ops[0]); - tree otype = TREE_TYPE (lhs); tree v_itype = get_vectype_for_scalar_type (vinfo, itype); tree v_otype = get_vectype_for_scalar_type (vinfo, otype); internal_fn fn = IFN_SAT_TRUNC;
[gcc r15-2777] Reduce iteration counts for gcc.dg/vect/tsvc tests.
https://gcc.gnu.org/g:8fac69a2dbff98ebe1feb87faba0d9b81a173c40 commit r15-2777-g8fac69a2dbff98ebe1feb87faba0d9b81a173c40 Author: Joern Rennecke Date: Mon Jul 22 11:02:16 2024 +0100 Reduce iteration counts for gcc.dg/vect/tsvc tests. testsuite/ * gcc.dg/vect/tsvc/tsvc.h (iterations): Allow to override, default to 10. (get_expected_result): Add values for iterations counts 10, 256 and 3200. (run): Add code to output values for new iterations counts. * gcc.dg/vect/tsvc/vect-tsvc-s1119.c (dg-additional-options): Add -Diterations=LEN_2D . * gcc.dg/vect/tsvc/vect-tsvc-s115.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s119.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s125.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s2102.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s2233.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s2275.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s231.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s235.c: Likewise. * gcc.dg/vect/tsvc/vect-tsvc-s176.c: (dg-additional-options): Add -Diterations=3200 . [!run_expensive_tests]: dg-additional-options "-DTRUNCATE_TEST" . [TRUNCATE_TEST]: Set m to 32. Diff: --- gcc/testsuite/gcc.dg/vect/tsvc/tsvc.h| 352 ++- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s1119.c | 4 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s115.c | 4 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s119.c | 4 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s125.c | 4 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s176.c | 13 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s2102.c | 2 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s2233.c | 4 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s2275.c | 4 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s231.c | 4 +- gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s235.c | 4 +- 11 files changed, 379 insertions(+), 20 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/tsvc/tsvc.h b/gcc/testsuite/gcc.dg/vect/tsvc/tsvc.h index d910c384fc83..cc02e4cacba1 100644 --- a/gcc/testsuite/gcc.dg/vect/tsvc/tsvc.h +++ b/gcc/testsuite/gcc.dg/vect/tsvc/tsvc.h @@ -1,7 +1,10 @@ /* This file is distributed under the University of Illinois Open Source License. See license.txt for details. */ -#define iterations 1 +#ifndef iterations +#define iterations 10 +/* Was: #define iterations 1 */ +#endif #define LEN_1D 32000 #define LEN_2D 256 #define ARRAY_ALIGNMENT 64 @@ -1093,7 +1096,11 @@ real_t calc_checksum(const char * name) real_t get_expected_result(const char * name) { -if (!strcmp(name, "s000")) { +if (!name) { +fprintf(stderr, "NULL name passed to expected_result.\n"); +exit(1); +#if iterations == 1 +} else if (!strcmp(name, "s000")) { return 512075584.f; } else if (!strcmp(name, "s111")) { return 32000.410156f; @@ -1395,6 +1402,334 @@ real_t get_expected_result(const char * name) return 1.644824f; } else if (!strcmp(name, "vbor")) { return 31924.046875f; +#elif iterations == 10 +} else if (!strcmp (name, "s000")) { + return 512066944.00f; +} else if (!strcmp (name, "s")) { + return 13.352139f; +} else if (!strcmp (name, "s1112")) { + return 32008.869141f; +} else if (!strcmp (name, "s1113")) { + return 51.947979f; +} else if (!strcmp (name, "s1115")) { + return 1567.842896f; +} else if (!strcmp (name, "s1119")) { + return 1567.842896f; +} else if (!strcmp (name, "s111")) { + return 32000.410156f; +} else if (!strcmp (name, "s112")) { + return 32049.320312f; +} else if (!strcmp (name, "s113")) { + return 32000.640625f; +} else if (!strcmp (name, "s114")) { + return 1567.842896f; +} else if (!strcmp (name, "s115")) { + return 32000.00f; +} else if (!strcmp (name, "s1161")) { + return 23.546333f; +} else if (!strcmp (name, "s116")) { + return 32000.00f; +} else if (!strcmp (name, "s118")) { + return 32000.00f; +} else if (!strcmp (name, "s119")) { + return 65536.00f; +} else if (!strcmp (name, "s1213")) { + return 14.449853f; +} else if (!strcmp (name, "s121")) { + return 32004.953125f; +} else if (!strcmp (name, "s1221")) { + return 79623.273438f; +} else if (!strcmp (name, "s122")) { + return 32016.369141f; +} else if (!strcmp (name, "s1232")) { + return 1567.842896f; +} else if (!strcmp (name, "s123")) { + return 32003.283203f; +} else if (!strcmp (name, "s1244")) { + return 36.141911f; +} else if (!strcmp (name, "s124")) { + return 32001.640625f; +} else if (!strcmp (name, "s1251")) { + return 42.998329f; +} else if (!strcmp (name, "s125"))
[gcc r15-2778] c++: Improve fixits for incorrect explicit instantiations
https://gcc.gnu.org/g:b7f719612515a86d1d2a36e24b02ade3f0904e10 commit r15-2778-gb7f719612515a86d1d2a36e24b02ade3f0904e10 Author: Nathaniel Shead Date: Mon Mar 4 22:59:56 2024 +1100 c++: Improve fixits for incorrect explicit instantiations When forgetting the '<>' on an explicit specialisation, the suggested fixit hint suggests to add 'template <>', but naively applying will cause nonsense results like 'template template <> struct S {};'. Instead check if we're currently parsing an explicit instantiation, and if so inform about the issue (an instantiation cannot have a class body) and suggest a fixit of simply '<>' to create a specialisation instead. gcc/cp/ChangeLog: * parser.cc (cp_parser_class_head): Clarify error message for explicit instantiations. gcc/testsuite/ChangeLog: * g++.dg/template/explicit-instantiation9.C: New test. Signed-off-by: Nathaniel Shead Diff: --- gcc/cp/parser.cc | 19 ++- .../g++.dg/template/explicit-instantiation9.C | 6 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index f625b0a310c8..82f3903838e2 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -27721,11 +27721,20 @@ cp_parser_class_head (cp_parser* parser, class_head_start_location, get_finish (type_start_token->location)); rich_location richloc (line_table, reported_loc); - richloc.add_fixit_insert_before (class_head_start_location, - "template <> "); - error_at (&richloc, - "an explicit specialization must be preceded by" - " %%>"); + if (processing_explicit_instantiation) + { + richloc.add_fixit_insert_before ("<> "); + error_at (&richloc, + "an explicit instantiation cannot have a definition;" + " use %%> to declare a specialization"); + } + else + { + richloc.add_fixit_insert_before ("template <> "); + error_at (&richloc, + "an explicit specialization must be preceded by" + " %%>"); + } invalid_explicit_specialization_p = true; /* Take the same action that would have been taken by cp_parser_explicit_specialization. */ diff --git a/gcc/testsuite/g++.dg/template/explicit-instantiation9.C b/gcc/testsuite/g++.dg/template/explicit-instantiation9.C new file mode 100644 index ..c4400226ef83 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/explicit-instantiation9.C @@ -0,0 +1,6 @@ +// Fixits for specialisations are not valid for instantiations + +template +struct S {}; + +template struct S {}; // { dg-error "explicit instantiation cannot have a definition" }
[gcc r15-2779] c++/modules: Ensure deduction guides are always reachable [PR115231]
https://gcc.gnu.org/g:ca287145f23ec3ea987fc2eacde3994096cc528e commit r15-2779-gca287145f23ec3ea987fc2eacde3994096cc528e Author: Nathaniel Shead Date: Sat Jun 15 22:50:14 2024 +1000 c++/modules: Ensure deduction guides are always reachable [PR115231] Deduction guides are represented as 'normal' functions currently, and have no special handling in modules. However, this causes some issues; by [temp.deduct.guide] a deduction guide is not found by normal name lookup and instead all reachable deduction guides for a class template should be considered, but this does not happen currently. To solve this, this patch ensures that all deduction guides are considered exported to ensure that they are always visible to importers if they are reachable. Another alternative here would be to add a new kind of "all reachable" flag to name lookup, but that is complicated by some difficulties in handling GM entities; this may be a better way to go if more kinds of entities end up needing this handling, however. Another issue here is that because deduction guides are "unrelated" functions, they will usually get discarded from the GMF, so this patch ensures that when finding dependencies, GMF deduction guides will also have bindings created. We do this in find_dependencies so that we don't unnecessarily create bindings for GMF deduction guides that are never reached; for consistency we do this for *all* deduction guides, not just GM ones. We also make sure that the opposite (a deduction guide being the only purview reference to a GMF template) correctly marks it as reachable. Finally, when merging deduction guides from multiple modules, the name lookup code may now return two-dimensional overload sets, so update callers to match. As a small drive-by improvement this patch also updates the error pretty printing code to add a space before the '->' when printing a deduction guide, so we get 'S(int) -> S' instead of 'S(int)-> S'. PR c++/115231 gcc/cp/ChangeLog: * error.cc (dump_function_decl): Add a space before '->' when printing deduction guides. * module.cc (depset::hash::add_binding_entity): Don't create bindings for guides here, only mark dependencies. (depset::hash::add_deduction_guides): New. (depset::hash::find_dependencies): Add deduction guide dependencies for a class template. (module_state::write_cluster): Always consider deduction guides as exported. * pt.cc (deduction_guides_for): Use 'lkp_iterator' instead of 'ovl_iterator'. gcc/testsuite/ChangeLog: * g++.dg/modules/dguide-1_a.C: New test. * g++.dg/modules/dguide-1_b.C: New test. * g++.dg/modules/dguide-2_a.C: New test. * g++.dg/modules/dguide-2_b.C: New test. * g++.dg/modules/dguide-3_a.C: New test. * g++.dg/modules/dguide-3_b.C: New test. * g++.dg/modules/dguide-3_c.C: New test. * g++.dg/modules/dguide-3_d.C: New test. Signed-off-by: Nathaniel Shead Diff: --- gcc/cp/error.cc | 1 + gcc/cp/module.cc | 65 +++ gcc/cp/pt.cc | 2 +- gcc/testsuite/g++.dg/modules/dguide-1_a.C | 44 + gcc/testsuite/g++.dg/modules/dguide-1_b.C | 20 ++ gcc/testsuite/g++.dg/modules/dguide-2_a.C | 24 gcc/testsuite/g++.dg/modules/dguide-2_b.C | 19 + gcc/testsuite/g++.dg/modules/dguide-3_a.C | 10 + gcc/testsuite/g++.dg/modules/dguide-3_b.C | 10 + gcc/testsuite/g++.dg/modules/dguide-3_c.C | 6 +++ gcc/testsuite/g++.dg/modules/dguide-3_d.C | 30 ++ 11 files changed, 230 insertions(+), 1 deletion(-) diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index ee3868efaed6..6c22ff55b463 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -1936,6 +1936,7 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) dump_type_suffix (pp, ret, flags); else if (deduction_guide_p (t)) { + pp->set_padding (pp_before); pp_cxx_ws_string (pp, "->"); dump_type (pp, TREE_TYPE (TREE_TYPE (t)), flags); } diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 7130faf26f52..723f0890d96e 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -2589,6 +2589,9 @@ public: void add_partial_entities (vec *); void add_class_entities (vec *); + private: +void add_deduction_guides (tree decl); + public: void find_dependencies (module_state *); bool finalize_dependencies (); @@ -13172,6 +13175,15 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) /* Ignore NTTP objects. */ return false;
[gcc r15-2780] Fix vect/pr115278.cc for targets where uint32_t is distinct from unsigned.
https://gcc.gnu.org/g:b844775283a620b8826adf734ecfc97d820c3611 commit r15-2780-gb844775283a620b8826adf734ecfc97d820c3611 Author: Joern Rennecke Date: Wed Aug 7 02:48:45 2024 +0100 Fix vect/pr115278.cc for targets where uint32_t is distinct from unsigned. gcc/testsuite/ * g++.dg/vect/pr115278.cc: Make cast's type agree with assignment destination WRITE. Diff: --- gcc/testsuite/g++.dg/vect/pr115278.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/g++.dg/vect/pr115278.cc b/gcc/testsuite/g++.dg/vect/pr115278.cc index 331075fb2781..df521e43a97c 100644 --- a/gcc/testsuite/g++.dg/vect/pr115278.cc +++ b/gcc/testsuite/g++.dg/vect/pr115278.cc @@ -21,7 +21,7 @@ union BitfieldStructUnion { BitfieldStructUnion(uint32_t value_low, uint32_t value_high) : value_low(value_low), value_high(value_high) {} }; -volatile uint32_t *WRITE = (volatile unsigned*)0x42; +volatile uint32_t *WRITE = (volatile uint32_t *)0x42; void buggy() { for (int i = 0; i < runs; i++) {
[gcc r15-2781] Fix Wstringop-overflow-47.c warning in RISC-V target.
https://gcc.gnu.org/g:b4d91abddc2359a5457b1c77f038b86567da52b6 commit r15-2781-gb4d91abddc2359a5457b1c77f038b86567da52b6 Author: Jiawei Date: Tue Jul 16 08:06:25 2024 +0800 Fix Wstringop-overflow-47.c warning in RISC-V target. Update warning test info for RISC-V target, compared on godbolt: https://godbolt.org/z/Mexd3dfcc gcc/testsuite/ChangeLog: * gcc.dg/Wstringop-overflow-47.c: Remove xfail target. Diff: --- gcc/testsuite/gcc.dg/Wstringop-overflow-47.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c index 883921b097ff..9fb78e55046f 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c @@ -65,15 +65,15 @@ void warn_i16_64 (int16_t i) like x86_64 it's a series of BIT_FIELD_REFs. The overflow by the former is detected but the latter is not yet. */ - extern char warn_a64[64]; // { dg-message "at offset (1|128) into destination object 'warn_a64' of size (63|64)" "pr97027 note" { xfail { ! { aarch64-*-* riscv*-*-* } } } } + extern char warn_a64[64]; // { dg-message "at offset (1|128) into destination object 'warn_a64' of size (63|64)" "pr97027 note" { xfail { ! { aarch64-*-* } } } } void *p = warn_a64 + 1; I16_64 *q = (I16_64*)p; - *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! { aarch64-*-* riscv*-*-* } } } } + *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! { aarch64-*-* } } } } char a64[64]; p = a64 + 1; q = (I16_64*)p; - *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! { aarch64-*-* riscv*-*-* } } } } + *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! { aarch64-*-* } } } } sink (p); }
[gcc r15-2782] MAINTAINERS: Change my contact email in MAINTAINERS file.
https://gcc.gnu.org/g:b8443da2fd7a5154e404e863539b68df812b3032 commit r15-2782-gb8443da2fd7a5154e404e863539b68df812b3032 Author: navidr Date: Wed Aug 7 04:55:37 2024 + MAINTAINERS: Change my contact email in MAINTAINERS file. * MAINTAINERS: Changing my email to gnu email. Diff: --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 7f697bfa193b..07ea5f5b6e12 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -729,7 +729,7 @@ Yao Qi qiyao Xianmiao Qu - Jerry Quinn jlquinn Ramana Radhakrishnanramana -Navid Rahiminavidr +Navid Rahiminavidr Rishi Raj - Easwaran Raman eraman Joe Ramsay joeramsay @@ -930,7 +930,7 @@ Gaius Mulley Andrew Pinski Siddhesh Poyarekar Ramana Radhakrishnan -Navid Rahimi +Navid Rahimi Rishi Raj Trevor Saunders Bill Schmidt