Re: Fold more boolean expressions
Thanks a lot for the review, Richard! - I have updated the patch. - Had done a full "make check" with the second draft. - Did a "make check-gcc" with the final patch. - Both tests have the same tests failing, that always fail: g++.dg/pr80481.C g++.dg/pr83239.C Would be great if anyone willing could push it to origin/trunk! Index: gcc/match.pd === --- gcc/match.pd(revision 264170) +++ gcc/match.pd(working copy) @@ -92,7 +92,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) IFN_FMA IFN_FMS IFN_FNMA IFN_FNMS) (define_operator_list COND_TERNARY IFN_COND_FMA IFN_COND_FMS IFN_COND_FNMA IFN_COND_FNMS) - + /* As opposed to convert?, this still creates a single pattern, so it is not a suitable replacement for convert? in all cases. */ (match (nop_convert @0) @@ -106,7 +106,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && tree_nop_conversion_p (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (@0)) /* This one has to be last, or it shadows the others. */ (match (nop_convert @0) - @0) + @0) /* Transform likes of (char) ABS_EXPR <(int) x> into (char) ABSU_EXPR ABSU_EXPR returns unsigned absolute value of the operand and the operand @@ -285,7 +285,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) And not for _Fract types where we can't build 1. */ (if (!integer_zerop (@0) && !ALL_FRACT_MODE_P (TYPE_MODE (type))) { build_one_cst (type); })) - /* X / abs (X) is X < 0 ? -1 : 1. */ + /* X / abs (X) is X < 0 ? -1 : 1. */ (simplify (div:C @0 (abs @0)) (if (INTEGRAL_TYPE_P (type) @@ -921,6 +921,31 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bitop:c @0 (bit_not (bitop:cs @0 @1))) (bitop @0 (bit_not @1 +/* (~x & y) | ~(x | y) -> ~x */ +(simplify + (bit_ior:c (bit_and:c (bit_not@2 @0) @1) (bit_not (bit_ior:c @0 @1))) + @2) + +/* (x | y) ^ (x | ~y) -> ~x */ +(simplify + (bit_xor:c (bit_ior:c @0 @1) (bit_ior:c @0 (bit_not @1))) + (bit_not @0)) + +/* (x & y) | ~(x | y) -> ~(x ^ y) */ +(simplify + (bit_ior:c (bit_and:cs @0 @1) (bit_not:s (bit_ior:s @0 @1))) + (bit_not (bit_xor @0 @1))) + +/* (~x | y) ^ (x ^ y) -> x | ~y */ +(simplify + (bit_xor:c (bit_ior:cs (bit_not @0) @1) (bit_xor:s @0 @1)) + (bit_ior @0 (bit_not @1))) + +/* (x ^ y) | ~(x | y) -> ~(x & y) */ +(simplify + (bit_ior:c (bit_xor:cs @0 @1) (bit_not:s (bit_ior:s @0 @1))) + (bit_not (bit_and @0 @1))) + /* (x | y) & ~x -> y & ~x */ /* (x & y) | ~x -> y | ~x */ (for bitop (bit_and bit_ior) @@ -1131,7 +1156,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (tree_nop_conversion_p (type, TREE_TYPE (@0)) && tree_nop_conversion_p (type, TREE_TYPE (@1))) (mult (convert @0) (convert (negate @1) - + /* -(A + B) -> (-B) - A. */ (simplify (negate (plus:c @0 negate_expr_p@1)) @@ -3091,7 +3116,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (tree_int_cst_sgn (@1) < 0) (scmp @0 @2) (cmp @0 @2)) - + /* Simplify comparison of something with itself. For IEEE floating-point, we can only do some of these simplifications. */ (for cmp (eq ge le) @@ -3162,11 +3187,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) } tree newtype = (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type1) - ? TREE_TYPE (@0) : type1); + ? TREE_TYPE (@0) : type1); } (if (TYPE_PRECISION (TREE_TYPE (@2)) > TYPE_PRECISION (newtype)) (cmp (convert:newtype @0) (convert:newtype @1)) - + (simplify (cmp @0 REAL_CST@1) /* IEEE doesn't distinguish +0 and -0 in comparisons. */ @@ -3414,7 +3439,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (FTYPE) N == CST -> 0 (FTYPE) N != CST -> 1. */ (if (cmp == EQ_EXPR || cmp == NE_EXPR) -{ constant_boolean_node (cmp == NE_EXPR, type); }) +{ constant_boolean_node (cmp == NE_EXPR, type); }) /* Otherwise replace with sensible integer constant. */ (with { @@ -3656,7 +3681,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (cmp (bit_and@2 @0 integer_pow2p@1) @1) (icmp @2 { build_zero_cst (TREE_TYPE (@0)); }))) - + /* If we have (A & C) != 0 ? D : 0 where C and D are powers of 2, convert this into a shift followed by ANDing with D. */ (simplify @@ -3876,7 +3901,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (cmp == LE_EXPR) (ge (convert:st @0) { build_zero_cst (st); }) (lt (convert:st @0) { build_zero_cst (st); })) - + (for cmp (unordered ordered unlt unle ungt unge uneq ltgt) /* If the second operand is NaN, the result is constant. */ (simplify @@ -4530,7 +4555,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (wi::to_wide (@1) == -1) (rdiv { build_real (type, dconst1); } @0 -/* Narrowing of arithmetic and logical operations. +/* Narrowing of arithmetic and logical operations. These are conceptually similar to the transformations performed for the C/C++ front-ends by shorten_binary_op and shorten_co
Re: [PATCH v4 01/10] Initial TI PRU GCC port
On Thursday, 9/13/2018 13:02:21 EEST Richard Sandiford wrote: > Dimitar Dimitrov writes: > > +(define_insn > > "sub_impl_ > _zext_op2>" + [(set (match_operand:EQD 0 "register_operand" "=r,r,r") > > + (minus:EQD > > +(zero_extend:EQD > > + (match_operand:EQS0 1 "reg_or_ubyte_operand" "r,r,I")) > > +(zero_extend:EQD > > + (match_operand:EQS1 2 "reg_or_ubyte_operand" "r,I,r"] > > + "" > > + "@ > > + sub\\t%0, %1, %2 > > + sub\\t%0, %1, %2 > > + rsb\\t%0, %2, %1" > > + [(set_attr "type" "alu") > > + (set_attr "length" "4")]) > > By convention, subtraction patterns shouldn't accept constants for > operand 2. Constants should instead be subtracted using an addition > of the negative. Understood. I will remove second alternative. But I will leave the third one since it enables an important optimization: unsigned test(unsigned a) { return 10-a; } RTL: (insn 6 3 7 2 (set (reg:SI 152) (minus:SI (const_int 10 [0xa]) (reg/v:SI 151 [ a ]))) "test.c":430 -1 (nil)) Assembly: test: rsb r14, r14, 10 ret > > > +(define_constraint "I" > > + "An unsigned 8-bit constant." > > + (and (match_code "const_int") > > + (match_test "UBYTE_INT (ival)"))) > > As it stands this will reject QImode constants with the top bit set, > since const_ints are always stored in sign-extended form. E.g. QImode > 128 is stored as (const_int -128) rather than (const_int 128). > > Unfortunately this is difficult to fix in a clean way, since > const_ints don't store their mode (a long-standing wart) and unlike > predicates, constraints aren't given a mode from context. The best > way I can think of coping with it is: > > a) have a separate constraint for -128...127 > b) add a define_mode_attr that maps QI to the new constraint and >HI and SI to I > c) use etc. instead of I in the match_operands > > Similar comment for "J" and HImode, although you already have the > "N" as the corresponding signed constraint and so don't need a new one. Thank you. This strategy worked for QImode. I will include the changes in my next patch. Since PRU ALU operations do not have 16-bit constant operands, there is no need to add define_mode_attr for HImode. The "mov" pattern already handles the "N" [-32768, 32767] constraint. > > > > +;; Return true if OP is a text segment reference. > > +;; This is needed for program memory address expressions. Borrowed from > > AVR. +(define_predicate "text_segment_operand" > > + (match_code "code_label,label_ref,symbol_ref,plus,minus,const") > > +{ > > + switch (GET_CODE (op)) > > +{ > > +case CODE_LABEL: > > + return true; > > +case LABEL_REF : > > + return true; > > +case SYMBOL_REF : > > + return SYMBOL_REF_FUNCTION_P (op); > > +case PLUS : > > +case MINUS : > > + /* Assume canonical format of symbol + constant. > > +Fall through. */ > > +case CONST : > > + return text_segment_operand (XEXP (op, 0), VOIDmode); > > +default : > > + return false; > > +} > > +}) > > This probably comes from AVR, but: no spaces before ":". > > Bit surprised that we can get a CODE_LABEL rather than a LABEL_REF here. > Do you know if that triggers in practice, and if so where? Indeed, CODE_LABEL case is never reached. I'll leave gcc_unreachable here. > An IMO neater and slightly more robust way of writing the body is: > poly_int64 offset: > rtx base = strip_offset (op, &offset); > switch (GET_CODE (base)) > > { > > case LABEL_REF: > ...as above... > > case SYMBOL_REF: > ...as above... > > default: > return false; > > } > > with "plus" and "minus" not in the match_code list (since they should > always appear in consts if they really are text references). The "plus" and "minus" are needed when handling code labels as values. Take for example the following construct: int x = &&lab1 - &&lab0; lab1: ... lab2: My TARGET_ASM_INTEGER callback uses the text_segment_operand predicate. In the above case it is passed the following RTL expression: (minus:SI (label_ref/v:SI 20) (label_ref/v:SI 27)) I need to detect text labels so that I annotate them with %pmem: .4byte %pmem(.L4-(.L2)) Instead of the incorrect: .4byte .L3-(.L2) > > +;; Return true if OP is a load multiple operation. It is known to be a > > +;; PARALLEL and the first section will be tested. > > + > > +(define_special_predicate "load_multiple_operation" > > + (match_code "parallel") > > +{ > > + machine_mode elt_mode; > > + int count = XVECLEN (op, 0); > > + unsigned int dest_regno; > > + rtx src_addr; > > + int i, off; > > + > > + /* Perform a quick check so we don't blow up below. */ > > + if (GET_CODE (XVECEXP (op, 0, 0)) != SET > > + || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG > > + || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM) > > +return false; > > + >
[Patc, fortran] PR85603 - ICE with character array substring assignment
Yet another 'obvious' deferred character fix. Committed to trunk as r264502. Will backport in about ten days time. Paul 2018-09-22 Paul Thomas PR fortran/85603 * trans-array.c (gfc_alloc_allocatable_for_assignment): Test the charlen backend_decl before using the VAR_P macro. 2018-09-22 Paul Thomas PR fortran/85603 * gfortran.dg/deferred_character_23.f90 : New test. Index: gcc/fortran/trans-array.c === *** gcc/fortran/trans-array.c (revision 264486) --- gcc/fortran/trans-array.c (working copy) *** gfc_alloc_allocatable_for_assignment (gf *** 9950,9956 { if (expr2->ts.deferred) { ! if (VAR_P (expr2->ts.u.cl->backend_decl)) tmp = expr2->ts.u.cl->backend_decl; else tmp = rss->info->string_length; --- 9950,9957 { if (expr2->ts.deferred) { ! if (expr2->ts.u.cl->backend_decl ! && VAR_P (expr2->ts.u.cl->backend_decl)) tmp = expr2->ts.u.cl->backend_decl; else tmp = rss->info->string_length; Index: gcc/testsuite/gfortran.dg/deferred_character_23.f90 === *** gcc/testsuite/gfortran.dg/deferred_character_23.f90 (nonexistent) --- gcc/testsuite/gfortran.dg/deferred_character_23.f90 (working copy) *** *** 0 --- 1,22 + ! { dg-do run } + ! + ! Tests the fix for PR85603. + ! + ! Contributed by Walt Spector + ! + program strlen_bug + implicit none + + character(:), allocatable :: strings(:) + integer :: maxlen + + strings = [ character(32) :: & + 'short', & + 'somewhat longer' ] + maxlen = maxval (len_trim (strings)) + if (maxlen .ne. 15) stop 1 + strings = strings(:)(:maxlen) ! Used to ICE + if (any (strings .ne. ['short ','somewhat longer'])) stop 2 + + deallocate (strings) ! To check for memory leaks + end program
Re: [PATCH 08/14] Add D2 Testsuite files.
* Iain Buclaw: > This patch adds part of the D2 testsuite, which includes D source code > files that are considered compilable; files that are considered > uncompilable, but should not ICE; and files that should execute on > targets with crash or assertion failures. > > ftp://ftp.gdcproject.org/patches/v4/08-v4-d-testsuite.patch Can you delete the Project Gutenberg header and other references before committing? This should address any concerns about the licensing conditions of this text (because it's supposed to be public domain after that). Thanks, Florian
Re: [PATCH 08/14] Add D2 Testsuite files.
On 22 September 2018 at 15:23, Florian Weimer wrote: > * Iain Buclaw: > >> This patch adds part of the D2 testsuite, which includes D source code >> files that are considered compilable; files that are considered >> uncompilable, but should not ICE; and files that should execute on >> targets with crash or assertion failures. >> >> ftp://ftp.gdcproject.org/patches/v4/08-v4-d-testsuite.patch > > Can you delete the Project Gutenberg header and other references before > committing? This should address any concerns about the licensing > conditions of this text (because it's supposed to be public domain after > that). > I've committed it in upstream, so will propagate it here. Iain
[wwwdocs] Disable empty sections in gcc-8/porting_to.html
I noticed this when pointing someone to this document. Clearly it does not make much sense to have those empty sections which just carry a title but no content, so I commented those (both in case someone is adding material later, and also since this is going to be used as a template for the GCC 9 pages). Committed. Gerald Index: gcc-8/porting_to.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-8/porting_to.html,v retrieving revision 1.10 diff -u -r1.10 porting_to.html --- gcc-8/porting_to.html 1 Sep 2018 23:42:06 - 1.10 +++ gcc-8/porting_to.html 22 Sep 2018 15:47:11 - @@ -24,10 +24,14 @@ + + C++ language issues @@ -225,6 +229,11 @@ character(kind=c_char), bind(C) :: c(2) end module mod + + + +
[patch, fortran] Clobber some intent(out) variables on call
Hello world, the attached patch lets the middle-end know that variables associated with intent(out) arguments become undefined, by issuing an assignment to a special value (a "clobber") before entering the procedure. Originally, I had also planned to do so on entry to the procedure, see https://gcc.gnu.org/ml/fortran/2018-09/msg00148.html . This turned out to cause regressions; some details are outlined in the PR. Regression-tested. OK for trunk? Regards Thomas 2018-09-22 Thomas Koenig PR fortran/41453 * trans.h (gfc_conv_expr_reference): Add optional argument add_clobber to prototype. (gfc_conv_procedure_call): Set add_clobber argument to gfc_conv_procedure_reference to true for scalar, INTENT(OUT), non-pointer, non-allocatable, non-dummy variables whose type is neither BT_CHARACTER, BT_DERIVED or BT_CLASS, but only if the procedure is not elemental. * trans-expr.c (gfc_conv_procedure_reference): Add clobber statement before call if add_clobber is set. 2018-09-22 Thomas Koenig PR fortran/41453 * gfortran.dg/intent_optimize_2.f90: New test. Index: trans-expr.c === --- trans-expr.c (Revision 264487) +++ trans-expr.c (Arbeitskopie) @@ -5276,8 +5276,17 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * } } else - gfc_conv_expr_reference (&parmse, e); + { + bool add_clobber; + add_clobber = fsym && fsym->attr.intent == INTENT_OUT + && !fsym->attr.allocatable && !fsym->attr.pointer + && !e->symtree->n.sym->attr.pointer + && !e->symtree->n.sym->attr.dummy /* See PR 41453. */ + && e->ts.type != BT_CHARACTER && e->ts.type != BT_DERIVED + && e->ts.type != BT_CLASS && !sym->attr.elemental; + gfc_conv_expr_reference (&parmse, e, add_clobber); + } /* Catch base objects that are not variables. */ if (e->ts.type == BT_CLASS && e->expr_type != EXPR_VARIABLE @@ -8060,7 +8069,7 @@ gfc_conv_expr_type (gfc_se * se, gfc_expr * expr, values only. */ void -gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr) +gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr, bool add_clobber) { gfc_ss *ss; tree var; @@ -8100,6 +8109,16 @@ void gfc_add_block_to_block (&se->pre, &se->post); se->expr = var; } + else if (add_clobber) + { + tree clobber; + tree var; + /* FIXME: This fails if var is passed by reference, see PR + 41453. */ + var = expr->symtree->n.sym->backend_decl; + clobber = build_clobber (TREE_TYPE (var)); + gfc_add_modify (&se->pre, var, clobber); + } return; } Index: trans.h === --- trans.h (Revision 264487) +++ trans.h (Arbeitskopie) @@ -485,7 +485,8 @@ tree gfc_build_compare_string (tree, tree, tree, t void gfc_conv_expr (gfc_se * se, gfc_expr * expr); void gfc_conv_expr_val (gfc_se * se, gfc_expr * expr); void gfc_conv_expr_lhs (gfc_se * se, gfc_expr * expr); -void gfc_conv_expr_reference (gfc_se * se, gfc_expr *); +void gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr, + bool add_clobber = false); void gfc_conv_expr_type (gfc_se * se, gfc_expr *, tree); ! { dg-do compile } ! { dg-options "-O -fno-inline -fdump-tree-optimized -fdump-tree-original" } ! PR fortran/41453 ! Check that there is one clobber in the *.original tree, plus that ! the constant 123456789 has been removed tue to the INTENT(OUT). module x implicit none contains subroutine foo(a) integer, intent(out) :: a a = 42 end subroutine foo end module x program main use x implicit none integer :: a a = 12345689 call foo(a) print *,a end program main ! { dg-final { scan-tree-dump-times "123456789" 0 "optimized" } } ! { dg-final { scan-tree-dump-times "CLOBBER" 1 "original" } }
[patch, fortran] PR87318 gfortran.dg/dtio_1.f90 is invalid
Committed as OKed by Janus on bugzilla. Author: jvdelisle Date: Sat Sep 22 17:49:19 2018 New Revision: 264505 URL: https://gcc.gnu.org/viewcvs?rev=264505&root=gcc&view=rev Log: 2018-09-22 Jerry DeLisle PR fortran/87318 * gfortran.dg/dtio_1.f90: Update test to valid code. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/dtio_1.f90
Re: [patch, fortran] Clobber some intent(out) variables on call
Minor typo, see below. On 9/22/18 10:23 AM, Thomas Koenig wrote: Hello world, the attached patch lets the middle-end know that variables associated with intent(out) arguments become undefined, by issuing an assignment to a special value (a "clobber") before entering the procedure. Originally, I had also planned to do so on entry to the procedure, see https://gcc.gnu.org/ml/fortran/2018-09/msg00148.html . This turned out to cause regressions; some details are outlined in the PR. Regression-tested. OK for trunk? ! { dg-do compile } ! { dg-options "-O -fno-inline -fdump-tree-optimized -fdump-tree-original" } ! PR fortran/41453 ! Check that there is one clobber in the *.original tree, plus that ! the constant 123456789 has been removed tue to the INTENT(OUT). s/tue/due/ and program main use x implicit none integer :: a a = 12345689 < missing 7 digit? call foo(a) print *,a end program main Otherwise OK. Jerry
Re: [PATCH] Cleanup strcpy/stpcpy no nul warning code
Hi Jeff. I noticed that your commit r264328 introduced this: gcc/builtins.c: ... 579tree rhs1 = gimple_assign_rhs1 (stmt); 580tree_code code = gimple_assign_rhs_code (stmt); 581if (code == ADDR_EXPR 582&& TREE_CODE (TREE_OPERAND (rhs1, 0)) == ARRAY_REF) 583 rhs1 = rhs1; < here 584else if (code != POINTER_PLUS_EXPR) 585 return NULL_TREE; ... which is reported by LLVM as warning: gcc/builtins.c:583:2:Semantic Issue: explicitly assigning value of variable of type 'tree' (aka 'tree_node *') to itself: -Wself-assign Can you please fix that? Thanks, Martin
Re: [patch, fortran] Clobber some intent(out) variables on call
Hi Jerry, s/tue/due/ a = 12345689 < missing 7 digit? Yep, you're right. Corrected, committed as r264506. Regards Thomas
Re: [PATCH 02/25] Propagate address spaces to builtins.
On Sep 05 2018, wrote: > At present, pointers passed to builtin functions, including atomic operators, > are stripped of their address space properties. This doesn't seem to be > deliberate, it just omits to copy them. > > Not only that, but it forces pointer sizes to Pmode, which isn't appropriate > for all address spaces. > > This patch attempts to correct both issues. It works for GCN atomics and > GCN OpenACC gang-private variables. > > 2018-09-05 Andrew Stubbs > Julian Brown > > gcc/ > * builtins.c (get_builtin_sync_mem): Handle address spaces. That breaks aarch64 ILP32. ../../../../libgomp/ordered.c: In function 'GOMP_doacross_wait': ../../../../libgomp/ordered.c:486:1: internal compiler error: output_operand: invalid address mode 486 | } | ^ 0xf7219f aarch64_print_address_internal ../../gcc/config/aarch64/aarch64.c:7163 0xf7269b aarch64_print_operand_address ../../gcc/config/aarch64/aarch64.c:7267 0x8871ef output_address(machine_mode, rtx_def*) ../../gcc/final.c:4069 0xf7302b aarch64_print_operand ../../gcc/config/aarch64/aarch64.c:6952 0x887133 output_operand(rtx_def*, int) ../../gcc/final.c:4053 0x887b5b output_asm_insn(char const*, rtx_def**) ../../gcc/final.c:3965 0x889157 output_asm_insn(char const*, rtx_def**) ../../gcc/final.c:3842 0x889157 final_scan_insn_1 ../../gcc/final.c:3103 0x88984b final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*) ../../gcc/final.c:3149 0x889b1f final_1 ../../gcc/final.c:2019 0x88aaff rest_of_handle_final ../../gcc/final.c:4660 0x88aaff execute ../../gcc/final.c:4734 Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
[PATCH] Do array index calculations in gfc_array_index_type
It was recently noticed that for a few of the coarray intrinsics array index calculations were done in integer_type_node instead of gfc_array_index_type. This patch fixes this. Regtested on x86_64-pc-linux-gnu, Ok for trunk? gcc/fortran/ChangeLog: 2018-09-22 Janne Blomqvist * trans-expr.c (gfc_caf_get_image_index): Do array index calculations in gfc_array_index_type. * trans-intrinsic.c (conv_intrinsic_event_query): Likewise. * trans-stmt.c (gfc_trans_lock_unlock): Likewise. (gfc_trans_event_post_wait): Likewise. gcc/testsuite/ChangeLog: 2018-09-22 Janne Blomqvist * gfortran.dg/coarray_lib_alloc_4.f90: Fix scan patterns. * gfortran.dg/coarray_lock_7.f90: Likewise. --- gcc/fortran/trans-expr.c | 42 +-- gcc/fortran/trans-intrinsic.c | 18 gcc/fortran/trans-stmt.c | 34 +++ .../gfortran.dg/coarray_lib_alloc_4.f90 | 2 +- gcc/testsuite/gfortran.dg/coarray_lock_7.f90 | 12 +++--- 5 files changed, 48 insertions(+), 60 deletions(-) diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 1f94dcf11dd..bfda2bd746a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -2095,60 +2095,56 @@ gfc_caf_get_image_index (stmtblock_t *block, gfc_expr *e, tree desc) integer_zero_node); } - img_idx = integer_zero_node; - extent = integer_one_node; + img_idx = build_zero_cst (gfc_array_index_type); + extent = build_one_cst (gfc_array_index_type); if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))) for (i = ref->u.ar.dimen; i < ref->u.ar.dimen + ref->u.ar.codimen; i++) { gfc_init_se (&se, NULL); - gfc_conv_expr_type (&se, ref->u.ar.start[i], integer_type_node); + gfc_conv_expr_type (&se, ref->u.ar.start[i], gfc_array_index_type); gfc_add_block_to_block (block, &se.pre); lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]); tmp = fold_build2_loc (input_location, MINUS_EXPR, - integer_type_node, se.expr, - fold_convert(integer_type_node, lbound)); - tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node, + TREE_TYPE (lbound), se.expr, lbound); + tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp), extent, tmp); - img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node, - img_idx, tmp); + img_idx = fold_build2_loc (input_location, PLUS_EXPR, + TREE_TYPE (tmp), img_idx, tmp); if (i < ref->u.ar.dimen + ref->u.ar.codimen - 1) { ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]); tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL); - tmp = fold_convert (integer_type_node, tmp); extent = fold_build2_loc (input_location, MULT_EXPR, - integer_type_node, extent, tmp); + TREE_TYPE (tmp), extent, tmp); } } else for (i = ref->u.ar.dimen; i < ref->u.ar.dimen + ref->u.ar.codimen; i++) { gfc_init_se (&se, NULL); - gfc_conv_expr_type (&se, ref->u.ar.start[i], integer_type_node); + gfc_conv_expr_type (&se, ref->u.ar.start[i], gfc_array_index_type); gfc_add_block_to_block (block, &se.pre); lbound = GFC_TYPE_ARRAY_LBOUND (TREE_TYPE (desc), i); - lbound = fold_convert (integer_type_node, lbound); tmp = fold_build2_loc (input_location, MINUS_EXPR, - integer_type_node, se.expr, lbound); - tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node, + TREE_TYPE (lbound), se.expr, lbound); + tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp), extent, tmp); - img_idx = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node, + img_idx = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (tmp), img_idx, tmp); if (i < ref->u.ar.dimen + ref->u.ar.codimen - 1) { ubound = GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (desc), i); - ubound = fold_convert (integer_type_node, ubound); tmp = fold_build2_loc (input_location, MINUS_EXPR, - integer_type_node, ubound, lbound); - tmp = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node, - tmp, integer_one_node); + TREE_TYPE (ubound), ubound, lbound); + tmp = fold_build2_loc (input_location, PLUS_EXPR, TREE_TYPE (tmp), + tmp, build_one_cst (TREE_TYPE (tmp)
Re: [PATCH] Cleanup strcpy/stpcpy no nul warning code
On 9/22/18 8:32 PM, Martin Liška wrote: Hi Jeff. I noticed that your commit r264328 introduced this: gcc/builtins.c: ... 579 tree rhs1 = gimple_assign_rhs1 (stmt); 580 tree_code code = gimple_assign_rhs_code (stmt); 581 if (code == ADDR_EXPR 582 && TREE_CODE (TREE_OPERAND (rhs1, 0)) == ARRAY_REF) 583 rhs1 = rhs1; < here 584 else if (code != POINTER_PLUS_EXPR) 585 return NULL_TREE; ... which is reported by LLVM as warning: gcc/builtins.c:583:2:Semantic Issue: explicitly assigning value of variable of type 'tree' (aka 'tree_node *') to itself: -Wself-assign Can you please fix that? Thanks, Martin Apparently the same was already reported here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87387 Martin