Simplify X * C1 == C2 with undefined overflow
Hello, this transformation is quite straightforward, without overflow, 3*X==15 is the same as X==5 and 3*X==5 cannot happen. Adding a single_use restriction for the first case didn't seem necessary, although of course it can slightly increase register pressure in some cases. Bootstrap+regtest on x86_64-pc-linux-gnu. 2020-08-03 Marc Glisse PR tree-optimization/95433 * match.pd (X * C1 == C2): New transformation. * gcc.c-torture/execute/pr23135.c: Add -fwrapv to avoid undefined behavior. * gcc.dg/tree-ssa/pr95433.c: New file. -- Marc Glissediff --git a/gcc/match.pd b/gcc/match.pd index a052c9e3dbc..78fd8cf5d9e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1578,6 +1578,20 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && wi::neg_p (wi::to_wide (@1), TYPE_SIGN (TREE_TYPE (@1 (cmp @2 @0)) +/* For integral types with undefined overflow fold + x * C1 == C2 into x == C2 / C1 or false. */ +(for cmp (eq ne) + (simplify + (cmp (mult @0 INTEGER_CST@1) INTEGER_CST@2) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)) + && wi::to_wide (@1) != 0) + (with { widest_int quot; } +(if (wi::multiple_of_p (wi::to_widest (@2), wi::to_widest (@1), + TYPE_SIGN (TREE_TYPE (@0)), ")) + (cmp @0 { wide_int_to_tree (TREE_TYPE (@0), quot); }) + { build_int_cst (type, cmp == NE_EXPR); }) + /* (X - 1U) <= INT_MAX-1U into (int) X > 0. */ (for cmp (le gt) icmp (gt le) diff --git a/gcc/testsuite/gcc.c-torture/execute/pr23135.c b/gcc/testsuite/gcc.c-torture/execute/pr23135.c index e740ff52874..ef9b7efc9c4 100644 --- a/gcc/testsuite/gcc.c-torture/execute/pr23135.c +++ b/gcc/testsuite/gcc.c-torture/execute/pr23135.c @@ -1,7 +1,7 @@ /* Based on execute/simd-1.c, modified by joern.renne...@st.com to trigger a reload bug. Verified for gcc mainline from 20050722 13:00 UTC for sh-elf -m4 -O2. */ -/* { dg-options "-Wno-psabi" } */ +/* { dg-options "-Wno-psabi -fwrapv" } */ /* { dg-add-options stack_size } */ #ifndef STACK_SIZE diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr95433.c b/gcc/testsuite/gcc.dg/tree-ssa/pr95433.c new file mode 100644 index 000..4e161ee26cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr95433.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +int f(int x){return x*7==17;} +int g(int x){return x*3==15;} + +/* { dg-final { scan-tree-dump "return 0;" "optimized" } } */ +/* { dg-final { scan-tree-dump "== 5;" "optimized" } } */
Re: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
Hi Paul, This is my first foray into gfortran for quite a little while so I am going cautiously on this 'obvious' patch. The comment in the patch and the ChangLog are clear enough that no further explanation is needed. Regtests on FC31.x86_64 - OK for trunk? If I read the PR correctly, this is a F2008 feature. Do you think it should have a gfc_option.allow_std & GFC_STD_F2008 somewhere? Apart from that, OK for trunk. I am a bit reluctant to get into backporting just yet because I am still groping my way round git. However, I will do it when I feel a bit braver! Actually, backporting is not all that bad if the patch applies cleanly. I don't know if you have done this recently, but it very much makes sense to run contrib/gcc-git-customization.sh which will then give you access to commands like "git gcc-backport" (there is tab completion) and others. 2020-07-31 Paul Thomas PR fortran/96320 * interface.c (gfc_check_dummy_characteristics): If a module procedure arrives with assumed shape in the interface and deferred shape in the procedure itself, update the latter and copy the lower bounds. 2020-07-31 Paul Thomas PR fortran/96320 * gfortran.dg/module_procedure_4.f90 : New test. With the ChangeLog formatted like this, I am afraid you will run afoul of the ChangeLog style police :-( In the Brave New World of git, you do not commit a ChangeLog together with your patch, you put it into the git commit message. It is best if you run your patch through contrib/mklog.py to get the template for your commit message. You can then copy over the other information. And you need a one-line description for the patch of at most 80 characters, with a period at the end. And, I think, new test cases are added automatically to the ChangeLogs. The ChangeLog then look something like this: Fix shape mismatch in assumed-length dummy argument character array. gcc/fortran/ChangeLog: 2020-07-31 Paul Thomas PR fortran/96320 * interface.c (gfc_check_dummy_characteristics): If a module procedure arrives with assumed shape in the interface and deferred shape in the procedure itself, update the latter and copy the lower bounds. (compare_parameter): Fix whitespace. (gfc_procedure_use): Fix whitespace. If you have already committed something that the ChangeLog style police objects to, you can change that with "git commit --amend". I hope this helps you in avoiding a few iterations of getting rejected when pushing a change. I think it covers most of what I went through :-| (I just discovered that there is a "git gcc-verify" which probably does the tests before you push. Maybe that could be helpful.) Best regards Thomas
Re: [Patch, fortran] PR96320 - gfortran 8-10 shape mismatch in assumed-length dummy argument character array
Hi Thomas, I discovered the bit about the ChangeLogs last night but thanks for the warning:-) The commit message reads: This patch fixes PR96320. See the explanatory comment in the testcase. 2020-08-01 Paul Thomas gcc/fortran PR target/96320 * interface.c (gfc_check_dummy_characteristics): If a module procedure arrives with assumed shape in the interface and deferred shape in the procedure itself, update the latter and copy the lower bounds. gcc/testsuite/ PR target/96320 * gfortran.dg/module_procedure_4.f90 : New test. Setting standard F2003 results in a whole pile of errors, starting with: ../pr96320/pr96320.f90:19:12: 19 | module subroutine bar1(arg) |1 Error: Fortran 2008: MODULE prefix at (1) and a bit later: ../pr96320/pr96320.f90:23:12: 23 | module subroutine bar2(arg) |1 Error: Fortran 2008: MODULE prefix at (1) Cheers Paul On Sat, 1 Aug 2020 at 10:54, Thomas Koenig wrote: > Hi Paul, > > > This is my first foray into gfortran for quite a little while so I am > going > > cautiously on this 'obvious' patch. The comment in the patch and the > > ChangLog are clear enough that no further explanation is needed. > > > > Regtests on FC31.x86_64 - OK for trunk? > > If I read the PR correctly, this is a F2008 feature. Do you think > it should have a gfc_option.allow_std & GFC_STD_F2008 somewhere? > > Apart from that, OK for trunk. > > > I am a bit reluctant to get into backporting just yet because I am still > > groping my way round git. However, I will do it when I feel a bit braver! > > Actually, backporting is not all that bad if the patch applies cleanly. > I don't know if you have done this recently, but it very much > makes sense to run > > contrib/gcc-git-customization.sh > > which will then give you access to commands like "git gcc-backport" > (there is tab completion) and others. > > > > 2020-07-31 Paul Thomas > > > > PR fortran/96320 > > * interface.c (gfc_check_dummy_characteristics): If a module > > procedure arrives with assumed shape in the interface and > > deferred shape in the procedure itself, update the latter and > > copy the lower bounds. > > > > 2020-07-31 Paul Thomas > > > > PR fortran/96320 > > * gfortran.dg/module_procedure_4.f90 : New test. > > With the ChangeLog formatted like this, I am afraid you will > run afoul of the ChangeLog style police :-( > > In the Brave New World of git, you do not commit a ChangeLog > together with your patch, you put it into the git commit > message. > > It is best if you run your patch through contrib/mklog.py > to get the template for your commit message. You can then copy > over the other information. > > And you need a one-line description for the patch of at most > 80 characters, with a period at the end. > > And, I think, new test cases are added automatically to the > ChangeLogs. > > The ChangeLog then look something like this: > > Fix shape mismatch in assumed-length dummy argument character array. > > gcc/fortran/ChangeLog: > > 2020-07-31 Paul Thomas > > PR fortran/96320 > * interface.c (gfc_check_dummy_characteristics): If a module > procedure arrives with assumed shape in the interface and > deferred shape in the procedure itself, update the latter and > copy the lower bounds. > (compare_parameter): Fix whitespace. > (gfc_procedure_use): Fix whitespace. > > > If you have already committed something that the ChangeLog style > police objects to, you can change that with "git commit --amend". > > I hope this helps you in avoiding a few iterations of getting rejected > when pushing a change. I think it covers most of what I went through :-| > > (I just discovered that there is a "git gcc-verify" which probably > does the tests before you push. Maybe that could be helpful.) > > Best regards > > Thomas > -- "If you can't explain it simply, you don't understand it well enough" - Albert Einstein
[Patch, fortran] PR96325 - Unclassifiable statement with syntax similar to a type-bound procedure call is accepted
The attached patch regtests on FC31/x86_64 - OK for trunk? Cheers Paul Commit message: This patch fixes PR96325. See the explanatory comment in the testcase. 2020-08-01 Paul Thomas gcc/fortran PR target/96325 * primary.c (gfc_match_varspec): In the case that a component reference is added to an intrinsic type component, emit the error message in this function. gcc/testsuite/ PR target/96325 * gfortran.dg/pr96325.f90: New test. * gfortran.dg/pr91589.f90: Update error message. diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index c0f66d3df22..a58a25924da 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -2023,7 +2023,8 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, { char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_ref *substring, *tail, *tmp; - gfc_component *component; + gfc_component *component = NULL; + gfc_component *previous = NULL; gfc_symbol *sym = primary->symtree->n.sym; gfc_expr *tgt_expr = NULL; match m; @@ -2343,15 +2344,19 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, break; } + previous = component; + if (!inquiry && !intrinsic) component = gfc_find_component (sym, name, false, false, &tmp); else component = NULL; - /* In some cases, returning MATCH_NO gives a better error message. Most - cases return "Unclassifiable statement at..." */ if (intrinsic && !inquiry) - return MATCH_NO; + { + gfc_error ("%qs at %C is not an inquiry reference to an intrinsic " + "type component %qs", name, previous->name); + return MATCH_ERROR; + } else if (component == NULL && !inquiry) return MATCH_ERROR; diff --git a/gcc/testsuite/gfortran.dg/pr91589.f90 b/gcc/testsuite/gfortran.dg/pr91589.f90 index d02cb64bfc2..375d895e0b7 100644 --- a/gcc/testsuite/gfortran.dg/pr91589.f90 +++ b/gcc/testsuite/gfortran.dg/pr91589.f90 @@ -10,6 +10,6 @@ program p integer :: a end type type(t) :: x = t(1) - call sub (x%a%a) ! { dg-error "Syntax error in argument list" } + call sub (x%a%a) ! { dg-error "is not an inquiry reference" } end ! { dg-do run } ! ! Test the fix for PR96325 in which the typebound procedure reference ! 'foo' was applied to an intrinsic type component without generating ! an error. The result of the expression was the value of the arg.. ! ! Contributed by Gerhardt Steinmetz ! implicit none type t2 integer r1 end type type(t2) :: t integer :: a a = t%r1%foo(1) { dg-error "is not an inquiry reference" } if (a == 42) stop end
[PATCH v4] genemit.c (main): split insn-emit.c for compiling parallelly
gcc/ChangeLog: * genemit.c (main): Print 'split line'. * Makefile.in (insn-emit.c): Define split count and file --- gcc/Makefile.in | 11 +++ gcc/genemit.c | 87 - 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 2ba76656dbf..bc0b3e6d343 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1253,6 +1253,13 @@ ANALYZER_OBJS = \ # We put the *-match.o and insn-*.o files first so that a parallel make # will build them sooner, because they are large and otherwise tend to be # the last objects to finish building. + +insn-generated-split-num = $(shell nproc) + +insn-emit-split-c = $(foreach o, $(shell for i in {1..$(insn-generated-split-num)}; do echo $$i; done), insn-emit$(o).c) +insn-emit-split-obj = $(patsubst %.c,%.o, $(insn-emit-split-c)) +$(insn-emit-split-c): insn-emit.c + OBJS = \ gimple-match.o \ generic-match.o \ @@ -1260,6 +1267,7 @@ OBJS = \ insn-automata.o \ insn-dfatab.o \ insn-emit.o \ + $(insn-emit-split-obj) \ insn-extract.o \ insn-latencytab.o \ insn-modes.o \ @@ -2367,6 +2375,9 @@ $(simple_generated_c:insn-%.c=s-%): s-%: build/gen%$(build_exeext) $(RUN_GEN) build/gen$*$(build_exeext) $(md_file) \ $(filter insn-conditions.md,$^) > tmp-$*.c $(SHELL) $(srcdir)/../move-if-change tmp-$*.c insn-$*.c + $*v=$$(echo $$(csplit insn-$*.c /parallel\ compilation/ -k -s {$(insn-generated-split-num)} -f insn-$* -b "%d.c" 2>&1));\ + [ ! "$$$*v" ] || grep "match not found" <<< $$$*v + [ -s insn-$*0.c ] || (for i in {1..$(insn-generated-split-num)}; do touch insn-$*$$i.c; done && echo "" > insn-$*.c) $(STAMP) s-$* # gencheck doesn't read the machine description, and the file produced diff --git a/gcc/genemit.c b/gcc/genemit.c index 84d07d388ee..3aaaeb62b0a 100644 --- a/gcc/genemit.c +++ b/gcc/genemit.c @@ -847,6 +847,46 @@ handle_overloaded_gen (overloaded_name *oname) } } +#define printf_include() do { \ + printf ("/* Generated automatically by the program `genemit'\n\ +from the machine description file `md'. */\n\n"); \ + printf ("#define IN_TARGET_CODE 1\n");\ + printf ("#include \"config.h\"\n"); \ + printf ("#include \"system.h\"\n"); \ + printf ("#include \"coretypes.h\"\n");\ + printf ("#include \"backend.h\"\n"); \ + printf ("#include \"predict.h\"\n"); \ + printf ("#include \"tree.h\"\n"); \ + printf ("#include \"rtl.h\"\n"); \ + printf ("#include \"alias.h\"\n");\ + printf ("#include \"varasm.h\"\n"); \ + printf ("#include \"stor-layout.h\"\n"); \ + printf ("#include \"calls.h\"\n");\ + printf ("#include \"memmodel.h\"\n"); \ + printf ("#include \"tm_p.h\"\n"); \ + printf ("#include \"flags.h\"\n");\ + printf ("#include \"insn-config.h\"\n"); \ + printf ("#include \"expmed.h\"\n"); \ + printf ("#include \"dojump.h\"\n"); \ + printf ("#include \"explow.h\"\n"); \ + printf ("#include \"emit-rtl.h\"\n"); \ + printf ("#include \"stmt.h\"\n"); \ + printf ("#include \"expr.h\"\n"); \ + printf ("#include \"insn-codes.h\"\n"); \ + printf ("#include \"optabs.h\"\n"); \ + printf ("#include \"dfp.h\"\n"); \ + printf ("#include \"output.h\"\n"); \ + printf ("#include \"recog.h\"\n");\ + printf ("#include \"df.h\"\n"); \ + printf ("#include \"resource.h\"\n"); \ + printf ("#include \"reload.h\"\n"); \ + printf ("#include \"diagnostic-core.h\"\n"); \ + printf ("#include \"regs.h\"\n"); \ + printf ("#include \"tm-constrs.h\"\n"); \ + printf ("#include \"ggc.h\"\n"); \ + printf ("#include \"target.h\"\n\n"); \ +} while (0) + int main (int argc, const char **argv) { @@ -862,49 +902,19 @@ main (int argc, const char **argv) /* Assign sequential codes to all entries in the machine description in parallel with the tables in insn-output.c. */ - printf ("/* Generated automatically by the program `genemit'\n\ -from the machine description file `md'. */\n\n"); - - printf ("#define IN_TARGET_CODE 1\n"); - printf ("#include \"config.h\"\n"); - printf ("#include \"system.h\"\n"); - printf ("#include \"coretypes.h\"\n"); - printf ("#include \"backend.h\"\n"); - printf ("#include \"predict.h\"\n"); - printf ("#include \"tree.h\"\n"); - printf ("#include \"rtl.h\"\n"); - printf ("#include \"
Re: [PATCH] CSKY: Add -mfloat-abi= option.
Committed to trunk, Thanks. Xianmiao On 7/31/20 3:18 PM, Jojo R wrote: gcc/ChangeLog: * config/csky/csky_opts.h (float_abi_type): New. * config/csky/csky.h (TARGET_SOFT_FLOAT): New. (TARGET_HARD_FLOAT): New. (TARGET_HARD_FLOAT_ABI): New. (OPTION_DEFAULT_SPECS): Use mfloat-abi. * config/csky/csky.opt (mfloat-abi): New. * doc/invoke.texi (C-SKY Options): Document -mfloat-abi=. --- gcc/config/csky/csky.h | 9 - gcc/config/csky/csky.opt| 29 + gcc/config/csky/csky_opts.h | 7 +++ gcc/doc/invoke.texi | 18 ++ 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/gcc/config/csky/csky.h b/gcc/config/csky/csky.h index 2d5a66ca187..8f4090b4b38 100644 --- a/gcc/config/csky/csky.h +++ b/gcc/config/csky/csky.h @@ -126,6 +126,13 @@ #define TARGET_TLS \ (CSKY_TARGET_ARCH (CK807) || CSKY_TARGET_ARCH (CK810)) +/* Run-time Target Specification. */ +#define TARGET_SOFT_FLOAT (csky_float_abi == CSKY_FLOAT_ABI_SOFT) +/* Use hardware floating point instructions. */ +#define TARGET_HARD_FLOAT (csky_float_abi != CSKY_FLOAT_ABI_SOFT) +/* Use hardware floating point calling convention. */ +#define TARGET_HARD_FLOAT_ABI (csky_float_abi == CSKY_FLOAT_ABI_HARD) + /* Number of loads/stores handled by ldm/stm. */ #define CSKY_MIN_MULTIPLE_STLD3 #define CSKY_MAX_MULTIPLE_STLD12 @@ -818,7 +825,7 @@ while (0) {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \ {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ {"endian", "%{!mbig-endian:%{!mlittle-endian:-m%(VALUE)-endian}}" }, \ - {"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }, + {"float", "%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}" }, /** diff --git a/gcc/config/csky/csky.opt b/gcc/config/csky/csky.opt index 5846e50344f..60b51e5798f 100644 --- a/gcc/config/csky/csky.opt +++ b/gcc/config/csky/csky.opt @@ -57,12 +57,33 @@ Target RejectNegative Report Alias(mlittle-endian) Undocumented ;; assembly. mhard-float -Target Report RejectNegative Mask(HARD_FLOAT) -Enable hardware floating-point instructions. +Target RejectNegative Alias(mfloat-abi=, hard) Undocumented msoft-float -Target Report RejectNegative InverseMask(HARD_FLOAT) -Use library calls to perform floating-point operations (default). +Target RejectNegative Alias(mfloat-abi=, soft) Undocumented + +mfloat-abi=v2 +Target RejectNegative Alias(mfloat-abi=, hard) Undocumented + +mfloat-abi=v1 +Target RejectNegative Alias(mfloat-abi=, softfp) Undocumented + +mfloat-abi= +Target RejectNegative Joined Enum(float_abi_type) Var(csky_float_abi) Init(CSKY_FLOAT_ABI_SOFT) +Specify if floating point hardware should be used. + +Enum +Name(float_abi_type) Type(enum float_abi_type) +Known floating-point ABIs (for use with the -mfloat-abi= option): + +EnumValue +Enum(float_abi_type) String(soft) Value(CSKY_FLOAT_ABI_SOFT) + +EnumValue +Enum(float_abi_type) String(softfp) Value(CSKY_FLOAT_ABI_SOFTFP) + +EnumValue +Enum(float_abi_type) String(hard) Value(CSKY_FLOAT_ABI_HARD) mfpu= Target RejectNegative Joined Enum(csky_fpu) Var(csky_fpu_index) Init(TARGET_FPU_auto) Save diff --git a/gcc/config/csky/csky_opts.h b/gcc/config/csky/csky_opts.h index a6dbf5ab6dd..7ee56be3e81 100644 --- a/gcc/config/csky/csky_opts.h +++ b/gcc/config/csky/csky_opts.h @@ -59,5 +59,12 @@ enum csky_fpu_type }; #define CSKY_TARGET_FPU_GET(name) TARGET_FPU_ ## name +enum float_abi_type +{ + CSKY_FLOAT_ABI_SOFT, + CSKY_FLOAT_ABI_SOFTFP, + CSKY_FLOAT_ABI_HARD +}; + #endif /* CSKY_OPTS_H */ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index eaaf6d06b65..a132e09c674 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -820,6 +820,7 @@ Objective-C and Objective-C++ Dialects}. @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} @gol -mbig-endian -EB -mlittle-endian -EL @gol -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu @gol +-mfloat-abi=@var{name} @gol -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust @gol -mdsp -medsp -mvdsp @gol -mdiv -msmart -mhigh-registers -manchor @gol @@ -20644,6 +20645,23 @@ Specify the C-SKY target processor. Valid values for @var{cpu} are: Select big- or little-endian code. The default is little-endian. +@item -mfloat-abi=@var{name} +@opindex mfloat-abi +Specifies which floating-point ABI to use. Permissible values +are: @samp{soft}, @samp{softfp} and @samp{hard}. + +Specifying @samp{soft} causes GCC to generate output containing +library calls for floating-point operations. +@samp{softfp} allows the generation of code using hardware floating-point +instructions, but still uses the soft-float calling conventions. +@samp{hard} allows generation of floating-point instructions +and uses FPU-specific calling conventions. + +The default depends
Re: [PATCH v4] genemit.c (main): split insn-emit.c for compiling parallelly
On 01. 08. 20 13:02, Jojo R wrote: > gcc/ChangeLog: > > * genemit.c (main): Print 'split line'. > * Makefile.in (insn-emit.c): Define split count and file > > --- > gcc/Makefile.in | 11 +++ > gcc/genemit.c | 87 - > 2 files changed, 60 insertions(+), 38 deletions(-) > > diff --git a/gcc/Makefile.in b/gcc/Makefile.in > index 2ba76656dbf..bc0b3e6d343 100644 > --- a/gcc/Makefile.in > +++ b/gcc/Makefile.in > @@ -1253,6 +1253,13 @@ ANALYZER_OBJS = \ > # We put the *-match.o and insn-*.o files first so that a parallel make > # will build them sooner, because they are large and otherwise tend to be > # the last objects to finish building. > + > +insn-generated-split-num = $(shell nproc) > + > +insn-emit-split-c = $(foreach o, $(shell for i in > {1..$(insn-generated-split-num)}; do echo $$i; done), insn-emit$(o).c) I believe {1..10} is a bashism. Is it OK in this context to require Bash? > +insn-emit-split-obj = $(patsubst %.c,%.o, $(insn-emit-split-c)) > +$(insn-emit-split-c): insn-emit.c > + > OBJS = \ > gimple-match.o \ > generic-match.o \ > @@ -1260,6 +1267,7 @@ OBJS = \ > insn-automata.o \ > insn-dfatab.o \ > insn-emit.o \ > + $(insn-emit-split-obj) \ > insn-extract.o \ > insn-latencytab.o \ > insn-modes.o \ > @@ -2367,6 +2375,9 @@ $(simple_generated_c:insn-%.c=s-%): s-%: > build/gen%$(build_exeext) > $(RUN_GEN) build/gen$*$(build_exeext) $(md_file) \ > $(filter insn-conditions.md,$^) > tmp-$*.c > $(SHELL) $(srcdir)/../move-if-change tmp-$*.c insn-$*.c > + $*v=$$(echo $$(csplit insn-$*.c /parallel\ compilation/ -k -s > {$(insn-generated-split-num)} -f insn-$* -b "%d.c" 2>&1));\ > + [ ! "$$$*v" ] || grep "match not found" <<< $$$*v > + [ -s insn-$*0.c ] || (for i in {1..$(insn-generated-split-num)}; do > touch insn-$*$$i.c; done && echo "" > insn-$*.c) > $(STAMP) s-$* > > # gencheck doesn't read the machine description, and the file produced > diff --git a/gcc/genemit.c b/gcc/genemit.c > index 84d07d388ee..3aaaeb62b0a 100644 > --- a/gcc/genemit.c > +++ b/gcc/genemit.c > @@ -847,6 +847,46 @@ handle_overloaded_gen (overloaded_name *oname) > } > } > > +#define printf_include() do { \ > + printf ("/* Generated automatically by the program `genemit'\n\ > +from the machine description file `md'. */\n\n"); \ > + printf ("#define IN_TARGET_CODE 1\n");\ > + printf ("#include \"config.h\"\n"); \ > + printf ("#include \"system.h\"\n"); \ > + printf ("#include \"coretypes.h\"\n");\ > + printf ("#include \"backend.h\"\n"); \ > + printf ("#include \"predict.h\"\n"); \ > + printf ("#include \"tree.h\"\n"); \ > + printf ("#include \"rtl.h\"\n"); \ > + printf ("#include \"alias.h\"\n");\ > + printf ("#include \"varasm.h\"\n"); \ > + printf ("#include \"stor-layout.h\"\n"); \ > + printf ("#include \"calls.h\"\n");\ > + printf ("#include \"memmodel.h\"\n"); \ > + printf ("#include \"tm_p.h\"\n"); \ > + printf ("#include \"flags.h\"\n");\ > + printf ("#include \"insn-config.h\"\n"); \ > + printf ("#include \"expmed.h\"\n"); \ > + printf ("#include \"dojump.h\"\n"); \ > + printf ("#include \"explow.h\"\n"); \ > + printf ("#include \"emit-rtl.h\"\n"); \ > + printf ("#include \"stmt.h\"\n"); \ > + printf ("#include \"expr.h\"\n"); \ > + printf ("#include \"insn-codes.h\"\n"); \ > + printf ("#include \"optabs.h\"\n"); \ > + printf ("#include \"dfp.h\"\n"); \ > + printf ("#include \"output.h\"\n"); \ > + printf ("#include \"recog.h\"\n");\ > + printf ("#include \"df.h\"\n"); \ > + printf ("#include \"resource.h\"\n"); \ > + printf ("#include \"reload.h\"\n"); \ > + printf ("#include \"diagnostic-core.h\"\n"); \ > + printf ("#include \"regs.h\"\n"); \ > + printf ("#include \"tm-constrs.h\"\n"); \ > + printf ("#include \"ggc.h\"\n"); \ > + printf ("#include \"target.h\"\n\n"); \ > +} while (0) > + > int > main (int argc, const char **argv) > { > @@ -862,49 +902,19 @@ main (int argc, const char **argv) >/* Assign sequential codes to all entries in the machine description > in parallel with the tables in insn-output.c. */ > > - printf ("/* Generated automatically by the program `genemit'\n\ > -from the machine description file `md'. */\n\n"); > - > - printf ("#define IN_TARGET_CODE 1\n"); > -
Add order verification
Hi, while looking into the chromium build issue I noticed that order can get pretty large. This patch adds checking so we know if it ever overflows or if someone uses it incorrectly (the second is important since one uninitialized order may disturb lto streaming) Honza gcc/ChangeLog: 2020-08-01 Jan Hubicka * symtab.c (symtab_node::verify_base): Verify order. (symtab_node::verify_symtab_nodes): Verify order. diff --git a/gcc/symtab.c b/gcc/symtab.c index 0e852d4c24d..d7dfbb676df 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -1085,6 +1085,11 @@ symtab_node::verify_base (void) error ("node has unknown type"); error_found = true; } + if (order < 0 || order >= symtab->order) +{ + error ("node has invalid order %i", order); + error_found = true; +} if (symtab->state != LTO_STREAMING) { @@ -1326,6 +1331,14 @@ symtab_node::verify_symtab_nodes (void) { symtab_node *node; hash_map comdat_head_map (251); + asm_node *anode; + + for (anode = symtab->first_asm_symbol (); anode; anode = anode->next) +if (anode->order < 0 || anode->order >= symtab->order) + { + error ("invalid order in asm node %i", anode->order); + internal_error ("symtab_node::verify failed"); + } FOR_EACH_SYMBOL (node) {
Cap frequency of self recursive calls
Hi, the frequency of self recursive call can never be 1 or more or the function would never finish. Yet we could do that based on static guesses and that may confuse IPA passes expondentially increasing frequency of functions. This patch fixes it by simply capping the BB containing self recursive call. This is not very nice (profile will be inconsistent) but I do not see how to do it better short of repeating the frequency propagation and slowly decreasing probabilities of the control dependent edges. That would probably buy little compared to this hack. Bootstrapped/regtested x86_64-linux, comitted. Honza * predict.c (estimate_bb_frequencies): Cap recursive calls by 90%. diff --git a/gcc/predict.c b/gcc/predict.c index a7ae977c866..0a317a7a4ac 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -3892,7 +3892,30 @@ estimate_bb_frequencies (bool force) cfun->cfg->count_max = profile_count::uninitialized (); FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb) { - sreal tmp = BLOCK_INFO (bb)->frequency * freq_max + sreal (1, -1); + sreal tmp = BLOCK_INFO (bb)->frequency; + if (tmp >= 1) + { + gimple_stmt_iterator gsi; + tree decl; + + /* Self recursive calls can not have frequency greater than 1 +or program will never terminate. This will result in an +inconsistent bb profile but it is better than greatly confusing +IPA cost metrics. */ + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + if (is_gimple_call (gsi_stmt (gsi)) + && (decl = gimple_call_fndecl (gsi_stmt (gsi))) != NULL + && recursive_call_p (current_function_decl, decl)) + { + if (dump_file) + fprintf (dump_file, "Dropping frequency of recursive call" + " in bb %i from %f\n", bb->index, + tmp.to_double ()); + tmp = (sreal)9 / (sreal)10; + break; + } + } + tmp = tmp * freq_max + sreal (1, -1); profile_count count = profile_count::from_gcov_type (tmp.to_int ()); /* If we have profile feedback in which this function was never
Re: [Patch, fortran] PR96325 - Unclassifiable statement with syntax similar to a type-bound procedure call is accepted
Hi Paul, The attached patch regtests on FC31/x86_64 - OK for trunk? OK. Thanks for the patch! Best regards Thomas
[PATCH] genmatch: Avoid unused parameter warnings in generated code.
This patch silences a number of unused parameter warnings whilst compiling both generic-match.c and gimple-match.c. The problem is that multiple (polymorphic) functions are generated for generic_simplify and gimple_simplify, each handling tree codes with a specific number of children. Currently, there are no simplifications for tree codes with four or five children, leading to functions with "empty" bodies and unused function arguments. This patch detects those cases, and generates stub functions (with anonymous arguments) to silence these warnings. Previously, genmatch would generate: static bool gimple_simplify (gimple_match_op *res_op, gimple_seq *seq, tree (*valueize)(tree) ATTRIBUTE_UNUSED, code_helper code, const tree type, tree _p0, tree _p1, tree _p2, tree _p3) { switch (code.get_rep()) { default:; } return false; } which results in: gimple_simplify (gimple_match_op *res_op, gimple_seq *seq, ^ gimple-match.c:130408:1: warning: unused parameter 'seq' [-Wunused-parameter] gimple-match.c:130408:1: warning: unused parameter 'type' [-Wunused-parameter] gimple-match.c:130408:1: warning: unused parameter '_p0' [-Wunused-parameter] gimple-match.c:130408:1: warning: unused parameter '_p1' [-Wunused-parameter] gimple-match.c:130408:1: warning: unused parameter '_p2' [-Wunused-parameter] gimple-match.c:130408:1: warning: unused parameter '_p3' [-Wunused-parameter] gimple-match.c:130420:1: warning: unused parameter 'res_op' [-Wunused-parameter] With this patch genmatch now generates: static bool gimple_simplify (gimple_match_op*, gimple_seq*, tree (*)(tree), code_helper, const tree, tree, tree, tree, tree) { return false; } which has the same signature but no compilation warnings. This patch has been tested on x86_64-pc-linux-gnu with a full "make bootstrap" and "make -k check" with no new failures. Ok for mainline? 2020-08-01 Roger Sayle * gcc/genmatch.c (decision_tree::gen): Emit stub functions for tree code operand counts that have no simplifications. (main): Correct comment typo. Thanks in advance, Roger -- Roger Sayle NextMove Software Cambridge, UK diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 0a8cba6..022ad8d 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -3798,6 +3798,8 @@ decision_tree::gen (FILE *f, bool gimple) for (unsigned n = 1; n <= 5; ++n) { + bool has_kids_p = false; + /* First generate split-out functions. */ for (unsigned j = 0; j < root->kids.length (); j++) { @@ -3836,6 +3838,32 @@ decision_tree::gen (FILE *f, bool gimple) else fprintf (f, " return NULL_TREE;\n"); fprintf (f, "}\n"); + has_kids_p = true; + } + + /* If this main entry has no children, avoid generating code +with compiler warnings, by generating a simple stub. */ + if (! has_kids_p) + { + if (gimple) + fprintf (f, "\nstatic bool\n" + "gimple_simplify (gimple_match_op*, gimple_seq*,\n" + " tree (*)(tree), code_helper,\n" + " const tree"); + else + fprintf (f, "\ntree\n" + "generic_simplify (location_t, enum tree_code,\n" + " const tree"); + for (unsigned i = 0; i < n; ++i) + fprintf (f, ", tree"); + fprintf (f, ")\n"); + fprintf (f, "{\n"); + if (gimple) + fprintf (f, " return false;\n"); + else + fprintf (f, " return NULL_TREE;\n"); + fprintf (f, "}\n"); + continue; } /* Then generate the main entry with the outermost switch and @@ -5061,7 +5089,7 @@ round_alloc_size (size_t s) } -/* The genmatch generator progam. It reads from a pattern description +/* The genmatch generator program. It reads from a pattern description and outputs GIMPLE or GENERIC IL matching and simplification routines. */ int
libgo patch committed: Update to go1.15rc1
This libgo patch updates the sources to the go1.15rc1 release candidate. As usual, the changes for this update are too large to include in an e-mail message. I've just included the highlights and changes to GCC-specific files below. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian f75af8c1464e948b5e166cf5ab09ebf0d82fc253 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 64a655e911e..89d1f3c7623 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -63bc2430187efe5ff47e9c7b9cd6d40b350ee7d7 +2c390ba951e83b547f6387cc9e19436c085b3775 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/MERGE b/libgo/MERGE index 4f8589371d3..ad43e2924c6 100644 --- a/libgo/MERGE +++ b/libgo/MERGE @@ -1,4 +1,4 @@ -edfd6f28486017dcb136cd3f3ec252706d4b326e +3e8f6b0791a670e52d25d76813d669daa68acfb4 The first line of this file holds the git revision number of the last merge done from the master library sources. diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 52a8330ed2a..88ea2728bc3 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -391,6 +391,11 @@ toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template toolexeclibgotexttemplate_DATA = \ text/template/parse.gox +toolexeclibgotimedir = $(toolexeclibgodir)/time + +toolexeclibgotime_DATA = \ + time/tzdata.gox + toolexeclibgounicodedir = $(toolexeclibgodir)/unicode toolexeclibgounicode_DATA = \ @@ -400,7 +405,8 @@ toolexeclibgounicode_DATA = \ # Some internal packages are needed to bootstrap the gc toolchain. toolexeclibgointernaldir = $(toolexeclibgodir)/internal toolexeclibgointernal_DATA = \ - internal/reflectlite.gox + internal/reflectlite.gox \ + internal/unsafeheader.gox # Some packages are only needed for tests, so unlike the other # internal packages nothing will explicitly depend on them. @@ -409,11 +415,11 @@ noinst_DATA = \ golang.org/x/net/nettest.gox \ internal/cfg.gox \ internal/obscuretestdata.gox \ + internal/profile.gox \ internal/testenv.gox \ internal/trace.gox \ net/internal/socktest.gox \ - os/signal/internal/pty.gox \ - runtime/pprof/internal/profile.gox + os/signal/internal/pty.gox if LIBGO_IS_RTEMS rtems_task_variable_add_file = runtime/rtems-task-variable-add.c @@ -706,9 +712,9 @@ syscall_lib_clone_lo = endif if LIBGO_IS_X86 -golangorg_x_sys_cpu_gccgo_lo = golang.org/x/sys/cpu_gccgo.lo +golangorg_x_sys_cpu_gccgo_x86_lo = golang.org/x/sys/cpu_gccgo_x86.lo else -golangorg_x_sys_cpu_gccgo_lo = +golangorg_x_sys_cpu_gccgo_x86_lo = endif PACKAGES = $(shell cat $(srcdir)/libgo-packages.txt) @@ -728,7 +734,7 @@ libgo_go_objs = \ runtime/internal/atomic_c.lo \ sync/atomic_c.lo \ internal/cpu/cpu_gccgo.lo \ - $(golangorg_x_sys_cpu_gccgo_lo) + $(golangorg_x_sys_cpu_gccgo_x86_lo) libgo_ldflags = \ -version-info $(libtool_VERSION) $(PTHREAD_CFLAGS) $(AM_LDFLAGS) @@ -1008,6 +1014,7 @@ extra_check_libs_cmd_go_internal_modload = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_module = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_mvs = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_search = $(abs_builddir)/libgotool.a +extra_check_libs_cmd_go_internal_test = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_web2 = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a @@ -1060,9 +1067,9 @@ internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/cpu/cpu_gccgo.c # Similarly, golang.org/x/sys/cpu needs some C code. -golang.org/x/sys/cpu_gccgo.lo: go/golang.org/x/sys/cpu/cpu_gccgo.c runtime.inc +golang.org/x/sys/cpu_gccgo_x86.lo: go/golang.org/x/sys/cpu/cpu_gccgo_x86.c runtime.inc @$(MKDIR_P) golang.org/x/sys - $(LTCOMPILE) -c -o $@ $(srcdir)/go/golang.org/x/sys/cpu/cpu_gccgo.c + $(LTCOMPILE) -c -o $@ $(srcdir)/go/golang.org/x/sys/cpu/cpu_gccgo_x86.c # Solaris 11.4 changed the type of fields in struct stat. # Use a build tag, based on a configure check, to cope. @@ -1238,7 +1245,7 @@ all-local: $(ALL_LOCAL_DEPS) MAJOR=$(firstword $(subst :, ,$(libtool_VERSION))) add-aix-fat-library: all-multi -@if test "$(MULTIBUILDTOP)" = ""; then \ -${AR} -X$(AIX_DEFAULT_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \ -${AR} -X$(AIX_DEFAULT_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \ -fi + @if test "$(MULTIBUILDTOP)" = ""; then \ + ${AR} -X$(AIX_DEFAULT_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \ +
[committed] wwwdocs: Update reference for PCOMMIT instruction deprecation.
For once corporate webmasters who keep their house in order and added proper redirects. Pushed. Gerald --- htdocs/gcc-6/changes.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/gcc-6/changes.html b/htdocs/gcc-6/changes.html index 3713a394..e95aabbe 100644 --- a/htdocs/gcc-6/changes.html +++ b/htdocs/gcc-6/changes.html @@ -900,7 +900,7 @@ are not listed here). IA-32/x86-64 Support for the https://software.intel.com/en-us/blogs/2016/09/12/deprecate-pcommit-instruction";>deprecated + href="https://software.intel.com/content/www/us/en/develop/blogs/deprecate-pcommit-instruction.html";>deprecated pcommit instruction has been removed. -- 2.27.0
[committed] libstdc++: Move www.stroustrup.com to https
Pushed. libstdc++-v3/ChangeLog: 2020-08-02 Gerald Pfeifer * doc/xml/manual/using_exceptions.xml: Move www.stroustrup.com to https. * doc/html/manual/using_exceptions.html: Regenerate. --- libstdc++-v3/doc/html/manual/using_exceptions.html | 2 +- libstdc++-v3/doc/xml/manual/using_exceptions.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/doc/html/manual/using_exceptions.html b/libstdc++-v3/doc/html/manual/using_exceptions.html index 892795ee3b5..3ae0beaf2c6 100644 --- a/libstdc++-v3/doc/html/manual/using_exceptions.html +++ b/libstdc++-v3/doc/html/manual/using_exceptions.html @@ -299,7 +299,7 @@ is called. . Richard Henderson. GNU . - http://www.stroustrup.com/3rd_safe.pdf"; target="_top"> + https://www.stroustrup.com/3rd_safe.pdf"; target="_top"> Appendix E: Standard-Library Exception Safety . Bjarne Stroustrup. diff --git a/libstdc++-v3/doc/xml/manual/using_exceptions.xml b/libstdc++-v3/doc/xml/manual/using_exceptions.xml index c54e8cd0d95..485b269a59e 100644 --- a/libstdc++-v3/doc/xml/manual/using_exceptions.xml +++ b/libstdc++-v3/doc/xml/manual/using_exceptions.xml @@ -512,7 +512,7 @@ is called. http://www.w3.org/1999/xlink"; - xlink:href="http://www.stroustrup.com/3rd_safe.pdf";> + xlink:href="https://www.stroustrup.com/3rd_safe.pdf";> Appendix E: Standard-Library Exception Safety -- 2.27.0
[committed] wwwdocs: Remove reference to dead www.milepost.eu.
--- htdocs/git.html | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/git.html b/htdocs/git.html index f7f87a9d..905ce80e 100644 --- a/htdocs/git.html +++ b/htdocs/git.html @@ -1117,7 +1117,6 @@ merged. milepost-branch This branch is for GCC developments done in the Milepost project. - (http://www.milepost.eu";>http://www.milepost.eu). The branch is maintained by Mircea Namolaru mailto:namol...@il.ibm.com";>namol...@il.ibm.com. Patches should be marked with the tag [mpost] wwwdocs: in the -- 2.27.0
[committed] wwwdocs: help.github.com is now docs.github.com.
Pushed. Gerald --- htdocs/codingconventions.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/codingconventions.html b/htdocs/codingconventions.html index c0377315..162e1dda 100644 --- a/htdocs/codingconventions.html +++ b/htdocs/codingconventions.html @@ -145,7 +145,7 @@ a large batch of changes. supported formats: \t* a/b/c/file.c:, \t* a/b/c/file.c (function):, \t* a/b/c/file1.c, a/b/c/file2.c: changelog_file_comment - line that follows a changelog_file with description of changes in the file; must start with \t -co_authored_by - https://help.github.com/en/github/committing-changes-to-your-project/creating-a-commit-with-multiple-authors";>GitHub format for a Co-Authored-By +co_authored_by - https://docs.github.com/en/github/committing-changes-to-your-project/creating-a-commit-with-multiple-authors";>GitHub format for a Co-Authored-By Format rules -- 2.28.0
Re: [PATCH v4] genemit.c (main): split insn-emit.c for compiling parallelly
On Sat, Aug 01, 2020 at 07:02:07PM +0800, Jojo R wrote: > +insn-generated-split-num = $(shell nproc) nproc isn't portable, is not the same on every system, and can lead to a number of processes quadratic in the number of processors being launched (say, if someone does make -jK with K some fraction of the number of processors). (It is a bad choice anyway: nproc shows how many hardware threads are available, not how many it is a good idea to use for optimal performance; and it can be overridden by the user as well, via an environment variable). You need to split to some fixed number of parts, where that fixed number can depend on the target, but not on the host (or build machine) at all. Segher