Re: [PATCH] Builtins handling in IVOPT
On Thu, Nov 21, 2013 at 12:19 AM, Zdenek Dvorak wrote: > Hi, > >> This patch works on the intrinsic calls handling issue in IVOPT mentioned >> here: >> http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01295.html >> >> In find_interesting_uses_stmt, it changes >> >> arg = expr >> __builtin_xxx (arg) >> >> to >> >> arg = expr; >> tmp = addr_expr (mem_ref(arg)); >> __builtin_xxx (tmp, ...) > > this looks a bit confusing (and wasteful) to me. It would make more sense to > just record the argument as USE_ADDRESS and do the rewriting in > rewrite_use_address. > > Zdenek I updated the patch. The gimple changing part is now moved to rewrite_use_address. Add support for plain address expr in addition to reference expr in find_interesting_uses_address. bootstrap and testing is going on. 2013-11-22 Wei Mi * expr.c (expand_expr_addr_expr_1): Not to split TMR. (expand_expr_real_1): Ditto. * targhooks.c (default_builtin_has_mem_ref_p): Default builtin. * tree-ssa-loop-ivopts.c (builtin_has_mem_ref_p): New function. (rewrite_use_address): Add TMR for builtin. (find_interesting_uses_stmt): Special handling of builtins. * gimple-expr.c (is_gimple_address): Add handling of TMR. * gimple-expr.h (is_gimple_addressable): Ditto. * config/i386/i386.c (ix86_builtin_has_mem_ref_p): New target hook. (ix86_atomic_assign_expand_fenv): Ditto. (ix86_expand_special_args_builtin): Special handling of TMR for builtin. * target.def (builtin_has_mem_ref_p): New hook. * doc/tm.texi.in: Ditto. * doc/tm.texi: Generated. 2013-11-22 Wei Mi * gcc.dg/tree-ssa/ivopt_5.c: New test. Index: testsuite/gcc.dg/tree-ssa/ivopt_5.c === --- testsuite/gcc.dg/tree-ssa/ivopt_5.c (revision 0) +++ testsuite/gcc.dg/tree-ssa/ivopt_5.c (revision 0) @@ -0,0 +1,21 @@ +/* { dg-do compile { target {{ i?86-*-* x86_64-*-* } && lp64 } } } */ +/* { dg-options "-O2 -m64 -fdump-tree-ivopts-details" } */ + +/* Make sure only one iv is selected after IVOPT. */ + +#include +extern __m128i arr[], d[]; +void test (void) +{ +unsigned int b; +for (b = 0; b < 1000; b += 2) { + __m128i *p = (__m128i *)(&d[b]); + __m128i a = _mm_load_si128(&arr[4*b+3]); + __m128i v = _mm_loadu_si128(p); + v = _mm_xor_si128(v, a); + _mm_storeu_si128(p, v); +} +} + +/* { dg-final { scan-tree-dump-times "PHI stmt); tree base_hint = NULL_TREE; - tree ref, iv; + tree ref, iv, callee; bool ok; adjust_iv_update_pos (cand, use); @@ -6383,10 +6437,41 @@ rewrite_use_address (struct ivopts_data base_hint = var_at_stmt (data->current_loop, cand, use->stmt); iv = var_at_stmt (data->current_loop, cand, use->stmt); - ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff, - reference_alias_ptr_type (*use->op_p), - iv, base_hint, data->speed); - copy_ref_info (ref, *use->op_p); + + /* For builtin_call(addr_expr), change it to: + tmp = ADDR_EXPR(TMR(...)); + call (tmp); */ + if (is_gimple_call (use->stmt) + && (callee = gimple_call_fndecl (use->stmt)) + && is_builtin_fn (callee)) +{ + gimple g; + gimple_seq seq = NULL; + tree addr; + tree type = TREE_TYPE (TREE_TYPE (*use->op_p)); + location_t loc = gimple_location (use->stmt); + gimple_stmt_iterator gsi = gsi_for_stmt (use->stmt); + + ref = create_mem_ref (&bsi, type, &aff, + TREE_TYPE (*use->op_p), + iv, base_hint, data->speed); + addr = build1 (ADDR_EXPR, TREE_TYPE (*use->op_p), ref); + g = gimple_build_assign_with_ops (ADDR_EXPR, + make_ssa_name (TREE_TYPE (*use->op_p), NULL), + addr, NULL); + gimple_set_location (g, loc); + gimple_seq_add_stmt_without_update (&seq, g); + gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT); + + ref = gimple_assign_lhs (g); +} + else +{ + ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff, + reference_alias_ptr_type (*use->op_p), + iv, base_hint, data->speed); + copy_ref_info (ref, *use->op_p); +} *use->op_p = ref; } Index: config/i386/i386.c === --- config/i386/i386.c (revision 204792) +++ config/i386/i386.c (working copy) @@ -29639,6 +29639,50 @@ ix86_init_mmx_sse_builtins (void) } } +/* Return whether the Ith param of the BUILTIN_FUNCTION + is a memory reference. If I == -1, return whether the + BUILTIN_FUNCTION contains any memory reference param. */ + +static bool +ix86_builtin_has_mem_ref_p (int builtin_function, int i) +{ + switch ((enum ix86_builtins) builtin_function) +{ +/* LOAD. */ +case IX86_BUILTIN_LOADHPS: +case IX86_BUILTIN_L
[Patch, Fortran, committed] PR 59228: ICE-on-invalid with assumed type and ASYNCHRONOUS
Hi all, I have just committed a completely obvious one-line patch for an ICE-on-invalid problem: http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=205304 Cheers, Janus
Re: [PATCH] Support addsub/subadd as non-isomorphic operations for SLP vectorizer.
On Fri, 22 Nov 2013, Cong Hou wrote: IMHO, if PR56788 was fixed, you wouldn't have this issue, and if PR56788 doesn't get fixed, I'll post a patch to remove _mm_frcz_sd and the associated builtin, which would solve your issue as well. I agree. Then I will wait until your patch is merged to the trunk, otherwise my patch could not pass the test. It seems that I was wrong in the PR (I can't remember where I read that misleading info at the time), but Uros seems to be handling it just fine :-) -- Marc Glisse
[PATCH] pointer to integer conversion.
Hi, This is a one line patch to an unexpected behaviour noticed from ARM and x86 when testing the D frontend. --- import core.stdc.stdio; import core.stdc.stdint; void test(void* p) { uint64_t pl = cast(uint64_t)p; uint64_t p2 = cast(uint64_t)cast(int)p; int tmp = cast(int)p; uint64_t p3 = cast(uint64_t)tmp; printf("%llx %llx %llx\n", pl, p2, p3); } void main() { void* p = cast(void*)0xFFEECCAA; test(p); } -- Output is: ffeeccaa ffeeccaa ffeeccaa Expected: ffeeccaa ffeeccaa ffeeccaa Doing a quick conversion to C found that the same thing occurs with GCC too. This is the comment associated with the change in the function. /* Convert to an unsigned integer of the correct width first, and from there widen/truncate to the required type. Some targets support the coexistence of multiple valid pointer sizes, so fetch the one we need from the type. */ Currently, GCC is converting the expression to a signed integer instead of an unsigned one. Does a test for the testsuite need to be written for this? Regards, Iain. diff --git a/gcc/convert.c b/gcc/convert.c index 4cf5001..262d080 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -547,7 +547,7 @@ convert_to_integer (tree type, tree expr) from the type. */ expr = fold_build1 (CONVERT_EXPR, lang_hooks.types.type_for_size - (TYPE_PRECISION (intype), 0), + (TYPE_PRECISION (intype), 1), expr); return fold_convert (type, expr);
Privatize recalculate_side_effects
Tested on x86_64-suse-linux, applied on the mainline as obvious. 2013-11-23 Eric Botcazou * gimplify.h (recalculate_side_effects): Delete. * gimplify.c (recalculate_side_effects): Make static and add comment. ada/ * gcc-interface/trans.c (Loop_Statement_to_gnu): Set TREE_SIDE_EFFECTS on the conditional expression directly. -- Eric BotcazouIndex: gimplify.c === --- gimplify.c (revision 205300) +++ gimplify.c (working copy) @@ -1757,7 +1757,9 @@ gimplify_var_or_parm_decl (tree *expr_p) return GS_ALL_DONE; } -void +/* Recalculate the value of the TREE_SIDE_EFFECTS flag for T. */ + +static void recalculate_side_effects (tree t) { enum tree_code code = TREE_CODE (t); Index: gimplify.h === --- gimplify.h (revision 205300) +++ gimplify.h (working copy) @@ -64,7 +64,6 @@ extern tree unshare_expr (tree); extern tree unshare_expr_without_location (tree); extern tree voidify_wrapper_expr (tree, tree); extern tree build_and_jump (tree *); -extern void recalculate_side_effects (tree); extern enum gimplify_status gimplify_self_mod_expr (tree *, gimple_seq *, gimple_seq *, bool, tree); extern tree gimple_boolify (tree); Index: ada/gcc-interface/trans.c === --- ada/gcc-interface/trans.c (revision 205300) +++ ada/gcc-interface/trans.c (working copy) @@ -2808,8 +2808,8 @@ Loop_Statement_to_gnu (Node_Id gnat_node if (gnu_cond_expr) { COND_EXPR_THEN (gnu_cond_expr) = gnu_loop_stmt; + TREE_SIDE_EFFECTS (gnu_cond_expr) = 1; gnu_result = gnu_cond_expr; - recalculate_side_effects (gnu_cond_expr); } else gnu_result = gnu_loop_stmt;
Re: [PATCH] pointer to integer conversion.
Iain Buclaw writes: > Currently, GCC is converting the expression to a signed integer > instead of an unsigned one. Does a test for the testsuite need to be > written for this? The C standard makes this implementation-defined, and GCC defines it like this (*Note (gcc) Arrays and pointers implementation::): A cast from pointer to integer discards most-significant bits if the pointer representation is larger than the integer type, sign-extends(1) if the pointer representation is smaller than the integer type, otherwise the bits are unchanged. -- Footnotes -- (1) Future versions of GCC may zero-extend, or use a target-defined `ptr_extend' pattern. Do not rely on sign extension. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [PATCH] pointer to integer conversion.
On 23 November 2013 10:46, Andreas Schwab wrote: > Iain Buclaw writes: > >> Currently, GCC is converting the expression to a signed integer >> instead of an unsigned one. Does a test for the testsuite need to be >> written for this? > > The C standard makes this implementation-defined, and GCC defines it > like this (*Note (gcc) Arrays and pointers implementation::): > > A cast from pointer to integer discards most-significant bits if > the pointer representation is larger than the integer type, > sign-extends(1) if the pointer representation is smaller than the > integer type, otherwise the bits are unchanged. > -- Footnotes -- > > (1) Future versions of GCC may zero-extend, or use a target-defined > `ptr_extend' pattern. Do not rely on sign extension. > > Andreas. > OK, I've checked that document, and there's also a comment with it. Apparently someone spotted this before. @c ??? We've always claimed that pointers were unsigned entities. @c Shouldn't we therefore be doing zero-extension? If so, the bug @c is in convert_to_integer, where we call type_for_size and request @c a signed integral type. On the other hand, it might be most useful @c for the target if we extend according to POINTERS_EXTEND_UNSIGNED. So where does this leave languages that say that pointer to integer conversions are clearly defined? In any case, the comment in convert_to_integer is - in my eyes - wrong. Iain.
[PATCH, i386]: Fix PR56788, _mm_frcz_sd and _mm_frcz_ss ignore their second argument
Hello! Attached patch fixes PR56788, where _mm_frcz_{ss,sd} intrinsics ignored their second argument. As explained in the PR [1], gcc implements two-operand "vector-merge" form as documented in Microsoft's definition [2]. However, in contrast to other SSE scalar insns, the instruction itself clears upper bits to zero. There were a couple of problems: the builtin was declared as builtin with two input operands, but the number of input operands didn't correspond to referred insn pattern, leaving its second operand uninitialized. The intrinsic was also implemented without necessary movss/movsd fixup that would merge both its operands in a correct way. Please also note that the definition in clang is wrong. I didn't include any testcase in the patch, since I don't have access to XOP target. Hopefully someone from AMD will provide tests that are mysteriously missing from XOP testsuite. 2013-11-23 Uros Bizjak PR target/56788 * config/i386/i386.c (bdesc_multi_arg) : Declare as MULTI_ARG_1_SF instruction. : Decleare as MULTI_ARG_1_DF instruction. * config/i386/sse.md (*xop_vmfrcz2): Rename from *xop_vmfrcz_. * config/i386/xopintrin.h (_mm_frcz_ss): Use __builtin_ia32_movss to merge scalar result with __A. (_mm_frcz_sd): Use __builtin_ia32_movsd to merge scalar result with __A. Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}. The patch was committed to mainline SVN and will be committed to other release branches in a couple of days (hopefully with additional tests). [1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56788 [2] http://msdn.microsoft.com/en-us/library/vstudio/gg445126%28v=vs.100%29.aspx Uros. Index: i386.c === --- i386.c (revision 205300) +++ i386.c (working copy) @@ -29189,8 +29189,8 @@ { OPTION_MASK_ISA_XOP, CODE_FOR_xop_shlv8hi3, "__builtin_ia32_vpshlw", IX86_BUILTIN_VPSHLW, UNKNOWN, (int)MULTI_ARG_2_HI }, { OPTION_MASK_ISA_XOP, CODE_FOR_xop_shlv16qi3, "__builtin_ia32_vpshlb", IX86_BUILTIN_VPSHLB, UNKNOWN, (int)MULTI_ARG_2_QI }, - { OPTION_MASK_ISA_XOP, CODE_FOR_xop_vmfrczv4sf2, "__builtin_ia32_vfrczss", IX86_BUILTIN_VFRCZSS, UNKNOWN, (int)MULTI_ARG_2_SF }, - { OPTION_MASK_ISA_XOP, CODE_FOR_xop_vmfrczv2df2, "__builtin_ia32_vfrczsd", IX86_BUILTIN_VFRCZSD, UNKNOWN, (int)MULTI_ARG_2_DF }, + { OPTION_MASK_ISA_XOP, CODE_FOR_xop_vmfrczv4sf2, "__builtin_ia32_vfrczss", IX86_BUILTIN_VFRCZSS, UNKNOWN, (int)MULTI_ARG_1_SF }, + { OPTION_MASK_ISA_XOP, CODE_FOR_xop_vmfrczv2df2, "__builtin_ia32_vfrczsd", IX86_BUILTIN_VFRCZSD, UNKNOWN, (int)MULTI_ARG_1_DF }, { OPTION_MASK_ISA_XOP, CODE_FOR_xop_frczv4sf2, "__builtin_ia32_vfrczps", IX86_BUILTIN_VFRCZPS, UNKNOWN, (int)MULTI_ARG_1_SF }, { OPTION_MASK_ISA_XOP, CODE_FOR_xop_frczv2df2, "__builtin_ia32_vfrczpd", IX86_BUILTIN_VFRCZPD, UNKNOWN, (int)MULTI_ARG_1_DF }, { OPTION_MASK_ISA_XOP, CODE_FOR_xop_frczv8sf2, "__builtin_ia32_vfrczps256", IX86_BUILTIN_VFRCZPS256, UNKNOWN, (int)MULTI_ARG_1_SF2 }, Index: sse.md === --- sse.md (revision 205300) +++ sse.md (working copy) @@ -13193,7 +13193,6 @@ [(set_attr "type" "ssecvt1") (set_attr "mode" "")]) -;; scalar insns (define_expand "xop_vmfrcz2" [(set (match_operand:VF_128 0 "register_operand") (vec_merge:VF_128 @@ -13203,11 +13202,9 @@ (match_dup 3) (const_int 1)))] "TARGET_XOP" -{ - operands[3] = CONST0_RTX (mode); -}) + "operands[3] = CONST0_RTX (mode);") -(define_insn "*xop_vmfrcz_" +(define_insn "*xop_vmfrcz2" [(set (match_operand:VF_128 0 "register_operand" "=x") (vec_merge:VF_128 (unspec:VF_128 Index: xopintrin.h === --- xopintrin.h (revision 205300) +++ xopintrin.h (working copy) @@ -747,13 +747,17 @@ extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_frcz_ss (__m128 __A, __m128 __B) { - return (__m128) __builtin_ia32_vfrczss ((__v4sf)__A, (__v4sf)__B); + return (__m128) __builtin_ia32_movss ((__v4sf)__A, + (__v4sf) + __builtin_ia32_vfrczss ((__v4sf)__B)); } extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_frcz_sd (__m128d __A, __m128d __B) { - return (__m128d) __builtin_ia32_vfrczsd ((__v2df)__A, (__v2df)__B); + return (__m128d) __builtin_ia32_movsd ((__v2df)__A, +(__v2df) +__builtin_ia32_vfrczsd ((__v2df)__B)); } extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artific
Re: [PATCH] Fix up forwprop and improve reassoc (PR tree-optimization/59154)
Jakub Jelinek wrote: >Hi! > >This PR is about what I understood (can't reproduce, seems ltoish) >about reassoc now creating say _24 = (int) 0; with _Bool 0, and >forwprop ICEing on that. > >The patch fixes forwprop not to ICE on it (I think we don't require >the IL to be always folded), and reassoc not to create it in this case, >IMHO either hunk could fix the issue but haven't verified that. > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok. Thanks, Richard. >2013-11-22 Jakub Jelinek > > PR tree-optimization/59154 > * tree-ssa-reassoc.c (maybe_optimize_range_tests): When changing > rhs1 of a cast and new_op is invariant, fold_convert it. > * tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Only call > simplify_conversion_from_bitmask if rhs1 is a SSA_NAME. > >--- gcc/tree-ssa-reassoc.c.jj 2013-11-22 13:15:55.0 +0100 >+++ gcc/tree-ssa-reassoc.c 2013-11-22 17:53:21.501637844 +0100 >@@ -2930,9 +2930,15 @@ maybe_optimize_range_tests (gimple stmt) > tree new_lhs = make_ssa_name (TREE_TYPE (lhs), NULL); > enum tree_code rhs_code > = gimple_assign_rhs_code (cast_stmt); >-gimple g >- = gimple_build_assign_with_ops (rhs_code, new_lhs, >- new_op, NULL_TREE); >+gimple g; >+if (is_gimple_min_invariant (new_op)) >+ { >+new_op = fold_convert (TREE_TYPE (lhs), new_op); >+g = gimple_build_assign (new_lhs, new_op); >+ } >+else >+ g = gimple_build_assign_with_ops (rhs_code, new_lhs, >+new_op, NULL_TREE); > gimple_stmt_iterator gsi = gsi_for_stmt (cast_stmt); > gimple_set_uid (g, gimple_uid (cast_stmt)); > gimple_set_visited (g, true); >--- gcc/tree-ssa-forwprop.c.jj 2013-11-22 13:15:55.0 +0100 >+++ gcc/tree-ssa-forwprop.c2013-11-22 16:05:38.823559573 +0100 >@@ -3542,7 +3542,8 @@ ssa_forward_propagate_and_combine (void) > { > tree outer_type = TREE_TYPE (gimple_assign_lhs (stmt)); > tree inner_type = TREE_TYPE (gimple_assign_rhs1 (stmt)); >- if (INTEGRAL_TYPE_P (outer_type) >+ if (TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME >+ && INTEGRAL_TYPE_P (outer_type) > && INTEGRAL_TYPE_P (inner_type) > && (TYPE_PRECISION (outer_type) > <= TYPE_PRECISION (inner_type))) > > Jakub
gcc/invoke.texi: Add missing @opindex
While looking at the index for -fsanitize=, I found out that it – and many other options – lack the @opindex. Attached is an attempted to add the missing ones. OK? Tobias diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 0708836..b41c44c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1500,6 +1500,7 @@ This invokes all subprograms of @command{gcc} under @samp{gdb --args cc1 @dots{}}. @item -fplugin=@var{name}.so +@opindex fplugin Load the plugin code in file @var{name}.so, assumed to be a shared object to be dlopen'd by the compiler. The base name of the shared object file is used to identify the plugin for the @@ -1509,15 +1510,18 @@ Each plugin should define the callback functions specified in the Plugins API. @item -fplugin-arg-@var{name}-@var{key}=@var{value} +@opindex fplugin-arg Define an argument called @var{key} with a value of @var{value} for the plugin called @var{name}. @item -fdump-ada-spec@r{[}-slim@r{]} +@opindex fdump-ada-spec For C and C++ source and include files, generate corresponding Ada specs. @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn, GNAT User's Guide}, which provides detailed documentation on this feature. @item -fdump-go-spec=@var{file} +@opindex fdump-go-spec For input files in any language, generate corresponding Go declarations in @var{file}. This generates Go @code{const}, @code{type}, @code{var}, and @code{func} declarations which may be a @@ -1751,6 +1755,7 @@ arguments followed by their declarations is also provided, inside comments, after the declaration. @item -fallow-parameterless-variadic-functions +@opindex fallow-parameterless-variadic-functions Accept variadic functions without named parameters. Although it is possible to define such a function, this is not very @@ -2392,7 +2397,7 @@ Note: This feature APPENDS data to the log file. If you want a fresh log file, be sure to delete any existing one. @item -fvtv-counts -@opindex (fvtv-counts) +@opindex fvtv-counts This is a debugging flag. When used in conjunction with @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this causes the compiler to keep track of the total number of virtual calls @@ -3490,6 +3495,8 @@ Options,,Options Controlling C Dialect}. @table @gcctabopt @item -Wformat=1 @itemx -Wformat +@opindex Wformat +@opindex Wformat=1 Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since @option{-Wformat} also checks for null format arguments for several @@ -3528,6 +3535,7 @@ The C standard specifies that zero-length formats are allowed. @item -Wformat=2 +@opindex Wformat=2 Enable @option{-Wformat} plus additional format checks. Currently equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security -Wformat-y2k}. @@ -5258,18 +5266,21 @@ many times it is given. This is mainly intended to be used with @option{-fcompare-debug}. @item -fsanitize=address +@opindex fsanitize= Enable AddressSanitizer, a fast memory error detector. Memory access instructions will be instrumented to detect out-of-bounds and use-after-free bugs. See @uref{http://code.google.com/p/address-sanitizer/} for more details. @item -fsanitize=thread +@opindex fsanitize=thread Enable ThreadSanitizer, a fast data race detector. Memory access instructions will be instrumented to detect data race bugs. See @uref{http://code.google.com/p/data-race-test/wiki/ThreadSanitizer} for more details. @item -fsanitize=leak +@opindex fsanitize=leak Enable LeakSanitizer, a memory leak detector. This option only matters for linking of executables and if neither @option{-fsanitize=address} nor @option{-fsanitize=thread} is used. In that @@ -5277,6 +5288,7 @@ case it will link the executable against a library that overrides @code{malloc} and other allocator functions. @item -fsanitize=undefined +@opindex fsanitize=undefined Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. Various computations will be instrumented to detect undefined behavior at runtime. Current suboptions are: @@ -5284,22 +5296,26 @@ at runtime. Current suboptions are: @itemize @bullet @item @option{-fsanitize=shift} +@opindex fsanitize=shift This option enables checking that the result of a shift operation is not undefined. Note that what exactly is considered undefined differs slightly between C and C++, as well as between ISO C90 and C99, etc. @item @option{-fsanitize=integer-divide-by-zero} +@opindex fsanitize=integer-divide-by-zero Detect integer division by zero as well as @code{INT_MIN / -1} division. @item @option{-fsanitize=unreachable} +@opindex fsanitize=unreachable With this option, the compiler will turn the @code{__builtin_unreachable} call into a diagnostics message call instead. When reaching the @code{__builtin_unreachable} call, the behavior is undefined. @item @option{-fsanitize=vla-bound} +@o
Re: [RFC][LIBGCC][0 of 2] 64 bit divide implementation for processor without hw divide instruction
This appears to be adding a new libgcc target macro; please document it in tm.texi.in and regenerate tm.texi. -- Joseph S. Myers jos...@codesourcery.com
Re: [RFC][LIBGCC][1 of 2] 64 bit divide implementation for processor without hw divide instruction
Kugan writes: > This RFC patch series implements a simple align divisor shift dividend > method. > > Regression tested on arm-none-linux-gnueabi with no issues. > > OK? > > Thanks, > Kugan > > +2013-11-22 Kugan Vivekanandarajah > + > + * libgcc/libgcc2.c (__udivmoddi4): Define new implementation when > + HAVE_NO_HW_DIVIDE is defined, for processors without any divide > + instructions. The code looks fine to me. You should document HAVE_NO_HW_DIVIDE in gcc/doc/tm.texi in the Library Calls section. The macro should probably be something like TARGET_HAS_NO_HW_DIVIDE. Ian
[PATCH, committed] AIX uninitialized data alignment
While working with Uli on the PPC64 LE ELFv2 implementation, we discovered that one of the changes to argument passing introduced new regressions in the struct-layout part of the testsuite, which should not have changed. Uli tracked this down to a change in the mode for multi-register parameters that caused a change in the traceback tables that changed the size of the text section that changed the placement and alignment of the data section. The struct-layout tests were failing in the initial alignment verification. The tests use a type v16sf, which requires alignment of 512. GCC aligns the default ".data" CSECT on AIX to 64 bits and the alignment is not automatically increased to the largest alignment specified within the CSECT. GCC specified alignment of 512 for the symbol, but the overall CSECT was less-strictly aligned, so the alignment was not satisfied and some tests passed due to luck. The tests only failed when compiled with C++ and not C. GCC annotates uninitialized C variables as COMMON, but G++ does not. The AIX XCOFF common section adopts the alignment of the strictest symbol. AIX XCOFF was intended to always use the equivalent of GCC -fdata-sections where each symbol is placed in its own CSECT. This patch places variables more strictly aligned than BIGGEST_ALIGNMENT into their own, named sections to achieve the necessary alignment without increasing the alignment of the entire, default data CSECT. With this change, all struct-layout tests pass on AIX. Bootstrapped on powerpc-ibm-aix7.1.0.0. Thanks, David * config/rs6000/rs6000.c (IN_NAMED_SECTION): New macro. (rs6000_xcoff_select_section): Place decls with stricter alignment into named sections. (rs6000_xcoff_unique_section): Allow unique sections for uninitialized data with strict alignment. Index: rs6000.c === --- rs6000.c(revision 205307) +++ rs6000.c(working copy) @@ -28588,10 +28588,23 @@ name, suffix[smclass], flags & SECTION_ENTSIZE); } +#define IN_NAMED_SECTION(DECL) \ + ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \ + && DECL_SECTION_NAME (DECL) != NULL_TREE) + static section * rs6000_xcoff_select_section (tree decl, int reloc, - unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) + unsigned HOST_WIDE_INT align) { + /* Place variables with alignment stricter than BIGGEST_ALIGNMENT into + named section. */ + if (align > BIGGEST_ALIGNMENT) +{ + resolve_unique_section (decl, reloc, true); + if (IN_NAMED_SECTION (decl)) +return get_named_section (decl, NULL, reloc); +} + if (decl_readonly_section (decl, reloc)) { if (TREE_PUBLIC (decl)) @@ -28629,10 +28642,12 @@ { const char *name; - /* Use select_section for private and uninitialized data. */ + /* Use select_section for private data and uninitialized data with + alignment <= BIGGEST_ALIGNMENT. */ if (!TREE_PUBLIC (decl) || DECL_COMMON (decl) - || DECL_INITIAL (decl) == NULL_TREE + || (DECL_INITIAL (decl) == NULL_TREE + && DECL_ALIGN (decl) <= BIGGEST_ALIGNMENT) || DECL_INITIAL (decl) == error_mark_node || (flag_zero_initialized_in_bss && initializer_zerop (DECL_INITIAL (decl
Re: [fortran, patch] Add Fortran 2003 IEEE intrinsic modules
Hi Uros! Thanks for lookin at this. I am a real newcomer to 387, and it took me a long time perusing the Intel doc, as well as glibc sources, to come up with that. The “reference” implementation of these FPU functions, the one I am confident in, is that in config/fpu-glibc.h: i.e., the functions in config/fpu-i387.h should have the same effect that config/fpu-glibc.h on i386/x86_64 hardware. I’ll reply to your comments, but in some cases I was not sure exactly what you were saying… thanks for your help, and patience! > @@ -136,16 +165,54 @@ set_fpu (void) > __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse)); > > /* The SSE exception masks are shifted by 7 bits. */ > - cw_sse |= _FPU_MASK_ALL << 7; > - cw_sse &= ~(excepts << 7); > - > - /* Clear stalled exception flags. */ > - cw_sse &= ~_FPU_EX_ALL; > > You have to clear stalled SSE exceptions here. Their flags are in LSB > bits, so their position is different than the position of exception > mask bits in the control word. So, if I get you right, I should restore the "cw_sse &= ~_FPU_EX_ALL”, which I had mistakenly removed. But I’m looking at glibc-2.18/sysdeps/x86_64/fpu/feenablxcpt.c and fedisblxcpt.c, and it doesn’t seem to be done there. > + __asm__ __volatile__ ("fnstenv\t%0" : "=m" (*&temp)); > [...] > + __asm__ __volatile__ ("fldenv\t%0" : : "m" (*&temp)); > > Why do you need "*&" here? I don’t. > fldenv will also trigger exceptions with set flags on the next x87 FP insn ... > > +__asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse)); > + > +cw_sse &= ~exc_clr; > +cw_sse |= exc_set; > + > +__asm__ __volatile__ ("%vldmxcsr\t%0" : : "m" (cw_sse)); > > ... and ldmxcsr won't trigger exceptions, neither with SSE insn. > Please see Intel documentation on FP exceptions. This code should be equivalent to glibc’s: feclearexcept (exc_clr); feraiseexcept (exc_set); So yes, raising an exception is the except action. I’ve attached a new version of config/fpu-387.h, along with the glibc version (fpu-glibc.h). I’d be glad if you could review it. Thanks a lot! FX fpu-387.h Description: Binary data fpu-glibc.h Description: Binary data
Re: [PATCH] pointer to integer conversion.
On Sat, Nov 23, 2013 at 4:38 AM, Iain Buclaw wrote: > > OK, I've checked that document, and there's also a comment with it. > Apparently someone spotted this before. > > @c ??? We've always claimed that pointers were unsigned entities. > @c Shouldn't we therefore be doing zero-extension? If so, the bug > @c is in convert_to_integer, where we call type_for_size and request > @c a signed integral type. On the other hand, it might be most useful > @c for the target if we extend according to POINTERS_EXTEND_UNSIGNED. > > > So where does this leave languages that say that pointer to integer > conversions are clearly defined? The language frontend needs to do the right thing. In this case it looks like the right thing is to convert the integer to the language equivalent of uintptr_t before converting it to a pointer type. Other than possibly from the frontend function convert, a language frontend really has no business calling convert_to_integer at all. The function implements C semantics. And the whole business of the middle-end calling the frontend function convert is broken anyhow. Ian
C++ PATCH #2 for c++/58868
The earlier patch fixed the testcase, but it seemed to me that build_aggr_init still ought to do the right thing here. Tested x86_64-pc-linux-gnu, applying to trunk. commit cfde6c1e56ecbbd098de20451cc718cedeb8dffd Author: Jason Merrill Date: Wed Nov 6 09:33:24 2013 -0500 PR c++/58868 * init.c (build_aggr_init): Don't clobber the type of init if we got an INIT_EXPR back from build_vec_init. (build_vec_init): Do digest_init on trivial initialization. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index fd43a4f..d7b0643 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1508,7 +1508,8 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) TREE_READONLY (exp) = was_const; TREE_THIS_VOLATILE (exp) = was_volatile; TREE_TYPE (exp) = type; - if (init) + /* Restore the type of init unless it was used directly. */ + if (init && TREE_CODE (stmt_expr) != INIT_EXPR) TREE_TYPE (init) = itype; return stmt_expr; } @@ -3421,6 +3422,8 @@ build_vec_init (tree base, tree maxindex, tree init, brace-enclosed initializers. In this case, digest_init and store_constructor will handle the semantics for us. */ + if (BRACE_ENCLOSED_INITIALIZER_P (init)) + init = digest_init (atype, init, complain); stmt_expr = build2 (INIT_EXPR, atype, base, init); if (length_check) stmt_expr = build3 (COND_EXPR, atype, length_check,
Re: [c++] Fix pr58525
On 10/07/2013 09:38 AM, Alexander Ivchenko wrote: __cxa_throw_bad_array_new_length and __cxa_throw_bad_array_new_length are generated with -fno-exceptions right now. The attached patch fixes that problem. Bootstrapped and regtested on x86_64-unknown-linux-gnu: Thanks. The underlying code has changed a bit since you sent this, so here's the version I'm applying: commit 3cf869f3399cc126ee91ecc37a19a331d277291a Author: Alexander Ivchenko Date: Mon Oct 7 17:38:48 2013 +0400 PR c++/58525 * call.c (build_operator_new_call): Add flag_exceptions check. * decl.c (compute_array_index_type): Ditto. * init.c (build_new_1): Ditto. (build_vec_init): Ditto. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 935e011..6a4386e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3956,7 +3956,7 @@ build_operator_new_call (tree fnname, vec **args, if (size_check != NULL_TREE) { tree errval = TYPE_MAX_VALUE (sizetype); - if (cxx_dialect >= cxx11) + if (cxx_dialect >= cxx11 && flag_exceptions) errval = throw_bad_array_new_length (); *size = fold_build3 (COND_EXPR, sizetype, size_check, original_size, errval); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 40a9a8c..889c203 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8393,7 +8393,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) stabilize_vla_size (itype); - if (cxx_dialect >= cxx1y) + if (cxx_dialect >= cxx1y && flag_exceptions) { /* If the VLA bound is larger than half the address space, or less than zero, throw std::bad_array_length. */ diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 0263050..1e6e691 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2529,7 +2529,7 @@ build_new_1 (vec **placement, tree type, tree nelts, } /* Perform the overflow check. */ tree errval = TYPE_MAX_VALUE (sizetype); - if (cxx_dialect >= cxx11) + if (cxx_dialect >= cxx11 && flag_exceptions) errval = throw_bad_array_new_length (); if (outer_nelts_check != NULL_TREE) size = fold_build3 (COND_EXPR, sizetype, outer_nelts_check, @@ -3399,7 +3399,8 @@ build_vec_init (tree base, tree maxindex, tree init, is big enough for all the initializers. */ if (init && TREE_CODE (init) == CONSTRUCTOR && CONSTRUCTOR_NELTS (init) > 0 - && !TREE_CONSTANT (maxindex)) + && !TREE_CONSTANT (maxindex) + && flag_exceptions) length_check = fold_build2 (LT_EXPR, boolean_type_node, maxindex, size_int (CONSTRUCTOR_NELTS (init) - 1));
Fix thinko in expand_builtin_cilk_detach
The 'worker' field has pointer type tree worker_type = lang_hooks.types.make_type (RECORD_TYPE); tree worker_ptr = build_pointer_type (worker_type); [...] tree worker = add_field ("worker", worker_ptr, parent); so it needs to be dereferenced before being subject to COMPONENT_REF. Tested on x86_64-suse-linux, applied on the mainline as obvious. 2013-11-23 Eric Botcazou * cilk-common.c (expand_builtin_cilk_detach): Dereference worker. -- Eric BotcazouIndex: cilk-common.c === --- cilk-common.c (revision 205300) +++ cilk-common.c (working copy) @@ -328,7 +328,7 @@ expand_builtin_cilk_detach (tree exp) tree parent = cilk_dot (fptr, CILK_TI_FRAME_PARENT, 0); tree worker = cilk_dot (fptr, CILK_TI_FRAME_WORKER, 0); - tree tail = cilk_dot (worker, CILK_TI_WORKER_TAIL, 1); + tree tail = cilk_arrow (worker, CILK_TI_WORKER_TAIL, 1); rtx wreg = expand_expr (worker, NULL_RTX, Pmode, EXPAND_NORMAL); if (GET_CODE (wreg) != REG)
Re: [fortran, patch] Add Fortran 2003 IEEE intrinsic modules
On Sat, Nov 23, 2013 at 4:30 PM, FX wrote: > Thanks for lookin at this. I am a real newcomer to 387, and it took me a long > time perusing the Intel doc, as well as glibc sources, to come up with that. > The “reference” implementation of these FPU functions, the one I am confident > in, is that in config/fpu-glibc.h: i.e., the functions in config/fpu-i387.h > should have the same effect that config/fpu-glibc.h on i386/x86_64 hardware. > > I’ll reply to your comments, but in some cases I was not sure exactly what > you were saying… thanks for your help, and patience! > > >> @@ -136,16 +165,54 @@ set_fpu (void) >> __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse)); >> >> /* The SSE exception masks are shifted by 7 bits. */ >> - cw_sse |= _FPU_MASK_ALL << 7; >> - cw_sse &= ~(excepts << 7); >> - >> - /* Clear stalled exception flags. */ >> - cw_sse &= ~_FPU_EX_ALL; >> >> You have to clear stalled SSE exceptions here. Their flags are in LSB >> bits, so their position is different than the position of exception >> mask bits in the control word. > > So, if I get you right, I should restore the "cw_sse &= ~_FPU_EX_ALL”, which > I had mistakenly removed. > But I’m looking at glibc-2.18/sysdeps/x86_64/fpu/feenablxcpt.c and > fedisblxcpt.c, and it doesn’t seem to be done there. The idea was that since control word is changed, status word should be cleared. But since stalled flags won't raise an exception, it actually doesn't matter, although it looks nicer in a debugger. However, if you remove SSE clear, you should also remove fnclex from x87 code. >> fldenv will also trigger exceptions with set flags on the next x87 FP insn >> ... >> >> +__asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse)); >> + >> +cw_sse &= ~exc_clr; >> +cw_sse |= exc_set; >> + >> +__asm__ __volatile__ ("%vldmxcsr\t%0" : : "m" (cw_sse)); >> >> ... and ldmxcsr won't trigger exceptions, neither with SSE insn. >> Please see Intel documentation on FP exceptions. > > This code should be equivalent to glibc’s: > > feclearexcept (exc_clr); > feraiseexcept (exc_set); > > So yes, raising an exception is the except action. I’ve attached a new > version of config/fpu-387.h, along with the glibc version (fpu-glibc.h). I’d > be glad if you could review it. Hm, I don't see the feraiseexcept part in your patch. As said in other reply, you can use the code from libatomic/config/x86/fenv.h. This source also handles FE_DENORM. Uros.
Re: [fortran, patch] Add Fortran 2003 IEEE intrinsic modules
On Sat, Nov 23, 2013 at 5:48 PM, Uros Bizjak wrote: >> Thanks for lookin at this. I am a real newcomer to 387, and it took me a >> long time perusing the Intel doc, as well as glibc sources, to come up with >> that. The “reference” implementation of these FPU functions, the one I am >> confident in, is that in config/fpu-glibc.h: i.e., the functions in >> config/fpu-i387.h should have the same effect that config/fpu-glibc.h on >> i386/x86_64 hardware. >> >> I’ll reply to your comments, but in some cases I was not sure exactly what >> you were saying… thanks for your help, and patience! >> >> >>> @@ -136,16 +165,54 @@ set_fpu (void) >>> __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse)); >>> >>> /* The SSE exception masks are shifted by 7 bits. */ >>> - cw_sse |= _FPU_MASK_ALL << 7; >>> - cw_sse &= ~(excepts << 7); >>> - >>> - /* Clear stalled exception flags. */ >>> - cw_sse &= ~_FPU_EX_ALL; >>> >>> You have to clear stalled SSE exceptions here. Their flags are in LSB >>> bits, so their position is different than the position of exception >>> mask bits in the control word. >> >> So, if I get you right, I should restore the "cw_sse &= ~_FPU_EX_ALL”, which >> I had mistakenly removed. >> But I’m looking at glibc-2.18/sysdeps/x86_64/fpu/feenablxcpt.c and >> fedisblxcpt.c, and it doesn’t seem to be done there. > > The idea was that since control word is changed, status word should be > cleared. But since stalled flags won't raise an exception, it actually > doesn't matter, although it looks nicer in a debugger. However, if you > remove SSE clear, you should also remove fnclex from x87 code. Actually, I was wrong. You have to clear stalled flags. Please consider following test: --cut here-- #include int main(void) { unsigned short cw; /* Raise FE_DIVBYZERO */ volatile float d = 0.0f; volatile float r = 1.0f / d; #if GLIBC feenableexcept (FE_DIVBYZERO); #else __asm__ __volatile__ ("fstcw\t%0" : "=m" (cw)); cw |= FE_ALL_EXCEPT; cw &= ~FE_DIVBYZERO; __asm__ __volatile__ ("fnclex\n\tfldcw\t%0" : : "m" (cw)); #endif /* Raise FE_INEXACT */ d = 3.0f; r = 1.0f / d; return 0; } --cut here-- The test (compiled with -m32 or -mfpmath=387 due to x87 assembly, linked against -lm will generate erroneous exception when -DGLIBC is added to compile flags. So, it looks to me that glibc has a bug here. Oh, and contrary to claims in glibc sources, the above test raises only FE_INEXACT exception. I have added Joseph to Cc due to glibc issues. Uros.
Re: [fortran, patch] Add Fortran 2003 IEEE intrinsic modules
On Sat, Nov 23, 2013 at 6:24 PM, Uros Bizjak wrote: > On Sat, Nov 23, 2013 at 5:48 PM, Uros Bizjak wrote: > >>> Thanks for lookin at this. I am a real newcomer to 387, and it took me a >>> long time perusing the Intel doc, as well as glibc sources, to come up with >>> that. The “reference” implementation of these FPU functions, the one I am >>> confident in, is that in config/fpu-glibc.h: i.e., the functions in >>> config/fpu-i387.h should have the same effect that config/fpu-glibc.h on >>> i386/x86_64 hardware. >>> >>> I’ll reply to your comments, but in some cases I was not sure exactly what >>> you were saying… thanks for your help, and patience! >>> >>> @@ -136,16 +165,54 @@ set_fpu (void) __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse)); /* The SSE exception masks are shifted by 7 bits. */ - cw_sse |= _FPU_MASK_ALL << 7; - cw_sse &= ~(excepts << 7); - - /* Clear stalled exception flags. */ - cw_sse &= ~_FPU_EX_ALL; You have to clear stalled SSE exceptions here. Their flags are in LSB bits, so their position is different than the position of exception mask bits in the control word. >>> >>> So, if I get you right, I should restore the "cw_sse &= ~_FPU_EX_ALL”, >>> which I had mistakenly removed. >>> But I’m looking at glibc-2.18/sysdeps/x86_64/fpu/feenablxcpt.c and >>> fedisblxcpt.c, and it doesn’t seem to be done there. >> >> The idea was that since control word is changed, status word should be >> cleared. But since stalled flags won't raise an exception, it actually >> doesn't matter, although it looks nicer in a debugger. However, if you >> remove SSE clear, you should also remove fnclex from x87 code. > > Actually, I was wrong. You have to clear stalled flags. > > Please consider following test: > > --cut here-- > #include > > int main(void) > { > unsigned short cw; > > /* Raise FE_DIVBYZERO */ > volatile float d = 0.0f; > volatile float r = 1.0f / d; > > #if GLIBC > feenableexcept (FE_DIVBYZERO); > #else > __asm__ __volatile__ ("fstcw\t%0" : "=m" (cw)); > > cw |= FE_ALL_EXCEPT; > cw &= ~FE_DIVBYZERO; > > __asm__ __volatile__ ("fnclex\n\tfldcw\t%0" : : "m" (cw)); > #endif > > /* Raise FE_INEXACT */ > d = 3.0f; > r = 1.0f / d; > > return 0; > } > > --cut here-- > > The test (compiled with -m32 or -mfpmath=387 due to x87 assembly, > linked against -lm will generate erroneous exception when -DGLIBC is > added to compile flags. > > So, it looks to me that glibc has a bug here. Oh, and contrary to > claims in glibc sources, the above test raises only FE_INEXACT > exception. > > I have added Joseph to Cc due to glibc issues. Now glibc Bug 16209 [1] [1] https://sourceware.org/bugzilla/show_bug.cgi?id=16209 Uros.
Re: [PATCH] Builtins handling in IVOPT
bootstrap and regression of the updated patch pass. On Sat, Nov 23, 2013 at 12:05 AM, Wei Mi wrote: > On Thu, Nov 21, 2013 at 12:19 AM, Zdenek Dvorak > wrote: >> Hi, >> >>> This patch works on the intrinsic calls handling issue in IVOPT mentioned >>> here: >>> http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01295.html >>> >>> In find_interesting_uses_stmt, it changes >>> >>> arg = expr >>> __builtin_xxx (arg) >>> >>> to >>> >>> arg = expr; >>> tmp = addr_expr (mem_ref(arg)); >>> __builtin_xxx (tmp, ...) >> >> this looks a bit confusing (and wasteful) to me. It would make more sense to >> just record the argument as USE_ADDRESS and do the rewriting in >> rewrite_use_address. >> >> Zdenek > > I updated the patch. The gimple changing part is now moved to > rewrite_use_address. Add support for plain address expr in addition to > reference expr in find_interesting_uses_address. > > bootstrap and testing is going on. > > 2013-11-22 Wei Mi > > * expr.c (expand_expr_addr_expr_1): Not to split TMR. > (expand_expr_real_1): Ditto. > * targhooks.c (default_builtin_has_mem_ref_p): Default > builtin. > * tree-ssa-loop-ivopts.c (builtin_has_mem_ref_p): New function. > (rewrite_use_address): Add TMR for builtin. > (find_interesting_uses_stmt): Special handling of builtins. > * gimple-expr.c (is_gimple_address): Add handling of TMR. > * gimple-expr.h (is_gimple_addressable): Ditto. > * config/i386/i386.c (ix86_builtin_has_mem_ref_p): New target hook. > (ix86_atomic_assign_expand_fenv): Ditto. > (ix86_expand_special_args_builtin): Special handling of TMR for > builtin. > * target.def (builtin_has_mem_ref_p): New hook. > * doc/tm.texi.in: Ditto. > * doc/tm.texi: Generated. > > 2013-11-22 Wei Mi > > * gcc.dg/tree-ssa/ivopt_5.c: New test. > > Index: testsuite/gcc.dg/tree-ssa/ivopt_5.c > === > --- testsuite/gcc.dg/tree-ssa/ivopt_5.c (revision 0) > +++ testsuite/gcc.dg/tree-ssa/ivopt_5.c (revision 0) > @@ -0,0 +1,21 @@ > +/* { dg-do compile { target {{ i?86-*-* x86_64-*-* } && lp64 } } } */ > +/* { dg-options "-O2 -m64 -fdump-tree-ivopts-details" } */ > + > +/* Make sure only one iv is selected after IVOPT. */ > + > +#include > +extern __m128i arr[], d[]; > +void test (void) > +{ > +unsigned int b; > +for (b = 0; b < 1000; b += 2) { > + __m128i *p = (__m128i *)(&d[b]); > + __m128i a = _mm_load_si128(&arr[4*b+3]); > + __m128i v = _mm_loadu_si128(p); > + v = _mm_xor_si128(v, a); > + _mm_storeu_si128(p, v); > +} > +} > + > +/* { dg-final { scan-tree-dump-times "PHI +/* { dg-final { cleanup-tree-dump "ivopts" } } */ > Index: targhooks.c > === > --- targhooks.c (revision 204792) > +++ targhooks.c (working copy) > @@ -566,6 +566,13 @@ default_builtin_reciprocal (unsigned int > } > > bool > +default_builtin_has_mem_ref_p (int built_in_function ATTRIBUTE_UNUSED, > + int i ATTRIBUTE_UNUSED) > +{ > + return false; > +} > + > +bool > hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false ( > cumulative_args_t ca ATTRIBUTE_UNUSED, > enum machine_mode mode ATTRIBUTE_UNUSED, > Index: expr.c > === > --- expr.c (revision 204792) > +++ expr.c (working copy) > @@ -7467,7 +7467,19 @@ expand_expr_addr_expr_1 (tree exp, rtx t > tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1)); > return expand_expr (tem, target, tmode, modifier); >} > +case TARGET_MEM_REF: > + { > + int old_cse_not_expected; > + addr_space_t as > + = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0; > > + result = addr_for_mem_ref (exp, as, true); > + old_cse_not_expected = cse_not_expected; > + cse_not_expected = true; > + result = memory_address_addr_space (tmode, result, as); > + cse_not_expected = old_cse_not_expected; > + return result; > + } > case CONST_DECL: >/* Expand the initializer like constants above. */ >result = XEXP (expand_expr_constant (DECL_INITIAL (exp), > @@ -9526,9 +9538,13 @@ expand_expr_real_1 (tree exp, rtx target > = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0; > enum insn_code icode; > unsigned int align; > + int old_cse_not_expected; > > op0 = addr_for_mem_ref (exp, as, true); > + old_cse_not_expected = cse_not_expected; > + cse_not_expected = true; > op0 = memory_address_addr_space (mode, op0, as); > + cse_not_expected = old_cse_not_expected; > temp = gen_rtx_MEM (mode, op0); > set_mem_attributes (temp, exp, 0); > set_mem_addr_space (temp, as); > Index: gimple-expr.c > ===
Go patch committed: Fix representation of calls to interface methods
Ulrich Weigand pointed out that the Go frontend is generating invalid GIMPLE for a call to an interface method: the function type does not match the number of arguments passed. I'm surprised this works at all, but in any case this patch fixes it. Fixing this problem showed that the frontend was not correctly handling function pointers. I changed the function pointer representation a few months back so that a Go function is represented as a pointer to a struct. This updates the calls to the backend interface so that placeholder pointers for Go functions are not marked as C functions. Also in order to avoid introducing unnecessary conversions between identical struct types, this patch unifies the return type of all functions with the same result parameters. Using a single backend representation for them lets the compiler not worry about converting that result struct to an identical one. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian 2013-11-23 Ian Lance Taylor * go-gcc.cc (Gcc_backend::function_type): Add result_struct parameter. Index: gcc/go/gofrontend/expressions.cc === --- gcc/go/gofrontend/expressions.cc (revision 205274) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -9863,8 +9863,11 @@ Call_expression::do_get_tree(Translate_c fndecl = TREE_OPERAND(fndecl, 0); // Add a type cast in case the type of the function is a recursive - // type which refers to itself. - if (!DECL_P(fndecl) || !DECL_IS_BUILTIN(fndecl)) + // type which refers to itself. We don't do this for an interface + // method because 1) an interface method never refers to itself, so + // we always have a function type here; 2) we pass an extra first + // argument to an interface method, so fnfield_type is not correct. + if ((!DECL_P(fndecl) || !DECL_IS_BUILTIN(fndecl)) && !is_interface_method) fn = fold_convert_loc(location.gcc_location(), fnfield_type, fn); // This is to support builtin math functions when using 80387 math. Index: gcc/go/gofrontend/backend.h === --- gcc/go/gofrontend/backend.h (revision 205274) +++ gcc/go/gofrontend/backend.h (working copy) @@ -101,11 +101,15 @@ class Backend // is provided so that the names are available. This should return // not the type of a Go function (which is a pointer to a struct) // but the type of a C function pointer (which will be used as the - // type of the first field of the struct). + // type of the first field of the struct). If there is more than + // one result, RESULT_STRUCT is a struct type to hold the results, + // and RESULTS may be ignored; if there are zero or one results, + // RESULT_STRUCT is NULL. virtual Btype* function_type(const Btyped_identifier& receiver, const std::vector& parameters, const std::vector& results, + Btype* result_struct, Location location) = 0; // Get a struct type. @@ -121,10 +125,11 @@ class Backend // NAME is the name of the type, and the location is where the named // type is defined. This function is also used for unnamed function // types with multiple results, in which case the type has no name - // and NAME will be empty. FOR_FUNCTION is true if this is for a Go - // function type, which corresponds to a C/C++ pointer to function - // type. The return value will later be passed as the first - // parameter to set_placeholder_pointer_type or + // and NAME will be empty. FOR_FUNCTION is true if this is for a C + // pointer to function type. A Go func type is represented as a + // pointer to a struct, and the first field of the struct is a C + // pointer to function. The return value will later be passed as + // the first parameter to set_placeholder_pointer_type or // set_placeholder_function_type. virtual Btype* placeholder_pointer_type(const std::string& name, Location, Index: gcc/go/gofrontend/types.cc === --- gcc/go/gofrontend/types.cc (revision 205274) +++ gcc/go/gofrontend/types.cc (working copy) @@ -1059,8 +1059,9 @@ Type::get_backend_placeholder(Gogo* gogo { case TYPE_FUNCTION: { + // A Go function type is a pointer to a struct type. Location loc = this->function_type()->location(); - bt = gogo->backend()->placeholder_pointer_type("", loc, true); + bt = gogo->backend()->placeholder_pointer_type("", loc, false); } break; @@ -1153,7 +1154,7 @@ Type::finish_backend(Gogo* gogo, Btype * case TYPE_FUNCTION: { Btype* bt = this->do_get_backend(gogo); - if (!gogo->backend()->set_placeholder_function_type(placeholder, bt)) + if (!gogo->backend()->set_placeholder_pointer_type(placeholder, bt)) go_assert(saw_errors()); } break; @@ -3378,6 +3379,48 @@ Function_type::do_hash_for_method(Gogo* return ret; } +// Hash result
Re: [patch] Fix ICEs when DEBUG_MANGLE is enabled
OK. Jason
Re: [C++ Patch] Fixes for two recent minor regressions (PR c++/59080, c++/59096)
OK. Jason
Re: [C++ Patch] Fixes for duplicate warnings regressions [1/2]
On 11/10/2013 05:26 AM, Paolo Carlini wrote: this is the issue with -Waddress caused by the fix for c++/56930. I'm handling it as already described, that is by adding a bool parameter to c_common_truthvalue_conversion. Why not handle this by making that warning respect c_inhibit_evaluation_warnings? Jason
wide-int, aarch64
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the aarch64 port. Ok? * config/aarch64/aarch64.c (aapcs_vfp_sub_candidate): Use wide-int interfaces. (aarch64_float_const_representable_p): Likewise. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index aad9a29..b175e6c 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -6047,9 +6047,7 @@ aapcs_vfp_sub_candidate (const_tree type, enum machine_mode *modep) - tree_to_uhwi (TYPE_MIN_VALUE (index))); /* There must be no padding. */ - if (!tree_fits_uhwi_p (TYPE_SIZE (type)) - || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type)) - != count * GET_MODE_BITSIZE (*modep))) + if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep))) return -1; return count; @@ -6077,9 +6075,7 @@ aapcs_vfp_sub_candidate (const_tree type, enum machine_mode *modep) } /* There must be no padding. */ - if (!tree_fits_uhwi_p (TYPE_SIZE (type)) - || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type)) - != count * GET_MODE_BITSIZE (*modep))) + if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep))) return -1; return count; @@ -6109,9 +6105,7 @@ aapcs_vfp_sub_candidate (const_tree type, enum machine_mode *modep) } /* There must be no padding. */ - if (!tree_fits_uhwi_p (TYPE_SIZE (type)) - || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type)) - != count * GET_MODE_BITSIZE (*modep))) + if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep))) return -1; return count; @@ -7449,8 +7443,8 @@ aarch64_float_const_representable_p (rtx x) int point_pos = 2 * HOST_BITS_PER_WIDE_INT - 1; int exponent; unsigned HOST_WIDE_INT mantissa, mask; - HOST_WIDE_INT m1, m2; REAL_VALUE_TYPE r, m; + bool fail; if (!CONST_DOUBLE_P (x)) return false; @@ -7474,16 +7468,16 @@ aarch64_float_const_representable_p (rtx x) WARNING: If we ever have a representation using more than 2 * H_W_I - 1 bits for the mantissa, this can fail (low bits will be lost). */ real_ldexp (&m, &r, point_pos - exponent); - REAL_VALUE_TO_INT (&m1, &m2, m); + wide_int w = real_to_integer (&m, &fail, HOST_BITS_PER_WIDE_INT * 2); /* If the low part of the mantissa has bits set we cannot represent the value. */ - if (m1 != 0) + if (w.elt (0) != 0) return false; /* We have rejected the lower HOST_WIDE_INT, so update our understanding of how many bits lie in the mantissa and look only at the high HOST_WIDE_INT. */ - mantissa = m2; + mantissa = w.elt (1); point_pos -= HOST_BITS_PER_WIDE_INT; /* We can only represent values with a mantissa of the form 1.. */
wide-int, alias
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the alias analysis code. Ok? * alias.c (ao_ref_from_mem): Use wide-int interfaces. (rtx_equal_for_memref_p): Update comment. (adjust_offset_for_component_ref): Use wide-int interfaces. diff --git a/gcc/alias.c b/gcc/alias.c index daa667c..8a1f09b 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -340,9 +340,10 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem) if (MEM_EXPR (mem) != get_spill_slot_decl (false) && (ref->offset < 0 || (DECL_P (ref->base) - && (!tree_fits_uhwi_p (DECL_SIZE (ref->base)) - || (tree_to_uhwi (DECL_SIZE (ref->base)) - < (unsigned HOST_WIDE_INT) (ref->offset + ref->size)) + && (DECL_SIZE (ref->base) == NULL_TREE + || TREE_CODE (DECL_SIZE (ref->base)) != INTEGER_CST + || wi::ltu_p (DECL_SIZE (ref->base), + ref->offset + ref->size) return false; return true; @@ -1543,9 +1544,7 @@ rtx_equal_for_memref_p (const_rtx x, const_rtx y) case VALUE: CASE_CONST_UNIQUE: - /* There's no need to compare the contents of CONST_DOUBLEs or -CONST_INTs because pointer equality is a good enough -comparison for these nodes. */ + /* Pointer equality guarantees equality for these nodes. */ return 0; default: @@ -2348,15 +2347,22 @@ adjust_offset_for_component_ref (tree x, bool *known_p, { tree xoffset = component_ref_field_offset (x); tree field = TREE_OPERAND (x, 1); + if (TREE_CODE (xoffset) != INTEGER_CST) + { + *known_p = false; + return; + } - if (! tree_fits_uhwi_p (xoffset)) + offset_int woffset + = (wi::to_offset (xoffset) + + wi::udiv_trunc (wi::to_offset (DECL_FIELD_BIT_OFFSET (field)), +BITS_PER_UNIT)); + if (!wi::fits_uhwi_p (woffset)) { *known_p = false; return; } - *offset += (tree_to_uhwi (xoffset) - + (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field)) -/ BITS_PER_UNIT)); + *offset += woffset.to_uhwi (); x = TREE_OPERAND (x, 0); }
wide-int, ada
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the ada front-end. Ok? ada: * gcc-interface/cuintp.c (UI_From_gnu): Use wide-int interfaces. * gcc-interface/decl.c (gnat_to_gnu_entity): Use TYPE_SIGN. (annotate_value): Use wide-int interfaces. * gcc-interface/utils.c (get_nonnull_operand): Use tree_fits_uhwi_p. diff --git a/gcc/ada/gcc-interface/cuintp.c b/gcc/ada/gcc-interface/cuintp.c index bbe62c1..7ef68b6 100644 --- a/gcc/ada/gcc-interface/cuintp.c +++ b/gcc/ada/gcc-interface/cuintp.c @@ -167,7 +167,7 @@ UI_From_gnu (tree Input) in a signed 64-bit integer. */ if (tree_fits_shwi_p (Input)) return UI_From_Int (tree_to_shwi (Input)); - else if (TREE_INT_CST_HIGH (Input) < 0 && TYPE_UNSIGNED (gnu_type)) + else if (wi::lts_p (Input, 0) && TYPE_UNSIGNED (gnu_type)) return No_Uint; #endif diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index ee76a9d..61b2239 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1664,7 +1664,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) TYPE_PRECISION (gnu_type) = esize; TYPE_UNSIGNED (gnu_type) = is_unsigned; set_min_and_max_values_for_integral_type (gnu_type, esize, - is_unsigned); + TYPE_SIGN (gnu_type)); process_attributes (&gnu_type, &attr_list, true, gnat_entity); layout_type (gnu_type); @@ -7493,11 +7493,9 @@ annotate_value (tree gnu_size) if (TREE_CODE (TREE_OPERAND (gnu_size, 1)) == INTEGER_CST) { tree op1 = TREE_OPERAND (gnu_size, 1); - double_int signed_op1 - = tree_to_double_int (op1).sext (TYPE_PRECISION (sizetype)); - if (signed_op1.is_negative ()) + if (wi::neg_p (op1)) { - op1 = double_int_to_tree (sizetype, -signed_op1); + op1 = wide_int_to_tree (sizetype, wi::neg (op1)); pre_op1 = annotate_value (build1 (NEGATE_EXPR, sizetype, op1)); } } diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 36e5b2d..ea80a32 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -6065,8 +6065,7 @@ static bool get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp) { /* Verify the arg number is a constant. */ - if (TREE_CODE (arg_num_expr) != INTEGER_CST - || TREE_INT_CST_HIGH (arg_num_expr) != 0) + if (!tree_fits_uhwi_p (arg_num_expr)) return false; *valp = TREE_INT_CST_LOW (arg_num_expr);
wide-int, arc
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the arc port. Ok? * config/arc/arc.c (arc_can_use_doloop_p): Use wide-int interfaces. diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 77932ce..5ad807e 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -392,7 +392,8 @@ static bool arc_return_in_memory (const_tree, const_tree); static void arc_init_simd_builtins (void); static bool arc_vector_mode_supported_p (enum machine_mode); -static bool arc_can_use_doloop_p (double_int, double_int, unsigned int, bool); +static bool arc_can_use_doloop_p (const widest_int &, const widest_int &, + unsigned int, bool); static const char *arc_invalid_within_doloop (const_rtx); static void output_short_suffix (FILE *file); @@ -5697,7 +5698,7 @@ arc_pass_by_reference (cumulative_args_t ca_v ATTRIBUTE_UNUSED, /* Implement TARGET_CAN_USE_DOLOOP_P. */ static bool -arc_can_use_doloop_p (double_int iterations, double_int, +arc_can_use_doloop_p (const widest_int &iterations, const widest_int &, unsigned int loop_depth, bool entered_at_top) { if (loop_depth > 1) @@ -5705,9 +5706,8 @@ arc_can_use_doloop_p (double_int iterations, double_int, /* Setting up the loop with two sr instructions costs 6 cycles. */ if (TARGET_ARC700 && !entered_at_top - && iterations.high == 0 - && iterations.low > 0 - && iterations.low <= (flag_pic ? 6 : 3)) + && wi::gtu_p (iterations, 0) + && wi::leu_p (iterations, flag_pic ? 6 : 3)) return false; return true; }
wide-int, builtins
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the builtins code. Ok? * builtins.c (get_object_alignment_2): Use wide-int interfaces. (c_readstr): Likewise. (target_char_cast): Add comment. (determine_block_size): Use wide-int interfaces. (expand_builtin_signbit): Likewise. (fold_builtin_int_roundingfn): Likewise. (fold_builtin_bitop): Likewise. (fold_builtin_bswap): Likewise. (fold_builtin_logarithm): Use signop. (fold_builtin_pow): Likewise. (fold_builtin_memory_op): Use wide-int interfaces. (fold_builtin_object_size): Likewise. diff --git a/gcc/builtins.c b/gcc/builtins.c index 9074ee7..5f840e9 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -411,7 +411,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, bitpos += ptr_bitpos; if (TREE_CODE (exp) == MEM_REF || TREE_CODE (exp) == TARGET_MEM_REF) - bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT; + bitpos += mem_ref_offset (exp).to_short_addr () * BITS_PER_UNIT; } } else if (TREE_CODE (exp) == STRING_CST) @@ -670,20 +670,23 @@ c_getstr (tree src) return TREE_STRING_POINTER (src) + tree_to_uhwi (offset_node); } -/* Return a CONST_INT or CONST_DOUBLE corresponding to target reading +/* Return a constant integer corresponding to target reading GET_MODE_BITSIZE (MODE) bits from string constant STR. */ static rtx c_readstr (const char *str, enum machine_mode mode) { - HOST_WIDE_INT c[2]; HOST_WIDE_INT ch; unsigned int i, j; + HOST_WIDE_INT tmp[MAX_BITSIZE_MODE_ANY_INT / HOST_BITS_PER_WIDE_INT]; + unsigned int len = (GET_MODE_PRECISION (mode) + HOST_BITS_PER_WIDE_INT - 1) +/ HOST_BITS_PER_WIDE_INT; + + for (i = 0; i < len; i++) +tmp[i] = 0; gcc_assert (GET_MODE_CLASS (mode) == MODE_INT); - c[0] = 0; - c[1] = 0; ch = 1; for (i = 0; i < GET_MODE_SIZE (mode); i++) { @@ -694,13 +697,14 @@ c_readstr (const char *str, enum machine_mode mode) && GET_MODE_SIZE (mode) >= UNITS_PER_WORD) j = j + UNITS_PER_WORD - 2 * (j % UNITS_PER_WORD) - 1; j *= BITS_PER_UNIT; - gcc_assert (j < HOST_BITS_PER_DOUBLE_INT); if (ch) ch = (unsigned char) str[i]; - c[j / HOST_BITS_PER_WIDE_INT] |= ch << (j % HOST_BITS_PER_WIDE_INT); + tmp[j / HOST_BITS_PER_WIDE_INT] |= ch << (j % HOST_BITS_PER_WIDE_INT); } - return immed_double_const (c[0], c[1], mode); + + wide_int c = wide_int::from_array (tmp, len, GET_MODE_PRECISION (mode)); + return immed_wide_int_const (c, mode); } /* Cast a target constant CST to target CHAR and if that value fits into @@ -716,7 +720,9 @@ target_char_cast (tree cst, char *p) || CHAR_TYPE_SIZE > HOST_BITS_PER_WIDE_INT) return 1; + /* Do not care if it fits or not right here. */ val = TREE_INT_CST_LOW (cst); + if (CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT) val &= (((unsigned HOST_WIDE_INT) 1) << CHAR_TYPE_SIZE) - 1; @@ -3118,7 +3124,7 @@ determine_block_size (tree len, rtx len_rtx, } else { - double_int min, max; + widest_int min, max; enum value_range_type range_type = VR_UNDEFINED; /* Determine bounds from the type. */ @@ -3135,18 +3141,19 @@ determine_block_size (tree len, rtx len_rtx, range_type = get_range_info (len, &min, &max); if (range_type == VR_RANGE) { - if (min.fits_uhwi () && *min_size < min.to_uhwi ()) + if (wi::fits_uhwi_p (min) && *min_size < min.to_uhwi ()) *min_size = min.to_uhwi (); - if (max.fits_uhwi () && *max_size > max.to_uhwi ()) + if (wi::fits_uhwi_p (max) && *max_size > max.to_uhwi ()) *probable_max_size = *max_size = max.to_uhwi (); } else if (range_type == VR_ANTI_RANGE) { /* Anti range 0...N lets us to determine minmal size to N+1. */ - if (min.is_zero ()) + if (min == 0) { - if ((max + double_int_one).fits_uhwi ()) - *min_size = (max + double_int_one).to_uhwi (); + widest_int max_plus_one = max + 1; + if (wi::fits_uhwi_p (max_plus_one)) + *min_size = max_plus_one.to_uhwi (); } /* Code like @@ -3157,9 +3164,8 @@ determine_block_size (tree len, rtx len_rtx, Produce anti range allowing negative values of N. We still can use the information and make a guess that N is not negative. */ - else if (!max.ule (double_int_one.lshift (30)) - && min.fits_uhwi ()) -*probable_max_size = min.to_uhwi () - 1; + else if (!wi::leu_p (max, 1 << 30) && wi::fits_uhwi_p (min)) + *probable_max_size = min.to_uhwi () - 1;
wide-int, bfin
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the bfin port. Ok? * config/bfin/bfin.c (bfin_local_alignment): Use wide-int interfaces. (bfin_can_use_doloop_p): Likewise. diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index d7af939..88fe426 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -3288,8 +3288,8 @@ bfin_local_alignment (tree type, unsigned align) memcpy can use 32 bit loads/stores. */ if (TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && (TREE_INT_CST_LOW (TYPE_SIZE (type)) > 8 - || TREE_INT_CST_HIGH (TYPE_SIZE (type))) && align < 32) + && wi::gtu_p (TYPE_SIZE (type), 8) + && align < 32) return 32; return align; } @@ -3371,15 +3371,14 @@ find_prev_insn_start (rtx insn) /* Implement TARGET_CAN_USE_DOLOOP_P. */ static bool -bfin_can_use_doloop_p (double_int, double_int iterations_max, +bfin_can_use_doloop_p (const widest_int &, const widest_int &iterations_max, unsigned int, bool) { /* Due to limitations in the hardware (an initial loop count of 0 does not loop 2^32 times) we must avoid to generate a hardware loops when we cannot rule out this case. */ if (!flag_unsafe_loop_optimizations - && (iterations_max.high != 0 - || iterations_max.low >= 0x)) + && wi::geu_p (iterations_max, 0x)) return false; return true; }
wide-int, c front end
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the c front end. Ok? c: * c-decl.c (check_bitfield_type_and_width): Use TYPE_SIGN. (finish_enum): Use wide-int interfaces. * c-parser.c (c_parser_cilk_clause_vectorlength): Use wide-int interfaces. * c-typeck.c (build_c_cast): Use wide-int interfaces. (set_nonincremental_init_from_string): Likewise. (c_tree_equal): Likewise. c-family: * c-ada-spec.c: Include wide-int.h. (ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX): Remove. (dump_generic_ada_node): Use wide-int interfaces. * c-common.c: Include wide-int-print.h. (shorten_compare): Use wide-int interfaces. (pointer_int_sum): Likewise. (c_common_nodes_and_builtins): Use make_int_cst. (match_case_to_enum_1): Use tree_fits_uhwi_p and tree_fits_shwi_p. (handle_alloc_size_attribute): Use wide-int interfaces. (get_nonnull_operand): Likewise. * c-format.c (get_constant): Use tree_fits_uhwi_p. * c-lex.c: Include wide-int.h. (narrowest_unsigned_type): Take a widest_int rather than two HOST_WIDE_INTs. (narrowest_signed_type): Likewise. (interpret_integer): Update accordingly. Use wide-int interfaces. (lex_charconst): Use wide-int interfaces. * c-pretty-print.c: Include wide-int.h. (pp_c_integer_constant): Use wide-int interfaces. * cilk.c (declare_one_free_variable): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED. diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 1724c74..e194d28 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -29,21 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "cpplib.h" #include "c-pragma.h" #include "cpp-id-data.h" - -/* Adapted from hwint.h to use the Ada prefix. */ -#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG -# if HOST_BITS_PER_WIDE_INT == 64 -# define ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX \ - "16#%" HOST_LONG_FORMAT "x%016" HOST_LONG_FORMAT "x#" -# else -# define ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX \ - "16#%" HOST_LONG_FORMAT "x%08" HOST_LONG_FORMAT "x#" -# endif -#else - /* We can assume that 'long long' is at least 64 bits. */ -# define ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX \ -"16#%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x#" -#endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */ +#include "wide-int.h" /* Local functions, macros and variables. */ static int dump_generic_ada_node (pretty_printer *, tree, tree, int, int, @@ -2211,19 +2197,18 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type, int spc, pp_unsigned_wide_integer (buffer, tree_to_uhwi (node)); else { - tree val = node; - unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (val); - HOST_WIDE_INT high = TREE_INT_CST_HIGH (val); - - if (tree_int_cst_sgn (val) < 0) + wide_int val = node; + int i; + if (wi::neg_p (val)) { pp_minus (buffer); - high = ~high + !low; - low = -low; + val = -val; } sprintf (pp_buffer (buffer)->digit_buffer, - ADA_HOST_WIDE_INT_PRINT_DOUBLE_HEX, - (unsigned HOST_WIDE_INT) high, low); + "16#%" HOST_LONG_FORMAT "x", val.elt (val.get_len () - 1)); + for (i = val.get_len () - 2; i <= 0; i--) + sprintf (pp_buffer (buffer)->digit_buffer, +HOST_WIDE_INT_PRINT_PADDED_HEX, val.elt (i)); pp_string (buffer, pp_buffer (buffer)->digit_buffer); } break; diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 97f33c1..e5e9389 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "target-def.h" #include "gimple.h" #include "gimplify.h" +#include "wide-int-print.h" cpp_reader *parse_in; /* Declared in c-pragma.h. */ @@ -4117,9 +4118,12 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, { /* Convert primop1 to target type, but do not introduce additional overflow. We know primop1 is an int_cst. */ - primop1 = force_fit_type_double (*restype_ptr, - tree_to_double_int (primop1), - 0, TREE_OVERFLOW (primop1)); + primop1 = force_fit_type (*restype_ptr, + wide_int::from + (primop1, + TYPE_PRECISION (*restype_ptr), + TYPE_SIGN (TREE_TYPE (
wide-int, build system
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the build system (make). Ok? * Makefile.in (RTL_H, CFGLOOP_H, C_COMMON_H, TREE_FLOW_H): Add wide-int.h. (REAL_H): Add signop.h. (OBJS): Add wide-int.o and wide-int-print.o. (GTFILES): Add wide-int.h and signop.h. (wide-int.h): New rule. (TAGS): Look for .cc files too. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 34e07a0..958118d 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -869,7 +869,7 @@ RTL_BASE_H = coretypes.h rtl.h rtl.def $(MACHMODE_H) reg-notes.def \ insn-notes.def $(INPUT_H) $(REAL_H) statistics.h $(VEC_H) \ $(FIXED_VALUE_H) alias.h $(HASHTAB_H) FIXED_VALUE_H = fixed-value.h $(MACHMODE_H) double-int.h -RTL_H = $(RTL_BASE_H) $(FLAGS_H) genrtl.h +RTL_H = $(RTL_BASE_H) $(FLAGS_H) genrtl.h wide-int.h READ_MD_H = $(OBSTACK_H) $(HASHTAB_H) read-md.h PARAMS_H = params.h params.def BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def \ @@ -899,7 +899,7 @@ FUNCTION_H = function.h $(HASHTAB_H) $(TM_H) hard-reg-set.h \ EXPR_H = expr.h insn-config.h $(FUNCTION_H) $(RTL_H) $(FLAGS_H) $(TREE_H) $(MACHMODE_H) $(EMIT_RTL_H) OPTABS_H = optabs.h insn-codes.h insn-opinit.h REGS_H = regs.h $(MACHMODE_H) hard-reg-set.h -CFGLOOP_H = cfgloop.h $(BASIC_BLOCK_H) double-int.h \ +CFGLOOP_H = cfgloop.h $(BASIC_BLOCK_H) double-int.h wide-int.h \ $(BITMAP_H) sbitmap.h IPA_UTILS_H = ipa-utils.h $(TREE_H) $(CGRAPH_H) IPA_REFERENCE_H = ipa-reference.h $(BITMAP_H) $(TREE_H) @@ -914,7 +914,7 @@ TIMEVAR_H = timevar.h timevar.def INSN_ATTR_H = insn-attr.h insn-attr-common.h $(INSN_ADDR_H) INSN_ADDR_H = $(srcdir)/insn-addr.h C_COMMON_H = c-family/c-common.h c-family/c-common.def $(TREE_H) \ - $(SPLAY_TREE_H) $(CPPLIB_H) $(GGC_H) $(DIAGNOSTIC_CORE_H) + $(SPLAY_TREE_H) $(CPPLIB_H) $(GGC_H) $(DIAGNOSTIC_CORE_H) wide-int.h C_PRAGMA_H = c-family/c-pragma.h $(CPPLIB_H) C_TREE_H = c/c-tree.h $(C_COMMON_H) $(DIAGNOSTIC_H) SYSTEM_H = system.h hwint.h $(srcdir)/../include/libiberty.h \ @@ -932,7 +932,7 @@ TREE_PASS_H = tree-pass.h $(TIMEVAR_H) $(DUMPFILE_H) TREE_FLOW_H = tree-flow.h tree-flow-inline.h tree-ssa-operands.h \ $(BITMAP_H) sbitmap.h $(BASIC_BLOCK_H) $(GIMPLE_H) \ $(HASHTAB_H) $(CGRAPH_H) $(IPA_REFERENCE_H) \ - tree-ssa-alias.h + tree-ssa-alias.h wide-int.h TREE_SSA_H = tree-ssa.h $(TREE_FLOW_H) PRETTY_PRINT_H = pretty-print.h $(INPUT_H) $(OBSTACK_H) TREE_PRETTY_PRINT_H = tree-pretty-print.h $(PRETTY_PRINT_H) @@ -942,7 +942,7 @@ DIAGNOSTIC_H = diagnostic.h $(DIAGNOSTIC_CORE_H) $(PRETTY_PRINT_H) C_PRETTY_PRINT_H = c-family/c-pretty-print.h $(PRETTY_PRINT_H) \ $(C_COMMON_H) $(TREE_H) TREE_INLINE_H = tree-inline.h -REAL_H = real.h $(MACHMODE_H) +REAL_H = real.h $(MACHMODE_H) signop.h LTO_STREAMER_H = lto-streamer.h $(LINKER_PLUGIN_API_H) $(TARGET_H) \ $(CGRAPH_H) $(VEC_H) $(HASH_TABLE_H) $(TREE_H) $(GIMPLE_H) \ $(GCOV_IO_H) $(DIAGNOSTIC_H) alloc-pool.h pointer-set.h @@ -1465,6 +1465,8 @@ OBJS = \ vmsdbgout.o \ vtable-verify.o \ web.o \ + wide-int.o \ + wide-int-print.o \ xcoffout.o \ $(out_object_file) \ $(EXTRA_OBJS) \ @@ -2227,7 +2229,7 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(host_xm_file_list) \ $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \ - $(srcdir)/alias.h $(srcdir)/coverage.c $(srcdir)/rtl.h \ + $(srcdir)/wide-int.h $(srcdir)/alias.h $(srcdir)/coverage.c $(srcdir)/rtl.h \ $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/tree-core.h \ $(srcdir)/libfuncs.h $(SYMTAB_H) \ $(srcdir)/real.h $(srcdir)/function.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \ @@ -2238,6 +2240,7 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \ $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-utils.h \ $(srcdir)/dbxout.c \ + $(srcdir)/signop.h \ $(srcdir)/dwarf2out.h \ $(srcdir)/dwarf2asm.c \ $(srcdir)/dwarf2cfi.c \ @@ -2435,15 +2438,16 @@ CFLAGS-gengtype-parse.o += -DGENERATOR_FILE build/gengtype-parse.o: $(BCONFIG_H) gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \ - gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \ - $(XREGEX_H) + gengtype.h errors.h double-int.h version.h $(HASHTAB_H)\ + $(OBSTACK_H) $(XREGEX_H) gengtype-state.o: $(CONFIG_H) CFLAGS-gengtype-state.o += -DGENERATOR_FILE build/gengtype-state.o: $(BCONFIG_H) - +wide-int.h: $(GTM_H) $(TREE_H) hwint.h $(OPTIONS_H)\ + $(MACHMODE_H) double-int.h dumpfile.h $(REAL_H) signop.h geng
wide-int, avr
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the avr port. Ok? * config/avr/avr.c (avr_out_round): Use wide-int interfaces. (avr_fold_builtin): Likewise. diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 8d98c81..e94e0d7 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -7550,6 +7550,8 @@ avr_out_round (rtx insn ATTRIBUTE_UNUSED, rtx *xop, int *plen) // The smallest fractional bit not cleared by the rounding is 2^(-RP). int fbit = (int) GET_MODE_FBIT (mode); double_int i_add = double_int_zero.set_bit (fbit-1 - INTVAL (xop[2])); + wide_int wi_add = wi::set_bit_in_zero (fbit-1 - INTVAL (xop[2]), +GET_MODE_PRECISION (imode)); // Lengths of PLUS and AND parts. int len_add = 0, *plen_add = plen ? &len_add : NULL; int len_and = 0, *plen_and = plen ? &len_and : NULL; @@ -7579,7 +7581,7 @@ avr_out_round (rtx insn ATTRIBUTE_UNUSED, rtx *xop, int *plen) // Rounding point ^^^ // Added above ^ rtx xreg = simplify_gen_subreg (imode, xop[0], mode, 0); - rtx xmask = immed_double_int_const (-i_add - i_add, imode); + rtx xmask = immed_wide_int_const (-wi_add - wi_add, imode); xpattern = gen_rtx_SET (VOIDmode, xreg, gen_rtx_AND (imode, xreg, xmask)); @@ -12230,7 +12232,7 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, break; } -tmap = double_int_to_tree (map_type, tree_to_double_int (arg[0])); +tmap = wide_int_to_tree (map_type, arg[0]); map = TREE_INT_CST_LOW (tmap); if (TREE_CODE (tval) != INTEGER_CST @@ -12335,8 +12337,7 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, /* Use map o G^-1 instead of original map to undo the effect of G. */ -tmap = double_int_to_tree (map_type, - double_int::from_uhwi (best_g.map)); +tmap = wide_int_to_tree (map_type, best_g.map); return build_call_expr (fndecl, 3, tmap, tbits, tval); } /* AVR_BUILTIN_INSERT_BITS */
wide-int, arm
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the arm port. Ok? * config/arm/arm.c (aapcs_vfp_sub_candidate): Use wide-int interfaces. (vfp3_const_double_index): Likewise. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 0d68f01..03bb136 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -4746,9 +4746,7 @@ aapcs_vfp_sub_candidate (const_tree type, enum machine_mode *modep) - tree_to_uhwi (TYPE_MIN_VALUE (index))); /* There must be no padding. */ - if (!tree_fits_uhwi_p (TYPE_SIZE (type)) - || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type)) - != count * GET_MODE_BITSIZE (*modep))) + if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep))) return -1; return count; @@ -4776,9 +4774,7 @@ aapcs_vfp_sub_candidate (const_tree type, enum machine_mode *modep) } /* There must be no padding. */ - if (!tree_fits_uhwi_p (TYPE_SIZE (type)) - || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type)) - != count * GET_MODE_BITSIZE (*modep))) + if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep))) return -1; return count; @@ -4808,9 +4804,7 @@ aapcs_vfp_sub_candidate (const_tree type, enum machine_mode *modep) } /* There must be no padding. */ - if (!tree_fits_uhwi_p (TYPE_SIZE (type)) - || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type)) - != count * GET_MODE_BITSIZE (*modep))) + if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep))) return -1; return count; @@ -11404,8 +11398,8 @@ vfp3_const_double_index (rtx x) int sign, exponent; unsigned HOST_WIDE_INT mantissa, mant_hi; unsigned HOST_WIDE_INT mask; - HOST_WIDE_INT m1, m2; int point_pos = 2 * HOST_BITS_PER_WIDE_INT - 1; + bool fail; if (!TARGET_VFP3 || !CONST_DOUBLE_P (x)) return -1; @@ -11425,9 +11419,9 @@ vfp3_const_double_index (rtx x) WARNING: If there's ever a VFP version which uses more than 2 * H_W_I - 1 bits for the mantissa, this may fail (low bits would be lost). */ real_ldexp (&m, &r, point_pos - exponent); - REAL_VALUE_TO_INT (&m1, &m2, m); - mantissa = m1; - mant_hi = m2; + wide_int w = real_to_integer (&m, &fail, HOST_BITS_PER_WIDE_INT * 2); + mantissa = w.elt (0); + mant_hi = w.elt (1); /* If there are bits set in the low part of the mantissa, we can't represent this value. */
wide-int, go
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the go front end. Ok? * godump.c: Include wide-int-print.h. (go_output_typedef): Use wide-int interfaces. go: * go-gcc.cc (Gcc_backend::type_size): Use tree_fits_uhwi_p. diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 83f91d5..578aff0 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -830,8 +830,7 @@ Gcc_backend::type_size(Btype* btype) if (t == error_mark_node) return 1; t = TYPE_SIZE_UNIT(t); - gcc_assert(TREE_CODE(t) == INTEGER_CST); - gcc_assert(TREE_INT_CST_HIGH(t) == 0); + gcc_assert(tree_fits_uhwi_p (t)); unsigned HOST_WIDE_INT val_wide = TREE_INT_CST_LOW(t); size_t ret = static_cast(val_wide); gcc_assert(ret == val_wide); diff --git a/gcc/godump.c b/gcc/godump.c index 3efbc7c..07edbc9 100644 --- a/gcc/godump.c +++ b/gcc/godump.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "pointer-set.h" #include "obstack.h" #include "debug.h" +#include "wide-int-print.h" /* We dump this information from the debug hooks. This gives us a stable and maintainable API to hook into. In order to work @@ -967,7 +968,7 @@ go_output_typedef (struct godump_container *container, tree decl) const char *name; struct macro_hash_value *mhval; void **slot; - char buf[100]; + char buf[WIDE_INT_PRINT_BUFFER_SIZE]; name = IDENTIFIER_POINTER (TREE_PURPOSE (element)); @@ -988,10 +989,7 @@ go_output_typedef (struct godump_container *container, tree decl) snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_UNSIGNED, tree_to_uhwi (TREE_VALUE (element))); else - snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_DOUBLE_HEX, -((unsigned HOST_WIDE_INT) - TREE_INT_CST_HIGH (TREE_VALUE (element))), -TREE_INT_CST_LOW (TREE_VALUE (element))); + print_hex (element, buf); mhval->value = xstrdup (buf); *slot = mhval;
wide-int, avr
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the avr port. Ok? * config/avr/avr.c (avr_out_round): Use wide-int interfaces. (avr_fold_builtin): Likewise. diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 8d98c81..e94e0d7 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -7550,6 +7550,8 @@ avr_out_round (rtx insn ATTRIBUTE_UNUSED, rtx *xop, int *plen) // The smallest fractional bit not cleared by the rounding is 2^(-RP). int fbit = (int) GET_MODE_FBIT (mode); double_int i_add = double_int_zero.set_bit (fbit-1 - INTVAL (xop[2])); + wide_int wi_add = wi::set_bit_in_zero (fbit-1 - INTVAL (xop[2]), +GET_MODE_PRECISION (imode)); // Lengths of PLUS and AND parts. int len_add = 0, *plen_add = plen ? &len_add : NULL; int len_and = 0, *plen_and = plen ? &len_and : NULL; @@ -7579,7 +7581,7 @@ avr_out_round (rtx insn ATTRIBUTE_UNUSED, rtx *xop, int *plen) // Rounding point ^^^ // Added above ^ rtx xreg = simplify_gen_subreg (imode, xop[0], mode, 0); - rtx xmask = immed_double_int_const (-i_add - i_add, imode); + rtx xmask = immed_wide_int_const (-wi_add - wi_add, imode); xpattern = gen_rtx_SET (VOIDmode, xreg, gen_rtx_AND (imode, xreg, xmask)); @@ -12230,7 +12232,7 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, break; } -tmap = double_int_to_tree (map_type, tree_to_double_int (arg[0])); +tmap = wide_int_to_tree (map_type, arg[0]); map = TREE_INT_CST_LOW (tmap); if (TREE_CODE (tval) != INTEGER_CST @@ -12335,8 +12337,7 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, /* Use map o G^-1 instead of original map to undo the effect of G. */ -tmap = double_int_to_tree (map_type, - double_int::from_uhwi (best_g.map)); +tmap = wide_int_to_tree (map_type, best_g.map); return build_call_expr (fndecl, 3, tmap, tbits, tval); } /* AVR_BUILTIN_INSERT_BITS */
wide-int, graphite
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the graphite code. Ok? * graphite-clast-to-gimple.c (gmp_cst_to_tree): Use wide-int interfaces. * graphite-sese-to-poly.c (tree_int_to_gmp): Use wide-int interfaces. (build_loop_iteration_domains): Likewise. diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index ad3e1dc..4d27335 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -70,14 +70,13 @@ gmp_cst_to_tree (tree type, mpz_t val) { tree t = type ? type : integer_type_node; mpz_t tmp; - double_int di; mpz_init (tmp); mpz_set (tmp, val); - di = mpz_get_double_int (t, tmp, true); + wide_int wi = wi::from_mpz (t, tmp, true); mpz_clear (tmp); - return double_int_to_tree (t, di); + return wide_int_to_tree (t, wi); } /* Sets RES to the min of V1 and V2. */ diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 544ea93..efe14b3 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -69,8 +69,7 @@ along with GCC; see the file COPYING3. If not see static inline void tree_int_to_gmp (tree t, mpz_t res) { - double_int di = tree_to_double_int (t); - mpz_set_double_int (res, di, TYPE_UNSIGNED (TREE_TYPE (t))); + wi::to_mpz (t, res, TYPE_SIGN (TREE_TYPE (t))); } /* Returns the index of the PHI argument defined in the outermost @@ -1021,7 +1020,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, /* loop_i <= expr_nb_iters */ else if (!chrec_contains_undetermined (nb_iters)) { - double_int nit; + widest_int nit; isl_pw_aff *aff; isl_set *valid; isl_local_space *ls; @@ -1057,7 +1056,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, isl_constraint *c; mpz_init (g); - mpz_set_double_int (g, nit, false); + wi::to_mpz (nit, g, SIGNED); mpz_sub_ui (g, g, 1); approx = extract_affine_gmp (g, isl_set_get_space (inner)); x = isl_pw_aff_ge_set (approx, aff);
wide-int, C++ front end
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the C++ front end. Ok? cp: * call.c: Include wide-int.h. (type_passed_as): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED. (convert_for_arg_passing): Likewise. * class.c: Include wide-int.h. (end_of_class): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED. (include_empty_classes): Likewise * cvt.c: Include wide-int.h. (ignore_overflows): Use wide_int_to_tree. * decl.c: Include wide-int.h. (check_array_designated_initializer): Use wide-int interfaces. (finish_enum_value_list): Use signop. (build_enumerator): Use wide-int interfaces. * init.c: Include wide-int.h. (build_new_1): Use wide-int interfaces. * mangle.c: Include wide-int.h. (write_integer_cst): Use wide-int interfaces. (write_array_type): Likewise. * tree.c: Include wide-int.h. (cp_tree_equal): Use wide-int interfaces. * typeck2.c: Include wide-int.h. (process_init_constructor_array): Use wide-int interfaces. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c529c16..00ebed4 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-objc.h" #include "timevar.h" #include "cgraph.h" +#include "wide-int.h" /* The various kinds of conversion. */ @@ -6495,8 +6496,7 @@ type_passed_as (tree type) else if (targetm.calls.promote_prototypes (type) && INTEGRAL_TYPE_P (type) && COMPLETE_TYPE_P (type) - && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), - TYPE_SIZE (integer_type_node))) + && INT_CST_LT (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) type = integer_type_node; return type; @@ -6536,8 +6536,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain) else if (targetm.calls.promote_prototypes (type) && INTEGRAL_TYPE_P (type) && COMPLETE_TYPE_P (type) - && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), - TYPE_SIZE (integer_type_node))) + && INT_CST_LT (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) val = cp_perform_integral_promotions (val, complain); if ((complain & tf_warning) && warn_suggest_attribute_format) diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 00fec27..027d235 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #include "hash-table.h" #include "gimple.h" #include "gimplify.h" +#include "wide-int.h" /* The number of nested classes being processed. If we are not in the scope of any class, this is zero. */ @@ -5831,7 +5832,7 @@ end_of_class (tree t, int include_virtuals_p) continue; offset = end_of_base (base_binfo); - if (INT_CST_LT_UNSIGNED (result, offset)) + if (INT_CST_LT (result, offset)) result = offset; } @@ -5841,7 +5842,7 @@ end_of_class (tree t, int include_virtuals_p) vec_safe_iterate (vbases, i, &base_binfo); i++) { offset = end_of_base (base_binfo); - if (INT_CST_LT_UNSIGNED (result, offset)) + if (INT_CST_LT (result, offset)) result = offset; } @@ -5921,7 +5922,7 @@ include_empty_classes (record_layout_info rli) CLASSTYPE_AS_BASE (rli->t) != NULL_TREE); rli_size = rli_size_unit_so_far (rli); if (TREE_CODE (rli_size) == INTEGER_CST - && INT_CST_LT_UNSIGNED (rli_size, eoc)) + && INT_CST_LT (rli_size, eoc)) { if (!abi_version_at_least (2)) /* In version 1 of the ABI, the size of a class that ends with diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 5264c5d..6d0e341 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "convert.h" #include "decl.h" #include "target.h" +#include "wide-int.h" static tree cp_convert_to_pointer (tree, tree, tsubst_flags_t); static tree convert_to_pointer_force (tree, tree, tsubst_flags_t); @@ -582,9 +583,7 @@ ignore_overflows (tree expr, tree orig) { gcc_assert (!TREE_OVERFLOW (orig)); /* Ensure constant sharing. */ - expr = build_int_cst_wide (TREE_TYPE (expr), -TREE_INT_CST_LOW (expr), -TREE_INT_CST_HIGH (expr)); + expr = wide_int_to_tree (TREE_TYPE (expr), expr); } return expr; } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 500c81f..babfc88 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -59,6 +59,7 @@ along with GCC; see the file COPYING3. If not see #include "splay-tree.h" #include "plugin.h" #include "cgraph.h" +#include "wide-int.h" /* Possible cases of
wide-int, gen*.c
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the gen*.c code, excluding gengtype. Ok? * genemit.c (gen_exp): Add CONST_WIDE_INT case. * gengenrtl.c (excluded_rtx): Add CONST_WIDE_INT case. * genmodes.c (emit_max_int): Define MAX_BITSIZE_MODE_ANY_INT and MAX_BITSIZE_MODE_ANY_MODE. * genpreds.c (write_one_predicate_function): Update comment. (write_tm_constrs_h): Add check for hval and lval use in CONST_WIDE_INT. * genrecog.c (validate_pattern): Add CONST_WIDE_INT case. (add_to_sequence): Likewise. * gensupport.c (struct std_pred_table): Add const_scalar_int_operand and const_double_operand. diff --git a/gcc/genemit.c b/gcc/genemit.c index 03831bf..174aa30 100644 --- a/gcc/genemit.c +++ b/gcc/genemit.c @@ -204,6 +204,7 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used) case CONST_DOUBLE: case CONST_FIXED: +case CONST_WIDE_INT: /* These shouldn't be written in MD files. Instead, the appropriate routines in varasm.c should be called. */ gcc_unreachable (); diff --git a/gcc/gengenrtl.c b/gcc/gengenrtl.c index 4a35683..ce2049d 100644 --- a/gcc/gengenrtl.c +++ b/gcc/gengenrtl.c @@ -142,6 +142,7 @@ static int excluded_rtx (int idx) { return ((strcmp (defs[idx].enumname, "CONST_DOUBLE") == 0) + || (strcmp (defs[idx].enumname, "CONST_WIDE_INT") == 0) || (strcmp (defs[idx].enumname, "CONST_FIXED") == 0)); } diff --git a/gcc/genmodes.c b/gcc/genmodes.c index 12a98f3..6f0fba8 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -883,14 +883,14 @@ emit_max_int (void) max = i->bytesize; if (max > mmax) mmax = max; - printf ("#define MAX_BITSIZE_MODE_ANY_INT %d*BITS_PER_UNIT\n", mmax); + printf ("#define MAX_BITSIZE_MODE_ANY_INT %d\n", mmax * MAX_BITS_PER_UNIT); mmax = 0; for (j = 0; j < MAX_MODE_CLASS; j++) for (i = modes[j]; i; i = i->next) if (mmax < i->bytesize) mmax = i->bytesize; - printf ("#define MAX_BITSIZE_MODE_ANY_MODE %d*BITS_PER_UNIT\n", mmax); + printf ("#define MAX_BITSIZE_MODE_ANY_MODE %d\n", mmax * MAX_BITS_PER_UNIT); } static void diff --git a/gcc/genpreds.c b/gcc/genpreds.c index c27ae88..dbffa90 100644 --- a/gcc/genpreds.c +++ b/gcc/genpreds.c @@ -612,7 +612,7 @@ write_one_predicate_function (struct pred_data *p) add_mode_tests (p); /* A normal predicate can legitimately not look at enum machine_mode - if it accepts only CONST_INTs and/or CONST_DOUBLEs. */ + if it accepts only CONST_INTs and/or CONST_WIDE_INT and/or CONST_DOUBLEs. */ printf ("int\n%s (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)\n{\n", p->name); write_predicate_stmts (p->exp); @@ -1075,12 +1075,17 @@ write_tm_constrs_h (void) if (needs_ival) puts (" if (CONST_INT_P (op))\n" "ival = INTVAL (op);"); +#if TARGET_SUPPORTS_WIDE_INT + if (needs_lval || needs_hval) + error ("you can't use lval or hval"); +#else if (needs_hval) puts (" if (GET_CODE (op) == CONST_DOUBLE && mode == VOIDmode)" "hval = CONST_DOUBLE_HIGH (op);"); if (needs_lval) puts (" if (GET_CODE (op) == CONST_DOUBLE && mode == VOIDmode)" "lval = CONST_DOUBLE_LOW (op);"); +#endif if (needs_rval) puts (" if (GET_CODE (op) == CONST_DOUBLE && mode != VOIDmode)" "rval = CONST_DOUBLE_REAL_VALUE (op);"); diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 814be7d..14a7e15 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -588,6 +588,7 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code) && GET_CODE (src) != PC && GET_CODE (src) != CC0 && !CONST_INT_P (src) +&& !CONST_WIDE_INT_P (src) && GET_CODE (src) != CALL) { const char *which; @@ -772,13 +773,14 @@ add_to_sequence (rtx pattern, struct decision_head *last, We can optimize the generated code a little if either (a) the predicate only accepts one code, or (b) the - predicate does not allow CONST_INT, in which case it - can match only if the modes match. */ + predicate does not allow CONST_INT or CONST_WIDE_INT, + in which case it can match only if the modes match. */ pred = lookup_predicate (pred_name); if (pred) { test->u.pred.data = pred; - allows_const_int = pred->codes[CONST_INT]; + allows_const_int = (pred->codes[CONST_INT] + || pred->codes[CONST_WIDE_INT]); if (was_code == MATCH_PA
wide-int, dfp
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the decimal floating point code. Ok? * dfp.c: Include wide-int.h. (decimal_real_to_integer2): Use wide-int interfaces and rename to decimal_real_to_integer. * dfp.h (decimal_real_to_integer2): Return a wide_int and rename to decimal_real_to_integer. diff --git a/gcc/dfp.c b/gcc/dfp.c index d15ee8f..265b707 100644 --- a/gcc/dfp.c +++ b/gcc/dfp.c @@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see #include "tree.h" #include "tm_p.h" #include "dfp.h" +#include "wide-int.h" /* The order of the following headers is important for making sure decNumber structure is large enough to hold decimal128 digits. */ @@ -604,11 +605,11 @@ decimal_real_to_integer (const REAL_VALUE_TYPE *r) return real_to_integer (&to); } -/* Likewise, but to an integer pair, HI+LOW. */ +/* Likewise, but returns a wide_int with PRECISION. *FAIL is set if the + value does not fit. */ -void -decimal_real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh, - const REAL_VALUE_TYPE *r) +wide_int +decimal_real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision) { decContext set; decNumber dn, dn2, dn3; @@ -628,7 +629,7 @@ decimal_real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh, function. */ decNumberToString (&dn, string); real_from_string (&to, string); - real_to_integer2 (plow, phigh, &to); + return real_to_integer (&to, fail, precision); } /* Perform the decimal floating point operation described by CODE. diff --git a/gcc/dfp.h b/gcc/dfp.h index 3b9bb8d..2f0da9b 100644 --- a/gcc/dfp.h +++ b/gcc/dfp.h @@ -38,7 +38,7 @@ void decimal_real_convert (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALU void decimal_real_to_decimal (char *, const REAL_VALUE_TYPE *, size_t, size_t, int); void decimal_do_fix_trunc (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *); void decimal_real_maxval (REAL_VALUE_TYPE *, int, enum machine_mode); -void decimal_real_to_integer2 (HOST_WIDE_INT *, HOST_WIDE_INT *, const REAL_VALUE_TYPE *); +wide_int decimal_real_to_integer (const REAL_VALUE_TYPE *, bool *, int); HOST_WIDE_INT decimal_real_to_integer (const REAL_VALUE_TYPE *); #ifdef TREE_CODE
wide-int, doc
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the documentation. Ok? * doc/generic.texi (Constant expressions): Use wide-int interfaces. * doc/rtl.texi (const_double): Use wide-int interfaces. (const_wide_int, CONST_WIDE_INT, CONST_WIDE_INT_VEC): New. (CONST_WIDE_INT_NUNITS, CONST_WIDE_INT_ELT): New. * doc/tm.texi.in (REAL_VALUE_TO_INT): Remove. (REAL_VALUE_FROM_INT): Remove. (TARGET_SUPPORTS_WIDE_INT): New. * doc/tm.texi: Regenerate. diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index f2dd0ff..534018e 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -1022,10 +1022,15 @@ As this example indicates, the operands are zero-indexed. @node Constant expressions @subsection Constant expressions @tindex INTEGER_CST -@findex TREE_INT_CST_HIGH -@findex TREE_INT_CST_LOW @findex tree_int_cst_lt @findex tree_int_cst_equal +@tindex tree_fits_uhwi_p +@tindex tree_fits_shwi_p +@tindex tree_to_uhwi +@tindex tree_to_shwi +@tindex TREE_INT_CST_NUNITS +@tindex TREE_INT_CST_ELT +@tindex TREE_INT_CST_LOW @tindex REAL_CST @tindex FIXED_CST @tindex COMPLEX_CST @@ -1044,36 +1049,18 @@ These nodes represent integer constants. Note that the type of these constants is obtained with @code{TREE_TYPE}; they are not always of type @code{int}. In particular, @code{char} constants are represented with @code{INTEGER_CST} nodes. The value of the integer constant @code{e} is -given by -@smallexample -((TREE_INT_CST_HIGH (e) << HOST_BITS_PER_WIDE_INT) -+ TREE_INST_CST_LOW (e)) -@end smallexample -@noindent -HOST_BITS_PER_WIDE_INT is at least thirty-two on all platforms. Both -@code{TREE_INT_CST_HIGH} and @code{TREE_INT_CST_LOW} return a -@code{HOST_WIDE_INT}. The value of an @code{INTEGER_CST} is interpreted -as a signed or unsigned quantity depending on the type of the constant. -In general, the expression given above will overflow, so it should not -be used to calculate the value of the constant. - -The variable @code{integer_zero_node} is an integer constant with value -zero. Similarly, @code{integer_one_node} is an integer constant with -value one. The @code{size_zero_node} and @code{size_one_node} variables -are analogous, but have type @code{size_t} rather than @code{int}. - -The function @code{tree_int_cst_lt} is a predicate which holds if its -first argument is less than its second. Both constants are assumed to -have the same signedness (i.e., either both should be signed or both -should be unsigned.) The full width of the constant is used when doing -the comparison; the usual rules about promotions and conversions are -ignored. Similarly, @code{tree_int_cst_equal} holds if the two -constants are equal. The @code{tree_int_cst_sgn} function returns the -sign of a constant. The value is @code{1}, @code{0}, or @code{-1} -according on whether the constant is greater than, equal to, or less -than zero. Again, the signedness of the constant's type is taken into -account; an unsigned constant is never less than zero, no matter what -its bit-pattern. +represented in an array of HOST_WIDE_INT. There are enough elements +in the array to represent the value without taking extra elements for +redundant 0s or -1. The number of elements used to represent @code{e} +is available via @code{TREE_INT_CST_NUNITS}. Element @code{i} can be +extracted by using @code{TREE_INT_CST_ELT (e, i)}. +@code{TREE_INT_CST_LOW} is a shorthand for @code{TREE_INT_CST_ELT (e, 0)}. + +The functions @code{tree_fits_shwi_p} and @code{tree_fits_uhwi_p} +can be used to tell if the value is small enough to fit in a +signed HOST_WIDE_INT or an unsigned HOST_WIDE_INT respectively. +The value can then be extracted using @code{tree_to_shwi} and +@code{tree_to_uhwi}. @item REAL_CST diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi index df2bb68..2565995 100644 --- a/gcc/doc/rtl.texi +++ b/gcc/doc/rtl.texi @@ -1541,17 +1541,21 @@ Similarly, there is only one object for the integer whose value is @findex const_double @item (const_double:@var{m} @var{i0} @var{i1} @dots{}) -Represents either a floating-point constant of mode @var{m} or an -integer constant too large to fit into @code{HOST_BITS_PER_WIDE_INT} -bits but small enough to fit within twice that number of bits (GCC -does not provide a mechanism to represent even larger constants). In -the latter case, @var{m} will be @code{VOIDmode}. For integral values -constants for modes with more bits than twice the number in -@code{HOST_WIDE_INT} the implied high order bits of that constant are -copies of the top bit of @code{CONST_DOUBLE_HIGH}. Note however that -integral values are neither inherently signed nor inherently unsigned; -where necessary, signedness is determined by the rtl operation -instead. +This represents either a floating
wide-int, gengtype
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the gengtype code. Ok? * gengtype.c: Remove include of double-int.h. (do_typedef): Use wide-int interfaces. (open_base_files): Add wide-int.h. (main): Add offset_int and widest_int typedefs. * gengtype-lex.l: Handle "^". (CXX_KEYWORD): Add "static". * gengtype-parse.c (require3): New. (require_template_declaration): Handle constant template arguments and nested templates. * gengtype-state.c: Don't include "double-int.h". diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 86e9ca2..0c0195c 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -25,7 +25,6 @@ #include "system.h" #include "errors.h"/* for fatal */ #include "getopt.h" -#include "double-int.h" #include "version.h" /* for version_string & pkgversion_string. */ #include "hashtab.h" #include "xregex.h" @@ -535,7 +534,7 @@ do_typedef (const char *s, type_p t, struct fileloc *pos) for (p = typedefs; p != NULL; p = p->next) if (strcmp (p->name, s) == 0) { - if (p->type != t) + if (p->type != t && strcmp (s, "result_type") != 0) { error_at_line (pos, "type `%s' previously defined", s); error_at_line (&p->line, "previously defined here"); @@ -1766,7 +1765,7 @@ open_base_files (void) static const char *const ifiles[] = { "config.h", "system.h", "coretypes.h", "tm.h", "hashtab.h", "splay-tree.h", "obstack.h", "bitmap.h", "input.h", - "tree.h", "rtl.h", "function.h", "insn-config.h", "expr.h", + "tree.h", "rtl.h", "wide-int.h", "function.h", "insn-config.h", "expr.h", "hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h", "optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h", "gimple.h", "gimple-iterator.h", "gimple-ssa.h", "tree-cfg.h", @@ -5633,6 +5632,8 @@ main (int argc, char **argv) POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); POS_HERE (do_scalar_typedef ("FIXED_VALUE_TYPE", &pos)); POS_HERE (do_scalar_typedef ("double_int", &pos)); + POS_HERE (do_scalar_typedef ("offset_int", &pos)); + POS_HERE (do_scalar_typedef ("widest_int", &pos)); POS_HERE (do_scalar_typedef ("uint64_t", &pos)); POS_HERE (do_scalar_typedef ("uint8", &pos)); POS_HERE (do_scalar_typedef ("uintptr_t", &pos)); diff --git a/gcc/gengtype-lex.l b/gcc/gengtype-lex.l index f46cd17..7ece2ab 100644 --- a/gcc/gengtype-lex.l +++ b/gcc/gengtype-lex.l @@ -57,7 +57,7 @@ ITYPE {IWORD}({WS}{IWORD})* /* Include '::' in identifiers to capture C++ scope qualifiers. */ ID {CID}({HWS}::{HWS}{CID})* EOID [^[:alnum:]_] -CXX_KEYWORD inline|public:|private:|protected:|template|operator|friend +CXX_KEYWORD inline|public:|private:|protected:|template|operator|friend|static %x in_struct in_struct_comment in_comment %option warn noyywrap nounput nodefault perf-report @@ -110,6 +110,7 @@ CXX_KEYWORD inline|public:|private:|protected:|template|operator|friend "const"/{EOID} /* don't care */ {CXX_KEYWORD}/{EOID} | "~"| +"^"| "&"{ *yylval = XDUPVAR (const char, yytext, yyleng, yyleng + 1); return IGNORABLE_CXX_KEYWORD; diff --git a/gcc/gengtype-parse.c b/gcc/gengtype-parse.c index 8328e3a..0a58822 100644 --- a/gcc/gengtype-parse.c +++ b/gcc/gengtype-parse.c @@ -197,6 +197,23 @@ require2 (int t1, int t2) return v; } +/* If the next token does not have one of the codes T1, T2 or T3, report a + parse error; otherwise return the token's value. */ +static const char * +require3 (int t1, int t2, int t3) +{ + int u = token (); + const char *v = advance (); + if (u != t1 && u != t2 && u != t3) +{ + parse_error ("expected %s, %s or %s, have %s", + print_token (t1, 0), print_token (t2, 0), + print_token (t3, 0), print_token (u, v)); + return 0; +} + return v; +} + /* Near-terminals. */ /* C-style string constant concatenation: STRING+ @@ -243,18 +260,45 @@ require_template_declaration (const char *tmpl_name) str = concat (tmpl_name, "<", (char *) 0); /* Read the comma-separated list of identifiers. */ - while (token () != '>') + int depth = 1; + while (depth > 0) { - const char *id = require2 (ID, ','); + if (token () == ENUM) + { + advance (); + str = concat (str, "enum ", (char *) 0); + continue; + } + if (token () == NUM) + { + str = concat (str, advance (), (char *) 0); + continue; + } + if (token () == ':') + { + advance (); + str = concat (str, ":", (char *) 0); +
wide-int, fortran
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the fortran front end. Ok? fortran: * target-memory.c: Include wide-int.h. (gfc_interpret_logical): Use wide-int interfaces. * trans-array.c: Include wide-int.h. (gfc_conv_array_initializer): Use wide-int interfaces. * trans-const.c: Include wide-int.h. (gfc_conv_string_init): Use wide-int interfaces. (gfc_conv_mpz_to_tree): Likewise. (gfc_conv_tree_to_mpz): Likewise. * trans-decl.c (gfc_can_put_var_on_stack): Use tree_fits_uhwi_p. * trans-expr.c: Include wide-int.h. (gfc_conv_cst_int_power): Use wide-int interfaces. (gfc_string_to_single_character): Likewise. (gfc_optimize_len_trim): Likewise. * trans-intrinsic.c: Include wide-int.h. (trans_this_image): Use wide-int interfaces. (gfc_conv_intrinsic_bound): Likewise. (conv_intrinsic_cobound): Likewise. * trans-types.c (gfc_init_types): Use wide-int interfaces. (gfc_get_array_type_bounds): Pass an integer of the correct type instead of using integer_one_node. diff --git a/gcc/fortran/target-memory.c b/gcc/fortran/target-memory.c index d0ee41a..8778d98 100644 --- a/gcc/fortran/target-memory.c +++ b/gcc/fortran/target-memory.c @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "trans-const.h" #include "trans-types.h" #include "target-memory.h" +#include "wide-int.h" /* --- */ /* Calculate the size of an expression. */ @@ -430,7 +431,7 @@ gfc_interpret_logical (int kind, unsigned char *buffer, size_t buffer_size, { tree t = native_interpret_expr (gfc_get_logical_type (kind), buffer, buffer_size); - *logical = tree_to_double_int (t).is_zero () ? 0 : 1; + *logical = wi::eq_p (t, 0) ? 0 : 1; return size_logical (kind); } diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index c2bbd0e..5b3cd1f 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -90,6 +90,7 @@ along with GCC; see the file COPYING3. If not see #include "trans-array.h" #include "trans-const.h" #include "dependency.h" +#include "wide-int.h" static bool gfc_get_array_constructor_size (mpz_t *, gfc_constructor_base); @@ -5361,9 +5362,8 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) { gfc_constructor *c; tree tmp; + offset_int wtmp; gfc_se se; - HOST_WIDE_INT hi; - unsigned HOST_WIDE_INT lo; tree index, range; vec *v = NULL; @@ -5385,20 +5385,13 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) else gfc_conv_structure (&se, expr, 1); - tmp = TYPE_MAX_VALUE (TYPE_DOMAIN (type)); - gcc_assert (tmp && INTEGER_CST_P (tmp)); - hi = TREE_INT_CST_HIGH (tmp); - lo = TREE_INT_CST_LOW (tmp); - lo++; - if (lo == 0) - hi++; + wtmp = wi::to_offset (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) + 1; + gcc_assert (wtmp != 0); /* This will probably eat buckets of memory for large arrays. */ - while (hi != 0 || lo != 0) + while (wtmp != 0) { CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, se.expr); - if (lo == 0) -hi--; - lo--; + wtmp -= 1; } break; diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c index f5a2b18..334b5f5 100644 --- a/gcc/fortran/trans-const.c +++ b/gcc/fortran/trans-const.c @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #include "trans-const.h" #include "trans-types.h" #include "target-memory.h" +#include "wide-int.h" tree gfc_rank_cst[GFC_MAX_DIMENSIONS + 1]; @@ -145,8 +146,7 @@ gfc_conv_string_init (tree length, gfc_expr * expr) gcc_assert (expr->expr_type == EXPR_CONSTANT); gcc_assert (expr->ts.type == BT_CHARACTER); - gcc_assert (INTEGER_CST_P (length)); - gcc_assert (TREE_INT_CST_HIGH (length) == 0); + gcc_assert (tree_fits_uhwi_p (length)); len = TREE_INT_CST_LOW (length); slen = expr->value.character.length; @@ -201,8 +201,8 @@ gfc_init_constants (void) tree gfc_conv_mpz_to_tree (mpz_t i, int kind) { - double_int val = mpz_get_double_int (gfc_get_int_type (kind), i, true); - return double_int_to_tree (gfc_get_int_type (kind), val); + wide_int val = wi::from_mpz (gfc_get_int_type (kind), i, true); + return wide_int_to_tree (gfc_get_int_type (kind), val); } /* Converts a backend tree into a GMP integer. */ @@ -210,8 +210,7 @@ gfc_conv_mpz_to_tree (mpz_t i, int kind) void gfc_conv_tree_to_mpz (mpz_t i, tree source) { - double_int val = tree_to_double_int (source); - mpz_set_double_int (i, val, TYPE_UNSIGNED (TREE_TYPE (source))); + wi::to_mpz (source, i, TYPE_SIGN (TREE_TYPE (source))); }
wide-int, msp430
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the msp430 port. Ok? * config/msp430/msp430.c (msp430_attr): Use wide-int interfaces. diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index daff4ae..e3f6712 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1085,7 +1085,7 @@ msp430_attr (tree * node, break; case INTEGER_CST: - if (TREE_INT_CST_LOW (value) > 31) + if (wi::gtu_p (value, 31)) /* Allow the attribute to be added - the linker script being used may still recognise this value. */ warning (OPT_Wattributes,
wide-int, nds32
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the nds32 port. Ok? * config/nds32/nds32.c (nds32_insert_attributes): Use wide-int interfaces. diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c index 008f088..8582bbb 100644 --- a/gcc/config/nds32/nds32.c +++ b/gcc/config/nds32/nds32.c @@ -3148,8 +3148,8 @@ nds32_insert_attributes (tree decl, tree *attributes) id = TREE_VALUE (id_list); /* Issue error if it is not a valid integer value. */ if (TREE_CODE (id) != INTEGER_CST - || TREE_INT_CST_LOW (id) < lower_bound - || TREE_INT_CST_LOW (id) > upper_bound) + || wi::ltu_p (id, lower_bound) + || wi::gtu_p (id, upper_bound)) error ("invalid id value for interrupt/exception attribute"); /* Advance to next id. */ @@ -3176,8 +3176,8 @@ nds32_insert_attributes (tree decl, tree *attributes) /* 3. Check valid integer value for reset. */ if (TREE_CODE (id) != INTEGER_CST - || TREE_INT_CST_LOW (id) < lower_bound - || TREE_INT_CST_LOW (id) > upper_bound) + || wi::ltu_p (id, lower_bound) + || wi::gtu_p (id, upper_bound)) error ("invalid id value for reset attribute"); /* 4. Check valid function for nmi/warm. */
wide-int, cfg
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the cfg code. Ok? * cfgloop.c (alloc_loop): Initialize nb_iterations_upper_bound and nb_iterations_estimate. (record_niter_bound): Use wide-int interfaces. (get_estimated_loop_iterations_int): Likewise. (get_estimated_loop_iterations): Likewise. (get_max_loop_iterations): Likewise. * cfgloop.h: Include wide-int.h. (struct nb_iter_bound): Change bound to widest_int. (struct loop): Change nb_iterations_upper_bound and nb_iterations_estimate to widest_int. (record_niter_bound): Switch to use widest_int. (get_estimated_loop_iterations): Likewise. (get_max_loop_iterations): Likewise. (gcov_type_to_double_int): Rename to gcov_type_to_wide_int and update for wide-int. * cgraph.c (cgraph_add_thunk): Use wide-int interfaces. diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index 09029c9..447302a 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -333,7 +333,8 @@ alloc_loop (void) loop->exits = ggc_alloc_cleared_loop_exit (); loop->exits->next = loop->exits->prev = loop->exits; loop->can_be_parallel = false; - + loop->nb_iterations_upper_bound = 0; + loop->nb_iterations_estimate = 0; return loop; } @@ -1784,21 +1785,21 @@ get_loop_location (struct loop *loop) I_BOUND times. */ void -record_niter_bound (struct loop *loop, double_int i_bound, bool realistic, - bool upper) +record_niter_bound (struct loop *loop, const widest_int &i_bound, + bool realistic, bool upper) { /* Update the bounds only when there is no previous estimation, or when the current estimation is smaller. */ if (upper && (!loop->any_upper_bound - || i_bound.ult (loop->nb_iterations_upper_bound))) + || wi::ltu_p (i_bound, loop->nb_iterations_upper_bound))) { loop->any_upper_bound = true; loop->nb_iterations_upper_bound = i_bound; } if (realistic && (!loop->any_estimate - || i_bound.ult (loop->nb_iterations_estimate))) + || wi::ltu_p (i_bound, loop->nb_iterations_estimate))) { loop->any_estimate = true; loop->nb_iterations_estimate = i_bound; @@ -1808,7 +1809,8 @@ record_niter_bound (struct loop *loop, double_int i_bound, bool realistic, number of iterations, use the upper bound instead. */ if (loop->any_upper_bound && loop->any_estimate - && loop->nb_iterations_upper_bound.ult (loop->nb_iterations_estimate)) + && wi::ltu_p (loop->nb_iterations_upper_bound, + loop->nb_iterations_estimate)) loop->nb_iterations_estimate = loop->nb_iterations_upper_bound; } @@ -1819,13 +1821,13 @@ record_niter_bound (struct loop *loop, double_int i_bound, bool realistic, HOST_WIDE_INT get_estimated_loop_iterations_int (struct loop *loop) { - double_int nit; + widest_int nit; HOST_WIDE_INT hwi_nit; if (!get_estimated_loop_iterations (loop, &nit)) return -1; - if (!nit.fits_shwi ()) + if (!wi::fits_shwi_p (nit)) return -1; hwi_nit = nit.to_shwi (); @@ -1856,7 +1858,7 @@ max_stmt_executions_int (struct loop *loop) returns true. */ bool -get_estimated_loop_iterations (struct loop *loop, double_int *nit) +get_estimated_loop_iterations (struct loop *loop, widest_int *nit) { /* Even if the bound is not recorded, possibly we can derrive one from profile. */ @@ -1864,7 +1866,7 @@ get_estimated_loop_iterations (struct loop *loop, double_int *nit) { if (loop->header->count) { - *nit = gcov_type_to_double_int + *nit = gcov_type_to_wide_int (expected_loop_iterations_unbounded (loop) + 1); return true; } @@ -1880,7 +1882,7 @@ get_estimated_loop_iterations (struct loop *loop, double_int *nit) false, otherwise returns true. */ bool -get_max_loop_iterations (struct loop *loop, double_int *nit) +get_max_loop_iterations (struct loop *loop, widest_int *nit) { if (!loop->any_upper_bound) return false; @@ -1896,13 +1898,13 @@ get_max_loop_iterations (struct loop *loop, double_int *nit) HOST_WIDE_INT get_max_loop_iterations_int (struct loop *loop) { - double_int nit; + widest_int nit; HOST_WIDE_INT hwi_nit; if (!get_max_loop_iterations (loop, &nit)) return -1; - if (!nit.fits_shwi ()) + if (!wi::fits_shwi_p (nit)) return -1; hwi_nit = nit.to_shwi (); diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 68285a6..69fa996 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #define GCC_CFGLOOP_H #include "double-int.h" +#include "wide-int.h" #include "bitmap.h" #include "sbitmap.h" #include "function.h" @@ -62,7
wide-int, OpenMP
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the OpenMP code. Ok? * omp-low.c (scan_omp_1_op): Use wide-int interfaces. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 2995060..d26139c 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2530,9 +2530,7 @@ scan_omp_1_op (tree *tp, int *walk_subtrees, void *data) if (tem != TREE_TYPE (t)) { if (TREE_CODE (t) == INTEGER_CST) - *tp = build_int_cst_wide (tem, - TREE_INT_CST_LOW (t), - TREE_INT_CST_HIGH (t)); + *tp = wide_int_to_tree (tem, t); else TREE_TYPE (t) = tem; }
wide-int, darwin
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the darwin port. Ok? * config/darwin.c (darwin_mergeable_constant_section): Use wide-int interfaces. (machopic_select_rtx_section): Update to handle CONST_WIDE_INT. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 761576d..50fb3f0 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1289,22 +1289,17 @@ darwin_mergeable_constant_section (tree exp, { tree size = TYPE_SIZE_UNIT (TREE_TYPE (exp)); - if (TREE_CODE (size) == INTEGER_CST - && TREE_INT_CST_LOW (size) == 4 - && TREE_INT_CST_HIGH (size) == 0) -return darwin_sections[literal4_section]; - else if (TREE_CODE (size) == INTEGER_CST - && TREE_INT_CST_LOW (size) == 8 - && TREE_INT_CST_HIGH (size) == 0) -return darwin_sections[literal8_section]; - else if (HAVE_GAS_LITERAL16 - && TARGET_64BIT - && TREE_CODE (size) == INTEGER_CST - && TREE_INT_CST_LOW (size) == 16 - && TREE_INT_CST_HIGH (size) == 0) -return darwin_sections[literal16_section]; - else -return readonly_data_section; + if (TREE_CODE (size) == INTEGER_CST) + { + if (wi::eq_p (size, 4)) + return darwin_sections[literal4_section]; + else if (wi::eq_p (size, 8)) + return darwin_sections[literal8_section]; + else if (HAVE_GAS_LITERAL16 + && TARGET_64BIT + && wi::eq_p (size, 16)) + return darwin_sections[literal16_section]; + } } return readonly_data_section; @@ -1731,16 +1726,19 @@ machopic_select_rtx_section (enum machine_mode mode, rtx x, { if (GET_MODE_SIZE (mode) == 8 && (GET_CODE (x) == CONST_INT + || GET_CODE (x) == CONST_WIDE_INT || GET_CODE (x) == CONST_DOUBLE)) return darwin_sections[literal8_section]; else if (GET_MODE_SIZE (mode) == 4 && (GET_CODE (x) == CONST_INT + || GET_CODE (x) == CONST_WIDE_INT || GET_CODE (x) == CONST_DOUBLE)) return darwin_sections[literal4_section]; else if (HAVE_GAS_LITERAL16 && TARGET_64BIT && GET_MODE_SIZE (mode) == 16 && (GET_CODE (x) == CONST_INT + || GET_CODE (x) == CONST_WIDE_INT || GET_CODE (x) == CONST_DOUBLE || GET_CODE (x) == CONST_VECTOR)) return darwin_sections[literal16_section];
wide-int, hook
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the hook code. Ok? * hooks.h: Include wide-int.h rather than double-int.h. (hook_bool_dint_dint_uint_bool_true): Delete. (hook_bool_wint_wint_uint_bool_true): Declare. * hooks.c (hook_bool_dint_dint_uint_bool_true): Removed. (hook_bool_wint_wint_uint_bool_true): New. * targhooks.h (can_use_doloop_if_innermost): Take widest_ints rather than double_ints. * targhooks.c (default_cxx_get_cookie_size): Uses INT_CST_LT rather than INT_CST_LT_UNSIGNED. (can_use_doloop_if_innermost): Take widest_ints rather than double_ints. diff --git a/gcc/hooks.c b/gcc/hooks.c index 9f53007..50c1250 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -332,7 +332,8 @@ hook_bool_rtx_int_int_int_intp_bool_false (rtx a ATTRIBUTE_UNUSED, } bool -hook_bool_dint_dint_uint_bool_true (double_int, double_int, unsigned int, bool) +hook_bool_wint_wint_uint_bool_true (const widest_int &, const widest_int &, + unsigned int, bool) { return true; } diff --git a/gcc/hooks.h b/gcc/hooks.h index 38454fb..38a5fd4 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -23,7 +23,7 @@ #define GCC_HOOKS_H #include "machmode.h" -#include "double-int.h" +#include "wide-int.h" extern bool hook_bool_void_false (void); extern bool hook_bool_void_true (void); @@ -61,7 +61,8 @@ extern bool hook_bool_rtx_int_int_int_intp_bool_false (rtx, int, int, int, extern bool hook_bool_tree_tree_false (tree, tree); extern bool hook_bool_tree_tree_true (tree, tree); extern bool hook_bool_tree_bool_false (tree, bool); -extern bool hook_bool_dint_dint_uint_bool_true (double_int, double_int, +extern bool hook_bool_wint_wint_uint_bool_true (const widest_int &, + const widest_int &, unsigned int, bool); extern void hook_void_void (void); diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 6c08385..c383520 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -291,7 +291,7 @@ default_cxx_get_cookie_size (tree type) sizetype_size = size_in_bytes (sizetype); type_align = size_int (TYPE_ALIGN_UNIT (type)); - if (INT_CST_LT_UNSIGNED (type_align, sizetype_size)) + if (INT_CST_LT (type_align, sizetype_size)) cookie_size = sizetype_size; else cookie_size = type_align; @@ -1744,7 +1744,7 @@ default_builtin_chkp_function (unsigned int fcode ATTRIBUTE_UNUSED) not support nested low-overhead loops. */ bool -can_use_doloop_if_innermost (double_int, double_int, +can_use_doloop_if_innermost (const widest_int &, const widest_int &, unsigned int loop_depth, bool) { return loop_depth == 1; diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 1ba0c1d..aed5778 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -213,5 +213,6 @@ extern tree default_fn_abi_va_list_bounds_size (tree); extern tree default_chkp_bound_type (void); extern enum machine_mode default_chkp_bound_mode (void); extern tree default_builtin_chkp_function (unsigned int); -extern bool can_use_doloop_if_innermost (double_int, double_int, +extern bool can_use_doloop_if_innermost (const widest_int &, +const widest_int &, unsigned int, bool);
wide-int, dwarf
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the dwarf code. Ok? * dwarf2out.c (get_full_len): New. (dw_val_equal_p): Add case dw_val_class_wide_int. (size_of_loc_descr): Likewise. (output_loc_operands): Likewise. (insert_double): Remove. (insert_wide_int): New. (add_AT_wide): New. (print_die): Add case dw_val_class_wide_int. (attr_checksum): Likewise. (attr_checksum_ordered): Likewise. (same_dw_val_p): Likewise. (size_of_die): Likewise. (value_format): Likewise. (output_die): Likewise. (double_int_type_size_in_bits): Rename to offset_int_type_size_in_bits. Use wide-int. (clz_loc_descriptor): Use wide-int interfaces. (mem_loc_descriptor): Likewise. Handle CONST_WIDE_INT. (loc_descriptor): Use wide-int interfaces. Handle CONST_WIDE_INT. (round_up_to_align): Use wide-int interfaces. (field_byte_offset): Likewise. (insert_double): Rename to insert_wide_int. Use wide-int interfaces. (add_const_value_attribute): Handle CONST_WIDE_INT. Update CONST_DOUBLE handling. Use wide-int interfaces. (add_bound_info): Use tree_fits_uhwi_p. Use wide-int interfaces. (gen_enumeration_type_die): Use add_AT_wide. (hash_loc_operands): Add case dw_val_class_wide_int. (compare_loc_operands): Likewise. * dwarf2out.h: Include wide-int.h. (wide_int_ptr): New. (enum dw_val_class): Add dw_val_class_wide_int. (struct dw_val_struct): Add val_wide. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index bd372b7..04d4988 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -353,6 +353,16 @@ dump_struct_debug (tree type, enum debug_info_usage usage, #endif +/* Get the number of HOST_WIDE_INTs needed to represent the precision + of the number. */ + +static unsigned int +get_full_len (const wide_int &op) +{ + return ((op.get_precision () + HOST_BITS_PER_WIDE_INT - 1) + / HOST_BITS_PER_WIDE_INT); +} + static bool should_emit_struct_debug (tree type, enum debug_info_usage usage) { @@ -1388,6 +1398,9 @@ dw_val_equal_p (dw_val_node *a, dw_val_node *b) return (a->v.val_double.high == b->v.val_double.high && a->v.val_double.low == b->v.val_double.low); +case dw_val_class_wide_int: + return *a->v.val_wide == *b->v.val_wide; + case dw_val_class_vec: { size_t a_len = a->v.val_vec.elt_size * a->v.val_vec.length; @@ -1644,6 +1657,10 @@ size_of_loc_descr (dw_loc_descr_ref loc) case dw_val_class_const_double: size += HOST_BITS_PER_DOUBLE_INT / BITS_PER_UNIT; break; + case dw_val_class_wide_int: + size += (get_full_len (*loc->dw_loc_oprnd2.v.val_wide) +* HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT); + break; default: gcc_unreachable (); } @@ -1821,6 +1838,20 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) second, NULL); } break; + case dw_val_class_wide_int: + { + int i; + int len = get_full_len (*val2->v.val_wide); + if (WORDS_BIG_ENDIAN) + for (i = len; i >= 0; --i) + dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR, +val2->v.val_wide->elt (i), NULL); + else + for (i = 0; i < len; ++i) + dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR, +val2->v.val_wide->elt (i), NULL); + } + break; case dw_val_class_addr: gcc_assert (val1->v.val_unsigned == DWARF2_ADDR_SIZE); dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, val2->v.val_addr, NULL); @@ -2030,6 +2061,21 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) dw2_asm_output_data (l, second, NULL); } break; + case dw_val_class_wide_int: + { + int i; + int len = get_full_len (*val2->v.val_wide); + l = HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; + + dw2_asm_output_data (1, len * l, NULL); + if (WORDS_BIG_ENDIAN) + for (i = len; i >= 0; --i) + dw2_asm_output_data (l, val2->v.val_wide->elt (i), NULL); + else + for (i = 0; i < len; ++i) + dw2_asm_output_data (l, val2->v.val_wide->elt (i), NULL); + } + break; default: gcc_unreachable (); } @@ -3122,7 +3168,7 @@ static void add_AT_location_description (dw_die_ref, enum dwarf_attribute, static void add_data
wide-int, sched
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the scheduler code. Ok? * sched-vis.c (print_value): Handle CONST_WIDE_INT. * sel-sched-ir.c (lhs_and_rhs_separable_p): Update comment. diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c index a965c4d..8fa29bf 100644 --- a/gcc/sched-vis.c +++ b/gcc/sched-vis.c @@ -428,6 +428,23 @@ print_value (pretty_printer *pp, const_rtx x, int verbose) pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX, (unsigned HOST_WIDE_INT) INTVAL (x)); break; + +case CONST_WIDE_INT: + { + const char *sep = "<"; + int i; + for (i = CONST_WIDE_INT_NUNITS (x) - 1; i >= 0; i--) + { + pp_string (pp, sep); + sep = ","; + sprintf (tmp, HOST_WIDE_INT_PRINT_HEX, +(unsigned HOST_WIDE_INT) CONST_WIDE_INT_ELT (x, i)); + pp_string (pp, tmp); + } +pp_greater (pp); + } + break; + case CONST_DOUBLE: if (FLOAT_MODE_P (GET_MODE (x))) { diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c index 7dfc703..0db84e6 100644 --- a/gcc/sel-sched-ir.c +++ b/gcc/sel-sched-ir.c @@ -1141,10 +1141,10 @@ lhs_and_rhs_separable_p (rtx lhs, rtx rhs) if (lhs == NULL || rhs == NULL) return false; - /* Do not schedule CONST, CONST_INT and CONST_DOUBLE etc as rhs: no point - to use reg, if const can be used. Moreover, scheduling const as rhs may - lead to mode mismatch cause consts don't have modes but they could be - merged from branches where the same const used in different modes. */ + /* Do not schedule constants as rhs: no point to use reg, if const + can be used. Moreover, scheduling const as rhs may lead to mode + mismatch cause consts don't have modes but they could be merged + from branches where the same const used in different modes. */ if (CONSTANT_P (rhs)) return false;
wide-int, rtl
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the first half of the rtl code. Ok? wide-int-rtl.diffs.txt.bz2 Description: BZip2 compressed data
wide-int, ipa
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the ipa code. Ok? * ipa-devirt.c (get_polymorphic_call_info): Use wide-int interfaces. * ipa-prop.c (compute_complex_assign_jump_func): Use wide-int interfaces. (get_ancestor_addr_info): Likewise. (ipa_modify_call_arguments): Likewise. diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 38cf378..41e5300 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -968,7 +968,7 @@ get_polymorphic_call_info (tree fndecl, { base_pointer = TREE_OPERAND (base, 0); context->offset -+= offset2 + mem_ref_offset (base).low * BITS_PER_UNIT; + += offset2 + mem_ref_offset (base).ulow () * BITS_PER_UNIT; context->outer_type = NULL; } /* We found base object. In this case the outer_type diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index d122dd5..3953442 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1063,7 +1063,7 @@ compute_complex_assign_jump_func (struct ipa_node_params *info, || max_size == -1 || max_size != size) return; - offset += mem_ref_offset (base).low * BITS_PER_UNIT; + offset += mem_ref_offset (base).to_short_addr () * BITS_PER_UNIT; ssa = TREE_OPERAND (base, 0); if (TREE_CODE (ssa) != SSA_NAME || !SSA_NAME_IS_DEFAULT_DEF (ssa) @@ -1122,7 +1122,7 @@ get_ancestor_addr_info (gimple assign, tree *obj_p, HOST_WIDE_INT *offset) || TREE_CODE (SSA_NAME_VAR (parm)) != PARM_DECL) return NULL_TREE; - *offset += mem_ref_offset (expr).low * BITS_PER_UNIT; + *offset += mem_ref_offset (expr).to_short_addr () * BITS_PER_UNIT; *obj_p = obj; return expr; } @@ -3661,9 +3661,8 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, if (TYPE_ALIGN (type) > align) align = TYPE_ALIGN (type); } - misalign += (tree_to_double_int (off) - .sext (TYPE_PRECISION (TREE_TYPE (off))).low - * BITS_PER_UNIT); + misalign += (offset_int::from (off, SIGNED) + * BITS_PER_UNIT).to_short_addr (); misalign = misalign & (align - 1); if (misalign != 0) align = (misalign & -misalign);
wide-int, rtl-2
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the half of the rtl code. Ok? * dojump.c (prefer_and_bit_test): Use wide-int interfaces. * stmt.c (expand_case): Use wide-int interfaces. * stor-layout.h (set_min_and_max_values_for_integral_type): Take a signop rather than a bool. * stor-layout.c (layout_type): Use wide-int interfaces. (initialize_sizetypes): Update calls to set_min_and_max_values_for_integral_type. (set_min_and_max_values_for_integral_type): Take a signop rather than a bool. Use wide-int interfaces. (fixup_signed_type): Update accordingly. Remove HOST_BITS_PER_DOUBLE_INT limit. (fixup_unsigned_type): Likewise. * varasm.c (decode_addr_const): Use wide-int interfaces. (const_hash_1): Likewise. (const_rtx_hash_1): Likewise (output_constant): Likewise. (array_size_for_constructor): Likewise. (output_constructor_regular_field): Likewise. (output_constructor_bitfield): Likewise. diff --git a/gcc/dojump.c b/gcc/dojump.c index 2aef34d..51c3c8c 100644 --- a/gcc/dojump.c +++ b/gcc/dojump.c @@ -143,6 +143,7 @@ static bool prefer_and_bit_test (enum machine_mode mode, int bitnum) { bool speed_p; + wide_int mask = wi::set_bit_in_zero (bitnum, GET_MODE_PRECISION (mode)); if (and_test == 0) { @@ -163,8 +164,7 @@ prefer_and_bit_test (enum machine_mode mode, int bitnum) } /* Fill in the integers. */ - XEXP (and_test, 1) -= immed_double_int_const (double_int_zero.set_bit (bitnum), mode); + XEXP (and_test, 1) = immed_wide_int_const (mask, mode); XEXP (XEXP (shift_test, 0), 1) = GEN_INT (bitnum); speed_p = optimize_insn_for_speed_p (); diff --git a/gcc/stmt.c b/gcc/stmt.c index 37b2de3..f7d5b4b 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -1233,9 +1233,7 @@ expand_case (gimple stmt) original type. Make sure to drop overflow flags. */ low = fold_convert (index_type, low); if (TREE_OVERFLOW (low)) - low = build_int_cst_wide (index_type, - TREE_INT_CST_LOW (low), - TREE_INT_CST_HIGH (low)); + low = wide_int_to_tree (index_type, low); /* The canonical from of a case label in GIMPLE is that a simple case has an empty CASE_HIGH. For the casesi and tablejump expanders, @@ -1244,9 +1242,7 @@ expand_case (gimple stmt) high = low; high = fold_convert (index_type, high); if (TREE_OVERFLOW (high)) - high = build_int_cst_wide (index_type, - TREE_INT_CST_LOW (high), - TREE_INT_CST_HIGH (high)); + high = wide_int_to_tree (index_type, high); basic_block case_bb = label_to_block_fn (cfun, lab); edge case_edge = find_edge (bb, case_bb); diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 0a1194e..839a7c2 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2204,13 +2204,10 @@ layout_type (tree type) && TYPE_UNSIGNED (TREE_TYPE (lb)) && tree_int_cst_lt (ub, lb)) { - unsigned prec = TYPE_PRECISION (TREE_TYPE (lb)); - lb = double_int_to_tree - (ssizetype, - tree_to_double_int (lb).sext (prec)); - ub = double_int_to_tree - (ssizetype, - tree_to_double_int (ub).sext (prec)); + lb = wide_int_to_tree (ssizetype, + offset_int::from (lb, SIGNED)); + ub = wide_int_to_tree (ssizetype, + offset_int::from (ub, SIGNED)); } length = fold_convert (sizetype, @@ -2486,16 +2483,14 @@ initialize_sizetypes (void) TYPE_ALIGN (sizetype) = GET_MODE_ALIGNMENT (TYPE_MODE (sizetype)); TYPE_SIZE (sizetype) = bitsize_int (precision); TYPE_SIZE_UNIT (sizetype) = size_int (GET_MODE_SIZE (TYPE_MODE (sizetype))); - set_min_and_max_values_for_integral_type (sizetype, precision, - /*is_unsigned=*/true); + set_min_and_max_values_for_integral_type (sizetype, precision, UNSIGNED); SET_TYPE_MODE (bitsizetype, smallest_mode_for_size (bprecision, MODE_INT)); TYPE_ALIGN (bitsizetype) = GET_MODE_ALIGNMENT (TYPE_MODE (bitsizetype)); TYPE_SIZE (bitsizetype) = bitsize_int (bprecision); TYPE_SIZE_UNIT (bitsizetype) = size_int (GET_MODE_SIZE (TYPE_MODE (bitsizetype))); - set_min_and_max_values_for_integral_type (bitsizetype, bprecision, - /*is_unsigned=*/true); + set_
wide-int, loop
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the loop code. Ok? * loop-doloop.c (doloop_modify): Use wide-int interfaces. (doloop_optimize): Likewise. * loop-iv.c (iv_number_of_iterations): Use wide-int interfaces. * loop-unroll.c (decide_unroll_constant_iterations): Use wide-int interfaces. (unroll_loop_constant_iterations): Likewise. (decide_unroll_runtime_iterations): Likewise. (unroll_loop_runtime_iterations): Likewise. (decide_peel_simple): Likewise. (decide_unroll_stupid): Likewise. diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c index 24e0201..0afd79d 100644 --- a/gcc/loop-doloop.c +++ b/gcc/loop-doloop.c @@ -409,7 +409,7 @@ doloop_modify (struct loop *loop, struct niter_desc *desc, basic_block loop_end = desc->out_edge->src; enum machine_mode mode; rtx true_prob_val; - double_int iterations; + widest_int iterations; jump_insn = BB_END (loop_end); @@ -461,9 +461,9 @@ doloop_modify (struct loop *loop, struct niter_desc *desc, /* Determine if the iteration counter will be non-negative. Note that the maximum value loaded is iterations_max - 1. */ if (get_max_loop_iterations (loop, &iterations) - && (iterations.ule (double_int_one.llshift - (GET_MODE_PRECISION (mode) - 1, - GET_MODE_PRECISION (mode) + && wi::leu_p (iterations, + wi::set_bit_in_zero + (GET_MODE_PRECISION (mode) - 1))) nonneg = 1; break; @@ -597,7 +597,7 @@ doloop_optimize (struct loop *loop) enum machine_mode mode; rtx doloop_seq, doloop_pat, doloop_reg; rtx count; - double_int iterations, iterations_max; + widest_int iterations, iterations_max; rtx start_label; rtx condition; unsigned level, est_niter; @@ -655,11 +655,12 @@ doloop_optimize (struct loop *loop) } if (desc->const_iter) -iterations = rtx_to_double_int (desc->niter_expr); +iterations = widest_int::from (std::make_pair (desc->niter_expr, mode), + UNSIGNED); else -iterations = double_int_zero; +iterations = 0; if (!get_max_loop_iterations (loop, &iterations_max)) -iterations_max = double_int_zero; +iterations_max = 0; level = get_loop_level (loop) + 1; entered_at_top = (loop->latch == desc->in_edge->dest && contains_no_active_insn_p (loop->latch)); @@ -688,7 +689,7 @@ doloop_optimize (struct loop *loop) computed, we must be sure that the number of iterations fits into the new mode. */ && (word_mode_size >= GET_MODE_PRECISION (mode) - || iterations_max.ule (double_int::from_shwi (word_mode_max + || wi::leu_p (iterations_max, word_mode_max))) { if (word_mode_size > GET_MODE_PRECISION (mode)) count = simplify_gen_unary (ZERO_EXTEND, word_mode, count, mode); diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index c01ee17..01f8dce 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -2622,8 +2622,7 @@ iv_number_of_iterations (struct loop *loop, rtx insn, rtx condition, max = (up - down) / inc + 1; if (!desc->infinite && !desc->assumptions) - record_niter_bound (loop, double_int::from_uhwi (max), - false, true); + record_niter_bound (loop, max, false, true); if (iv0.step == const0_rtx) { @@ -2662,8 +2661,8 @@ iv_number_of_iterations (struct loop *loop, rtx insn, rtx condition, iv1.step = const0_rtx; if (INTVAL (iv0.step) < 0) { - iv0.step = simplify_gen_unary (NEG, comp_mode, iv0.step, mode); - iv1.base = simplify_gen_unary (NEG, comp_mode, iv1.base, mode); + iv0.step = simplify_gen_unary (NEG, comp_mode, iv0.step, comp_mode); + iv1.base = simplify_gen_unary (NEG, comp_mode, iv1.base, comp_mode); } iv0.step = lowpart_subreg (mode, iv0.step, comp_mode); @@ -2837,8 +2836,7 @@ iv_number_of_iterations (struct loop *loop, rtx insn, rtx condition, desc->niter = val & GET_MODE_MASK (desc->mode); if (!desc->infinite && !desc->assumptions) -record_niter_bound (loop, double_int::from_uhwi (desc->niter), - false, true); +record_niter_bound (loop, desc->niter, false, true); } else { @@ -2847,8 +2845,7 @@ iv_number_of_iterations (struct loop *loop, rtx insn, rtx condition, goto zero_iter_simplify; if (!desc->infinite && !desc->assumptions) - record_niter_bound (loop, double_int::from_uhwi (max), - false, true); + record_niter_bound (loop, max, false, true); /* simplify_u
wide-int, testsuite
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the test suite. Ok? testsuite: * gcc.dg/tree-ssa/pr45427.c: Update to look for 0x0 instead of 0. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr45427.c b/gcc/testsuite/gcc.dg/tree-ssa/pr45427.c index 0952b5a..0bd1a18 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr45427.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr45427.c @@ -25,5 +25,5 @@ int main() return 0; } -/* { dg-final { scan-tree-dump-times "bounded by 0" 0 "cunrolli"} } */ +/* { dg-final { scan-tree-dump-times "bounded by 0x0\[^0-9a-f\]" 0 "cunrolli"} } */ /* { dg-final { cleanup-tree-dump "cunrolli" } } */
wide-int, tree-vec
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the tree-vec code. Ok? * tree-vect-data-refs.c (vect_prune_runtime_alias_test_list): Use wide-int interfaces. (vect_check_gather): Likewise. * tree-vect-generic.c (build_replicated_const): Use wide-int interfaces. (expand_vector_divmod): Likewise. * tree-vect-loop.c (vect_transform_loop): Use wide-int interfaces. * tree-vect-loop-manip.c (vect_do_peeling_for_loop_bound): Use wide-int interfaces. (vect_do_peeling_for_alignment): Likewise. * tree-vect-patterns.c (vect_recog_divmod_pattern): Use wide-int interfaces. diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index c1eb455..f8c8442 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -2904,15 +2904,13 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo) */ - HOST_WIDE_INT - min_seg_len_b = (TREE_CODE (dr_b1->seg_len) == INTEGER_CST) ? -TREE_INT_CST_LOW (dr_b1->seg_len) : -vect_factor; + HOST_WIDE_INT min_seg_len_b = (tree_fits_shwi_p (dr_b1->seg_len) + ? tree_to_shwi (dr_b1->seg_len) + : vect_factor); if (diff <= min_seg_len_b - || (TREE_CODE (dr_a1->seg_len) == INTEGER_CST - && diff - (HOST_WIDE_INT) TREE_INT_CST_LOW (dr_a1->seg_len) < -min_seg_len_b)) + || (tree_fits_shwi_p (dr_a1->seg_len) + && diff - tree_to_shwi (dr_a1->seg_len) < min_seg_len_b)) { dr_a1->seg_len = size_binop (PLUS_EXPR, dr_a2->seg_len, size_int (diff)); @@ -2975,8 +2973,8 @@ vect_check_gather (gimple stmt, loop_vec_info loop_vinfo, tree *basep, { if (off == NULL_TREE) { - double_int moff = mem_ref_offset (base); - off = double_int_to_tree (sizetype, moff); + offset_int moff = mem_ref_offset (base); + off = wide_int_to_tree (sizetype, moff); } else off = size_binop (PLUS_EXPR, off, diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index fc1c7b1..3679926 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -52,9 +52,10 @@ static tree build_replicated_const (tree type, tree inner_type, HOST_WIDE_INT value) { int width = tree_to_uhwi (TYPE_SIZE (inner_type)); - int n = HOST_BITS_PER_WIDE_INT / width; - unsigned HOST_WIDE_INT low, high, mask; - tree ret; + int n = TYPE_PRECISION (type) / width; + unsigned HOST_WIDE_INT low, mask; + HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; + int i; gcc_assert (n); @@ -66,17 +67,11 @@ build_replicated_const (tree type, tree inner_type, HOST_WIDE_INT value) low = (unsigned HOST_WIDE_INT) ~0 / mask * (value & mask); } - if (TYPE_PRECISION (type) < HOST_BITS_PER_WIDE_INT) -low &= ((HOST_WIDE_INT)1 << TYPE_PRECISION (type)) - 1, high = 0; - else if (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT) -high = 0; - else if (TYPE_PRECISION (type) == HOST_BITS_PER_DOUBLE_INT) -high = low; - else -gcc_unreachable (); + for (i = 0; i < n; i++) +a[i] = low; - ret = build_int_cst_wide (type, low, high); - return ret; + return wide_int_to_tree +(type, wide_int::from_array (a, n, TYPE_PRECISION (type))); } static GTY(()) tree vector_inner_type; @@ -410,7 +405,8 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, unsigned HOST_WIDE_INT *mulc = XALLOCAVEC (unsigned HOST_WIDE_INT, nunits); int prec = TYPE_PRECISION (TREE_TYPE (type)); int dummy_int; - unsigned int i, unsignedp = TYPE_UNSIGNED (TREE_TYPE (type)); + unsigned int i; + signop sign_p = TYPE_SIGN (TREE_TYPE (type)); unsigned HOST_WIDE_INT mask = GET_MODE_MASK (TYPE_MODE (TREE_TYPE (type))); tree *vec; tree cur_op, mulcst, tem; @@ -452,7 +448,7 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, } if (mode == -2) continue; - if (unsignedp) + if (sign_p == UNSIGNED) { unsigned HOST_WIDE_INT mh; unsigned HOST_WIDE_INT d = TREE_INT_CST_LOW (cst) & mask; @@ -581,7 +577,7 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, if (use_pow2) { tree addend = NULL_TREE; - if (!unsignedp) + if (sign_p == SIGNED) { tree uns_type; @@ -633,7 +629,7 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, } if (code == TRUNC_DIV_EXPR) { - if (unsignedp) + if (sign_p == UNSIGNED) {
wide-int, lto
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the lto code. Ok? * lto-streamer-in.c (input_cfg): Use wide-int interfaces. (lto_input_tree_1): Likewise. * lto-streamer-out.c (hash_tree): Use wide-int interfaces. (output_cfg): Likewise. lto: * lto.c (compare_tree_sccs_1): Use wide-int interfaces. * lto-lang.c (get_nonnull_operand): Use wide-int interfaces. diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index de25925..f2a3c0f 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -702,14 +702,26 @@ input_cfg (struct lto_input_block *ib, struct function *fn, loop->any_upper_bound = streamer_read_hwi (ib); if (loop->any_upper_bound) { - loop->nb_iterations_upper_bound.low = streamer_read_uhwi (ib); - loop->nb_iterations_upper_bound.high = streamer_read_hwi (ib); + HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; + int i; + int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib); + int len = streamer_read_uhwi (ib); + for (i = 0; i < len; i++) + a[i] = streamer_read_hwi (ib); + + loop->nb_iterations_upper_bound = widest_int::from_array (a, len); } loop->any_estimate = streamer_read_hwi (ib); if (loop->any_estimate) { - loop->nb_iterations_estimate.low = streamer_read_uhwi (ib); - loop->nb_iterations_estimate.high = streamer_read_hwi (ib); + HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; + int i; + int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib); + int len = streamer_read_uhwi (ib); + for (i = 0; i < len; i++) + a[i] = streamer_read_hwi (ib); + + loop->nb_iterations_estimate = widest_int::from_array (a, len); } place_new_loop (fn, loop); @@ -1259,12 +1271,17 @@ lto_input_tree_1 (struct lto_input_block *ib, struct data_in *data_in, } else if (tag == LTO_integer_cst) { - /* For shared integer constants in singletons we can use the existing - tree integer constant merging code. */ + /* For shared integer constants in singletons we can use the + existing tree integer constant merging code. */ tree type = stream_read_tree (ib, data_in); - unsigned HOST_WIDE_INT low = streamer_read_uhwi (ib); - HOST_WIDE_INT high = streamer_read_hwi (ib); - result = build_int_cst_wide (type, low, high); + unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib); + unsigned HOST_WIDE_INT i; + HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; + + for (i = 0; i < len; i++) + a[i] = streamer_read_hwi (ib); + result = wide_int_to_tree (type, wide_int::from_array +(a, len, TYPE_PRECISION (type))); streamer_tree_cache_append (data_in->reader_cache, result, hash); } else if (tag == LTO_tree_scc) diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 6f1585a..a06f386 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -714,8 +714,11 @@ hash_tree (struct streamer_tree_cache_d *cache, tree t) if (CODE_CONTAINS_STRUCT (code, TS_INT_CST)) { - v = iterative_hash_host_wide_int (TREE_INT_CST_LOW (t), v); - v = iterative_hash_host_wide_int (TREE_INT_CST_HIGH (t), v); + int i; + v = iterative_hash_host_wide_int (TREE_INT_CST_NUNITS (t), v); + v = iterative_hash_host_wide_int (TREE_INT_CST_EXT_NUNITS (t), v); + for (i = 0; i < TREE_INT_CST_NUNITS (t); i++) + v = iterative_hash_host_wide_int (TREE_INT_CST_ELT (t, i), v); } if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST)) @@ -1631,14 +1634,24 @@ output_cfg (struct output_block *ob, struct function *fn) streamer_write_hwi (ob, loop->any_upper_bound); if (loop->any_upper_bound) { - streamer_write_uhwi (ob, loop->nb_iterations_upper_bound.low); - streamer_write_hwi (ob, loop->nb_iterations_upper_bound.high); + int len = loop->nb_iterations_upper_bound.get_len (); + int i; + + streamer_write_uhwi (ob, loop->nb_iterations_upper_bound.get_precision ()); + streamer_write_uhwi (ob, len); + for (i = 0; i < len; i++) + streamer_write_hwi (ob, loop->nb_iterations_upper_bound.elt (i)); } streamer_write_hwi (ob, loop->any_estimate); if (loop->any_estimate) { - streamer_write_uhwi (ob, loop->nb_iterations_estimate.low); - streamer_write_hwi (ob, loop->nb_iterations_estimate.high); + int len = loop->nb_iterations_estimate.get_len (); + int i; + + streamer_write_uhwi (ob, loop->nb_iterations_estimate.get_precision ()); + streamer_write_uhwi (ob, len); + for (i = 0; i < len; i++) + streamer_write_h
wide-int, rs6000
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the rs6000 port. Ok? * config/rs6000/predicates.md (any_operand): Add const_wide_int. (zero_constant): Likewise. (non_logical_cint_operand): Likewise. (input_operand): Likewise. (splat_input_operand): Likewise. * config/rs6000/rs6000.c (num_insns_constant): Handle CONST_WIDE_INT. (easy_altivec_constant): Update comment. (paired_expand_vector_init): Use CONSTANT_P. (rs6000_legitimize_address): Handle CONST_WIDE_INT. (rs6000_emit_move): Update checks. (rs6000_aggregate_candidate): Use wide-int interfaces. (rs6000_expand_ternop_builtin): Likewise. (rs6000_output_move_128bit): Handle CONST_WIDE_INT. (rs6000_assemble_integer): Likewise. (rs6000_hash_constant): Likewise. (output_toc): Likewise. (rs6000_rtx_costs): Likewise. (rs6000_emit_swrsqrt); Update call to real_from_integer. * config/rs6000/rs6000-c.c: Include wide-int.h. (altivec_resolve_overloaded_builtin): Use wide-int interfaces. * config/rs6000/rs6000.h (TARGET_SUPPORTS_WIDE_INT): New. * config/rs6000/rs6000.md Use const_scalar_int_operand. Handle CONST_WIDE_INT. * config/sol2-c.c (solaris_pragma_align): Use tree_fits_uhwi_p. diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index c3118be..585df9a 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -19,7 +19,7 @@ ;; Return 1 for anything except PARALLEL. (define_predicate "any_operand" - (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem")) + (match_code "const_int,const_double,const_wide_int,const,symbol_ref,label_ref,subreg,reg,mem")) ;; Return 1 for any PARALLEL. (define_predicate "any_parallel_operand" @@ -596,7 +596,7 @@ ;; Return 1 if operand is constant zero (scalars and vectors). (define_predicate "zero_constant" - (and (match_code "const_int,const_double,const_vector") + (and (match_code "const_int,const_double,const_wide_int,const_vector") (match_test "op == CONST0_RTX (mode)"))) ;; Return 1 if operand is 0.0. @@ -790,7 +790,7 @@ ;; Return 1 if op is a constant that is not a logical operand, but could ;; be split into one. (define_predicate "non_logical_cint_operand" - (and (match_code "const_int,const_double") + (and (match_code "const_int,const_wide_int") (and (not (match_operand 0 "logical_operand")) (match_operand 0 "reg_or_logical_cint_operand" @@ -1059,7 +1059,7 @@ ;; Return 1 if this operand is a valid input for a move insn. (define_predicate "input_operand" (match_code "symbol_ref,const,reg,subreg,mem, - const_double,const_vector,const_int") + const_double,const_wide_int,const_vector,const_int") { /* Memory is always valid. */ if (memory_operand (op, mode)) @@ -1072,8 +1072,7 @@ /* Allow any integer constant. */ if (GET_MODE_CLASS (mode) == MODE_INT - && (GET_CODE (op) == CONST_INT - || GET_CODE (op) == CONST_DOUBLE)) + && CONST_SCALAR_INT_P (op)) return 1; /* Allow easy vector constants. */ @@ -1112,7 +,7 @@ ;; Return 1 if this operand is a valid input for a vsx_splat insn. (define_predicate "splat_input_operand" (match_code "symbol_ref,const,reg,subreg,mem, - const_double,const_vector,const_int") + const_double,const_wide_int,const_vector,const_int") { if (MEM_P (op)) { diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 667e5a6..8cc0dc6 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -28,6 +28,7 @@ #include "tree.h" #include "stor-layout.h" #include "stringpool.h" +#include "wide-int.h" #include "c-family/c-common.h" #include "c-family/c-pragma.h" #include "diagnostic-core.h" @@ -4208,8 +4209,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, mode = TYPE_MODE (arg1_type); if ((mode == V2DFmode || mode == V2DImode) && VECTOR_MEM_VSX_P (mode) && TREE_CODE (arg2) == INTEGER_CST - && TREE_INT_CST_HIGH (arg2) == 0 - && (TREE_INT_CST_LOW (arg2) == 0 || TREE_INT_CST_LOW (arg2) == 1)) + && wi::ltu_p (arg2, 2)) { tree call = NULL_TREE; @@ -4293,9 +4293,8 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, /* If we can use the VSX xxpermdi instruction, use that for insert. */ mode = TYPE_MODE (arg1_type); if ((mode == V2DFmode || mode == V2DImode) && VECTOR_UNIT_VSX_P (mode) - && TREE_CODE (arg2) == INTEGER_CST - && TREE_INT_CST_HIGH (arg2) == 0 - && (TREE_INT_CST_LOW (arg2) == 0 || TREE_INT_CST_LOW
wide-int, wide
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the new wide-int code. Ok? wide-int-wide.diffs.txt.bz2 Description: BZip2 compressed data
wide-int, gimple
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the gimple code. Ok? * gimple.c (preprocess_case_label_vec_for_gimple): Use wide-int interfaces. * gimple-fold.c (get_base_constructor): Use wide-int interfaces. (fold_array_ctor_reference): Likewise. (fold_nonarray_ctor_reference): Likewise. (fold_const_aggregate_ref_1): Likewise. (gimple_val_nonnegative_real_p): Likewise. (gimple_fold_indirect_ref): Likewise. * gimple-pretty-print.c (dump_ssaname_info): Use wide-int interfaces. * gimple-ssa-strength-reduction.c: Include wide-int-print.h. (struct slsr_cand_d): Change index to be widest_int. (struct incr_info_d): Change incr to be widest_int. (alloc_cand_and_find_basis): Use wide-int interfaces. (slsr_process_phi): Likewise. (backtrace_base_for_ref): Likewise. Return a widest_int. (restructure_reference): Take a widest_int instead of a double_int. (slsr_process_ref): Use wide-int interfaces. (create_mul_ssa_cand): Likewise. (create_mul_imm_cand): Likewise. (create_add_ssa_cand): Likewise. (create_add_imm_cand): Take a widest_int instead of a double_int. (slsr_process_add): Use wide-int interfaces. (slsr_process_cast): Likewise. (slsr_process_copy): Likewise. (dump_candidate): Likewise. (dump_incr_vec): Likewise. (replace_ref): Likewise. (cand_increment): Likewise. Return a widest_int. (cand_abs_increment): Likewise. (replace_mult_candidate): Take a widest_int instead of a double_int. (replace_unconditional_candidate): Use wide-int interfaces. (incr_vec_index): Take a widest_int instead of a double_int. (create_add_on_incoming_edge): Likewise. (create_phi_basis): Use wide-int interfaces. (replace_conditional_candidate): Likewise. (record_increment): Take a widest_int instead of a double_int. (record_phi_increments): Use wide-int interfaces. (phi_incr_cost): Take a widest_int instead of a double_int. (lowest_cost_path): Likewise. (total_savings): Likewise. (analyze_increments): Use wide-int interfaces. (ncd_with_phi): Take a widest_int instead of a double_int. (ncd_of_cand_and_phis): Likewise. (nearest_common_dominator_for_cands): Likewise. (insert_initializers): Use wide-int interfaces. (all_phi_incrs_profitable): Likewise. (replace_one_candidate): Likewise. (replace_profitable_candidates): Likewise. * value-prof.c (gimple_divmod_fixed_value_transform): Use wide-int interfaces. (gimple_stringops_transform): Likewise. diff --git a/gcc/gimple.c b/gcc/gimple.c index 67730bc..25f1296 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -2795,11 +2795,7 @@ preprocess_case_label_vec_for_gimple (vec labels, low = CASE_HIGH (labels[i - 1]); if (!low) low = CASE_LOW (labels[i - 1]); - if ((TREE_INT_CST_LOW (low) + 1 - != TREE_INT_CST_LOW (high)) - || (TREE_INT_CST_HIGH (low) - + (TREE_INT_CST_LOW (high) == 0) - != TREE_INT_CST_HIGH (high))) + if (wi::add (low, 1) != high) break; } if (i == len) diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 91214bc..2163187 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -2724,7 +2724,7 @@ get_base_constructor (tree base, HOST_WIDE_INT *bit_offset, { if (!tree_fits_shwi_p (TREE_OPERAND (base, 1))) return NULL_TREE; - *bit_offset += (mem_ref_offset (base).low + *bit_offset += (mem_ref_offset (base).to_short_addr () * BITS_PER_UNIT); } @@ -2819,9 +2819,10 @@ fold_array_ctor_reference (tree type, tree ctor, { unsigned HOST_WIDE_INT cnt; tree cfield, cval; - double_int low_bound, elt_size; - double_int index, max_index; - double_int access_index; + offset_int low_bound; + offset_int elt_size; + offset_int index, max_index; + offset_int access_index; tree domain_type = NULL_TREE, index_type = NULL_TREE; HOST_WIDE_INT inner_offset; @@ -2833,31 +2834,29 @@ fold_array_ctor_reference (tree type, tree ctor, /* Static constructors for variably sized objects makes no sense. */ gcc_assert (TREE_CODE (TYPE_MIN_VALUE (domain_type)) == INTEGER_CST); index_type = TREE_TYPE (TYPE_MIN_VALUE (domain_type)); - low_bound = tree_to_double_int (TYPE_MIN_VALUE (domain_type)); + low_bound = wi::to_offset (TYPE_MIN_VALUE (domain_type)); } else -low_bound = double_i
wide-int, reload
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the reload code. Ok? * postreload.c (reload_cse_simplify_set): Use wide-int interfaces. diff --git a/gcc/postreload.c b/gcc/postreload.c index b0c6342..7803b33 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -295,27 +295,27 @@ reload_cse_simplify_set (rtx set, rtx insn) #ifdef LOAD_EXTEND_OP if (extend_op != UNKNOWN) { - HOST_WIDE_INT this_val; + wide_int result; - /* ??? I'm lazy and don't wish to handle CONST_DOUBLE. Other -constants, such as SYMBOL_REF, cannot be extended. */ - if (!CONST_INT_P (this_rtx)) + if (!CONST_SCALAR_INT_P (this_rtx)) continue; - this_val = INTVAL (this_rtx); switch (extend_op) { case ZERO_EXTEND: - this_val &= GET_MODE_MASK (GET_MODE (src)); + result = wide_int::from (std::make_pair (this_rtx, + GET_MODE (src)), + BITS_PER_WORD, UNSIGNED); break; case SIGN_EXTEND: - /* ??? In theory we're already extended. */ - if (this_val == trunc_int_for_mode (this_val, GET_MODE (src))) - break; + result = wide_int::from (std::make_pair (this_rtx, + GET_MODE (src)), + BITS_PER_WORD, SIGNED); + break; default: gcc_unreachable (); } - this_rtx = GEN_INT (this_val); + this_rtx = immed_wide_int_const (result, word_mode); } #endif this_cost = set_src_cost (this_rtx, speed);
wide-int, i386
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the i386 port. Ok? * config/i386/i386.c: Include wide-int.h. (ix86_data_alignment): Use wide-int interfaces. (ix86_local_alignment): Likewise. (ix86_emit_swsqrtsf): Update real_from_integer. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 459281e..bdde693 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -67,6 +67,7 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "dumpfile.h" #include "tree-pass.h" +#include "wide-int.h" #include "context.h" #include "pass_manager.h" @@ -26176,8 +26177,7 @@ ix86_data_alignment (tree type, int align, bool opt) && AGGREGATE_TYPE_P (type) && TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= (unsigned) max_align - || TREE_INT_CST_HIGH (TYPE_SIZE (type))) + && wi::geu_p (TYPE_SIZE (type), max_align) && align < max_align) align = max_align; @@ -26188,8 +26188,8 @@ ix86_data_alignment (tree type, int align, bool opt) if ((opt ? AGGREGATE_TYPE_P (type) : TREE_CODE (type) == ARRAY_TYPE) && TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= 128 - || TREE_INT_CST_HIGH (TYPE_SIZE (type))) && align < 128) + && wi::geu_p (TYPE_SIZE (type), 128) + && align < 128) return 128; } @@ -26298,13 +26298,13 @@ ix86_local_alignment (tree exp, enum machine_mode mode, && TARGET_SSE) { if (AGGREGATE_TYPE_P (type) - && (va_list_type_node == NULL_TREE - || (TYPE_MAIN_VARIANT (type) - != TYPE_MAIN_VARIANT (va_list_type_node))) - && TYPE_SIZE (type) - && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && (TREE_INT_CST_LOW (TYPE_SIZE (type)) >= 16 - || TREE_INT_CST_HIGH (TYPE_SIZE (type))) && align < 128) + && (va_list_type_node == NULL_TREE + || (TYPE_MAIN_VARIANT (type) + != TYPE_MAIN_VARIANT (va_list_type_node))) + && TYPE_SIZE (type) + && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST + && wi::geu_p (TYPE_SIZE (type), 16) + && align < 128) return 128; } if (TREE_CODE (type) == ARRAY_TYPE) @@ -38736,7 +38736,7 @@ void ix86_emit_swsqrtsf (rtx res, rtx a, enum machine_mode mode, e2 = gen_reg_rtx (mode); e3 = gen_reg_rtx (mode); - real_from_integer (&r, VOIDmode, -3, -1, 0); + real_from_integer (&r, VOIDmode, -3, SIGNED); mthree = CONST_DOUBLE_FROM_REAL_VALUE (r, SFmode); real_arithmetic (&r, NEGATE_EXPR, &dconsthalf, NULL);
wide-int, java
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the java front end. Ok? java: * boehm.c: Include wide-int.h. (mark_reference_fields): Use a wide_int mask. (get_boehm_type_descriptor): Use wide-int interfaces. * expr.c: Include wide-int.h. (build_newarray): Remove bogus "== INTEGER_CST". (expand_java_pushc): Use real_from_integer. (build_field_ref): Use INT_CST_LT instead of INT_CST_LT_UNSIGNED. * jcf-parse.c: Include wide-int.h. (get_constant): Use wide-int interfaces. diff --git a/gcc/java/boehm.c b/gcc/java/boehm.c index 5910f03..d8ed239 100644 --- a/gcc/java/boehm.c +++ b/gcc/java/boehm.c @@ -32,8 +32,9 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "java-tree.h" #include "parse.h" #include "diagnostic-core.h" +#include "wide-int.h" -static void mark_reference_fields (tree, double_int *, unsigned int, +static void mark_reference_fields (tree, wide_int *, unsigned int, int *, int *, int *, HOST_WIDE_INT *); /* A procedure-based object descriptor. We know that our @@ -47,7 +48,7 @@ static void mark_reference_fields (tree, double_int *, unsigned int, /* Recursively mark reference fields. */ static void mark_reference_fields (tree field, - double_int *mask, + wide_int *mask, unsigned int ubit, int *pointer_after_end, int *all_bits_set, @@ -107,7 +108,7 @@ mark_reference_fields (tree field, bits for all words in the record. This is conservative, but the size_words != 1 case is impossible in regular java code. */ for (i = 0; i < size_words; ++i) - *mask = (*mask).set_bit (ubit - count - i - 1); + *mask = wi::set_bit (*mask, ubit - count - i - 1); if (count >= ubit - 2) *pointer_after_end = 1; @@ -136,16 +137,15 @@ get_boehm_type_descriptor (tree type) int last_set_index = 0; HOST_WIDE_INT last_view_index = -1; int pointer_after_end = 0; - double_int mask; tree field, value, value_type; - mask = double_int_zero; - /* If the GC wasn't requested, just use a null pointer. */ if (! flag_use_boehm_gc) return null_pointer_node; value_type = java_type_for_mode (ptr_mode, 1); + wide_int mask = wi::zero (TYPE_PRECISION (value_type)); + /* If we have a type of unknown size, use a proc. */ if (int_size_in_bytes (type) == -1) goto procedure_object_descriptor; @@ -194,22 +194,22 @@ get_boehm_type_descriptor (tree type) that we don't have to emit reflection data for run time marking. */ count = 0; - mask = double_int_zero; + mask = wi::zero (TYPE_PRECISION (value_type)); ++last_set_index; while (last_set_index) { if ((last_set_index & 1)) - mask = mask.set_bit (log2_size + count); + mask = wi::set_bit (mask, log2_size + count); last_set_index >>= 1; ++count; } - value = double_int_to_tree (value_type, mask); + value = wide_int_to_tree (value_type, mask); } else if (! pointer_after_end) { /* Bottom two bits for bitmap mark type are 01. */ - mask = mask.set_bit (0); - value = double_int_to_tree (value_type, mask); + mask = wi::set_bit (mask, 0); + value = wide_int_to_tree (value_type, mask); } else { diff --git a/gcc/java/expr.c b/gcc/java/expr.c index c62d66d..7ae852f 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -46,6 +46,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "ggc.h" #include "tree-iterator.h" #include "target.h" +#include "wide-int.h" static void flush_quick_stack (void); static void push_value (tree); @@ -1051,7 +1052,7 @@ build_newarray (int atype_value, tree length) tree prim_type = decode_newarray_type (atype_value); tree type = build_java_array_type (prim_type, -tree_fits_shwi_p (length) == INTEGER_CST +tree_fits_shwi_p (length) ? tree_to_shwi (length) : -1); /* Pass a reference to the primitive type class and save the runtime @@ -1260,7 +1261,7 @@ expand_java_pushc (int ival, tree type) else if (type == float_type_node || type == double_type_node) { REAL_VALUE_TYPE x; - REAL_VALUE_FROM_INT (x, ival, 0, TYPE_MODE (type)); + real_from_integer (&x, TYPE_MODE (type), ival, SIGNED); value = build_real (type, x); } else @@ -1717,7 +1718,7 @@ build_field_ref (tree self_value, tree self_class, tree name) tree field_offset = byte_position (field_decl); if (! page_size) page_s
wide-int, objc
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the Objective-C front end. Ok? objc: * objc-act.c: Include wide-int.h. (objc_decl_method_attributes): Use wide-int interfaces. diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index d7e8afb..2c152c7 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "tree-iterator.h" #include "hash-table.h" +#include "wide-int.h" #include "langhooks-def.h" /* Different initialization, code gen and meta data generation for each runtime. */ @@ -4882,14 +4883,10 @@ objc_decl_method_attributes (tree *node, tree attributes, int flags) which specifies the index of the format string argument. Add 2. */ number = TREE_VALUE (second_argument); - if (number - && TREE_CODE (number) == INTEGER_CST - && TREE_INT_CST_HIGH (number) == 0) - { - TREE_VALUE (second_argument) - = build_int_cst (integer_type_node, -TREE_INT_CST_LOW (number) + 2); - } + if (number && TREE_CODE (number) == INTEGER_CST) + TREE_VALUE (second_argument) + = wide_int_to_tree (TREE_TYPE (number), + wi::add (number, 2)); /* This is the third argument, the "first-to-check", which specifies the index of the first argument to @@ -4897,15 +4894,10 @@ objc_decl_method_attributes (tree *node, tree attributes, int flags) in which case we don't need to add 2. Add 2 if not 0. */ number = TREE_VALUE (third_argument); - if (number - && TREE_CODE (number) == INTEGER_CST - && TREE_INT_CST_HIGH (number) == 0 - && TREE_INT_CST_LOW (number) != 0) - { - TREE_VALUE (third_argument) - = build_int_cst (integer_type_node, -TREE_INT_CST_LOW (number) + 2); - } + if (number && TREE_CODE (number) == INTEGER_CST) + TREE_VALUE (third_argument) + = wide_int_to_tree (TREE_TYPE (number), + wi::add (number, 2)); } filtered_attributes = chainon (filtered_attributes, new_attribute); @@ -4937,15 +4929,11 @@ objc_decl_method_attributes (tree *node, tree attributes, int flags) { /* Get the value of the argument and add 2. */ tree number = TREE_VALUE (argument); - if (number - && TREE_CODE (number) == INTEGER_CST - && TREE_INT_CST_HIGH (number) == 0 - && TREE_INT_CST_LOW (number) != 0) - { - TREE_VALUE (argument) - = build_int_cst (integer_type_node, -TREE_INT_CST_LOW (number) + 2); - } + if (number && TREE_CODE (number) == INTEGER_CST + && !wi::eq_p (number, 0)) + TREE_VALUE (argument) + = wide_int_to_tree (TREE_TYPE (number), + wi::add (number, 2)); argument = TREE_CHAIN (argument); }
wide-int, misc
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the random pieces that didn't seem to fit nicely into other bins. Ok? * coretypes.h (struct hwivec_def): New. (hwivec): New. (const_hwivec): New. * dbxout.c (stabstr_U): Use wide-int interfaces. (dbxout_type): Update to use cst_fits_shwi_p. * defaults.h (TARGET_SUPPORTS_WIDE_INT): Add default. * double-int.h: Include wide-int.h. (struct wi::int_traits): New. * fixed-value.c: Include wide-int.h. (fixed_from_string): Use wide-int interfaces. (fixed_to_decimal): Likewise. (fixed_convert_from_real): Likewise. (real_convert_from_fixed): Likewise. * predict.c (predict_iv_comparison): Use wide-int interfaces. * pretty-print.h: Include wide-int-print.h. (pp_wide_int) New. * signop.h: New file. * system.h (STATIC_CONSTANT_P): New. (STATIC_ASSERT): New. * target.def (can_use_doloop_p): Take widest_ints rather than double_ints. * target.h: Include wide-int.h rather than double-int.h. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 5d60240..439b0cb 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -58,6 +58,9 @@ typedef const struct rtx_def *const_rtx; struct rtvec_def; typedef struct rtvec_def *rtvec; typedef const struct rtvec_def *const_rtvec; +struct hwivec_def; +typedef struct hwivec_def *hwivec; +typedef const struct hwivec_def *const_hwivec; union tree_node; typedef union tree_node *tree; typedef const union tree_node *const_tree; diff --git a/gcc/dbxout.c b/gcc/dbxout.c index bc6a3af..bbd8be0 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -692,88 +692,39 @@ stabstr_U (unsigned HOST_WIDE_INT num) static void stabstr_O (tree cst) { - unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (cst); - unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (cst); - - char buf[128]; - char *p = buf + sizeof buf; - - /* GDB wants constants with no extra leading "1" bits, so - we need to remove any sign-extension that might be - present. */ - { -const unsigned int width = TYPE_PRECISION (TREE_TYPE (cst)); -if (width == HOST_BITS_PER_DOUBLE_INT) - ; -else if (width > HOST_BITS_PER_WIDE_INT) - high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1); -else if (width == HOST_BITS_PER_WIDE_INT) - high = 0; -else - high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1); - } + int prec = TYPE_PRECISION (TREE_TYPE (cst)); + int res_pres = prec % 3; + int i; + unsigned int digit; /* Leading zero for base indicator. */ stabstr_C ('0'); /* If the value is zero, the base indicator will serve as the value all by itself. */ - if (high == 0 && low == 0) + if (wi::eq_p (cst, 0)) return; - /* If the high half is zero, we need only print the low half normally. */ - if (high == 0) -NUMBER_FMT_LOOP (p, low, 8); - else + /* GDB wants constants with no extra leading "1" bits, so + we need to remove any sign-extension that might be + present. */ + if (res_pres == 1) { - /* When high != 0, we need to print enough zeroes from low to -give the digits from high their proper place-values. Hence -NUMBER_FMT_LOOP cannot be used. */ - const int n_digits = HOST_BITS_PER_WIDE_INT / 3; - int i; - - for (i = 1; i <= n_digits; i++) - { - unsigned int digit = low % 8; - low /= 8; - *--p = '0' + digit; - } - - /* Octal digits carry exactly three bits of information. The -width of a HOST_WIDE_INT is not normally a multiple of three. -Therefore, the next digit printed probably needs to carry -information from both low and high. */ - if (HOST_BITS_PER_WIDE_INT % 3 != 0) - { - const int n_leftover_bits = HOST_BITS_PER_WIDE_INT % 3; - const int n_bits_from_high = 3 - n_leftover_bits; - - const unsigned HOST_WIDE_INT - low_mask = (((unsigned HOST_WIDE_INT)1) << n_leftover_bits) - 1; - const unsigned HOST_WIDE_INT - high_mask = (((unsigned HOST_WIDE_INT)1) << n_bits_from_high) - 1; - - unsigned int digit; - - /* At this point, only the bottom n_leftover_bits bits of low -should be set. */ - gcc_assert (!(low & ~low_mask)); - - digit = (low | ((high & high_mask) << n_leftover_bits)); - high >>= n_bits_from_high; - - *--p = '0' + digit; - } - - /* Now we can format high in the normal manner. However, if -the only bits of high that were set were handled by the -digit split between low and high, high will now be zero, and -we don't want to print extra digits in that case. */ -
wide-int, real
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the real.c code. Ok? * real.c: Include wide-int.h. (real_to_integer2): Delete. (real_to_integer): New function, returning a wide_int. (real_from_integer): Take a wide_int rather than two HOST_WIDE_INTs. (ten_to_ptwo): Update call to real_from_integer. (real_digit): Likewise. * real.h: Include signop.h, wide-int.h and insn-modes.h. (real_to_integer2, REAL_VALUE_FROM_INT, REAL_VALUE_FROM_UNSIGNED_INT) (REAL_VALUE_TO_INT): Delete. (real_to_integer): Declare a wide-int form. (real_from_integer): Take a wide_int rather than two HOST_WIDE_INTs. diff --git a/gcc/real.c b/gcc/real.c index c1af548..93dfc35 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -29,6 +29,7 @@ #include "realmpfr.h" #include "tm_p.h" #include "dfp.h" +#include "wide-int.h" /* The floating point model used internally is not exactly IEEE 754 compliant, and close to the description in the ISO C99 standard, @@ -1370,42 +1371,37 @@ real_to_integer (const REAL_VALUE_TYPE *r) } } -/* Likewise, but to an integer pair, HI+LOW. */ +/* Likewise, but producing a wide-int of PRECISION. If the value cannot + be represented in precision, *FAIL is set to TRUE. */ -void -real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh, - const REAL_VALUE_TYPE *r) +wide_int +real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision) { - REAL_VALUE_TYPE t; - HOST_WIDE_INT low, high; + HOST_WIDE_INT val[2 * MAX_BITSIZE_MODE_ANY_INT / HOST_BITS_PER_WIDE_INT]; int exp; + int words; + wide_int result; + int w; switch (r->cl) { case rvc_zero: underflow: - low = high = 0; - break; + return wi::zero (precision); case rvc_inf: case rvc_nan: overflow: - high = (unsigned HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1); + *fail = true; + if (r->sign) - low = 0; + return wi::set_bit_in_zero (precision - 1, precision); else - { - high--; - low = -1; - } - break; + return ~wi::set_bit_in_zero (precision - 1, precision); case rvc_normal: if (r->decimal) - { - decimal_real_to_integer2 (plow, phigh, r); - return; - } + return decimal_real_to_integer (r, fail, precision); exp = REAL_EXP (r); if (exp <= 0) @@ -1414,42 +1410,49 @@ real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh, undefined, so it doesn't matter what we return, and some callers expect to be able to use this routine for both signed and unsigned conversions. */ - if (exp > HOST_BITS_PER_DOUBLE_INT) + if (exp > precision) goto overflow; - rshift_significand (&t, r, HOST_BITS_PER_DOUBLE_INT - exp); - if (HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG) + words = (precision + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT; + + for (unsigned int i = 0; i < ARRAY_SIZE (val); i++) + val[i] = 0; + +#if (HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG) + for (int i = 0; i < words; i++) { - high = t.sig[SIGSZ-1]; - low = t.sig[SIGSZ-2]; + int j = SIGSZ - words + i; + val[i] = (j < 0) ? 0 : r->sig[j]; } - else +#else + gcc_assert (HOST_BITS_PER_WIDE_INT == 2*HOST_BITS_PER_LONG); + for (int i = 0; i < words; i++) { - gcc_assert (HOST_BITS_PER_WIDE_INT == 2*HOST_BITS_PER_LONG); - high = t.sig[SIGSZ-1]; - high = high << (HOST_BITS_PER_LONG - 1) << 1; - high |= t.sig[SIGSZ-2]; - - low = t.sig[SIGSZ-3]; - low = low << (HOST_BITS_PER_LONG - 1) << 1; - low |= t.sig[SIGSZ-4]; + int j = SIGSZ - (words * 2) + (i + 2) + 1; + if (j < 0) + val[i] = 0; + else + { + val[i] = r->sig[j]; + val[i] <<= HOST_BITS_PER_LONG; + val[i] |= r->sig[j - 1]; + } } +#endif + w = SIGSZ * HOST_BITS_PER_LONG + words * HOST_BITS_PER_WIDE_INT; + result = wide_int::from_array + (val, (w + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT, w); + result = wi::lrshift (result, (words * HOST_BITS_PER_WIDE_INT) - exp); + result = wide_int::from (result, precision, UNSIGNED); if (r->sign) - { - if (low == 0) - high = -high; - else - low = -low, high = ~high; - } - break; + return -result; + else + return result; default: gcc_unreachable (); } - - *plow = low; - *phigh = high; } /* A subroutine of real_to_decimal. Compute the quotient and remainder @@ -2112,43 +2115,88 @@ real_from_string3 (REAL_VALUE_TYPE
wide-int, sparc
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the sparc port. Ok? * config/sol2-c.c (solaris_pragma_align): Use tree_fits_uhwi_p. * config/sparc/sparc.c: Include wide-int.h. (sparc_fold_builtin): Use wide-int interfaces. diff --git a/gcc/config/sol2-c.c b/gcc/config/sol2-c.c index 8254af0..5a173ff 100644 --- a/gcc/config/sol2-c.c +++ b/gcc/config/sol2-c.c @@ -96,7 +96,7 @@ solaris_pragma_align (cpp_reader *pfile ATTRIBUTE_UNUSED) } low = TREE_INT_CST_LOW (x); - if (TREE_INT_CST_HIGH (x) != 0 + if (!tree_fits_uhwi_p (x) || (low != 1 && low != 2 && low != 4 && low != 8 && low != 16 && low != 32 && low != 64 && low != 128)) { diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 8bdc9bb..410c8ee 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -59,6 +59,7 @@ along with GCC; see the file COPYING3. If not see #include "opts.h" #include "tree-pass.h" #include "context.h" +#include "wide-int.h" /* Processor costs */ @@ -10643,30 +10644,30 @@ sparc_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, && TREE_CODE (arg2) == INTEGER_CST) { bool overflow = false; - double_int result = TREE_INT_CST (arg2); - double_int tmp; + wide_int result = arg2; + wide_int tmp; unsigned i; for (i = 0; i < VECTOR_CST_NELTS (arg0); ++i) { - double_int e0 = TREE_INT_CST (VECTOR_CST_ELT (arg0, i)); - double_int e1 = TREE_INT_CST (VECTOR_CST_ELT (arg1, i)); + tree e0 = VECTOR_CST_ELT (arg0, i); + tree e1 = VECTOR_CST_ELT (arg1, i); bool neg1_ovf, neg2_ovf, add1_ovf, add2_ovf; - tmp = e1.neg_with_overflow (&neg1_ovf); - tmp = e0.add_with_sign (tmp, false, &add1_ovf); - if (tmp.is_negative ()) - tmp = tmp.neg_with_overflow (&neg2_ovf); + tmp = wi::neg (e1, &neg1_ovf); + tmp = wi::add (e0, tmp, SIGNED, &add1_ovf); + if (wi::neg_p (tmp)) + tmp = wi::neg (tmp, &neg2_ovf); else neg2_ovf = false; - result = result.add_with_sign (tmp, false, &add2_ovf); + result = wi::add (result, tmp, SIGNED, &add2_ovf); overflow |= neg1_ovf | neg2_ovf | add1_ovf | add2_ovf; } gcc_assert (!overflow); - return build_int_cst_wide (rtype, result.low, result.high); + return wide_int_to_tree (rtype, result); } default:
wide-int, tree
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the tree code. Ok? wide-int-tree.diffs.txt.bz2 Description: BZip2 compressed data
wide-int, tree-ssa
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the tree-saa code. Ok? wide-int-tree-ssa.diffs.txt.bz2 Description: BZip2 compressed data
wide-int, vax
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.This patch covers the vax port. Ok? * config/vax/vax.c: Include wide-int.h. (vax_float_literal): Use real_from_integer. diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 7aac7cb..90da3b9 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see #include "tm_p.h" #include "target.h" #include "target-def.h" +#include "wide-int.h" static void vax_option_override (void); static bool vax_legitimate_address_p (enum machine_mode, rtx, bool); @@ -645,7 +646,7 @@ vax_float_literal (rtx c) { int x = 1 << i; bool ok; - REAL_VALUE_FROM_INT (s, x, 0, mode); + real_from_integer (&s, mode, x, SIGNED); if (REAL_VALUES_EQUAL (r, s)) return true;
Re: [C++ Patch] PR 50436
On 11/06/2013 05:56 AM, Paolo Carlini wrote: in this bug, filed by Zack, we loop forever after error in constant_value_1. Straightforward thing to do, detect and break out. This doesn't handle mutual infinite recursion, such as the modified testcase below. I think the right answer is to make sure that if we hit an instantiation depth error during instantiation of the initializer of a variable, we set DECL_INITIAL to error_mark_node. Perhaps just checking errorcount is good enough. template struct VI {}; template struct B; template struct IP { static const bool r = B::r; }; template struct B { static const bool r = IP::r; }; template struct V { VI::r> vi; }; struct X; struct Y { V v; };
Re: wide-int, testsuite
On Nov 23, 2013, at 11:22 AM, Mike Stump wrote: > Richi has asked the we break the wide-int patch so that the individual port > and front end maintainers can review their parts without have to go through > the entire patch.This patch covers the test suite. > > Ok? Ok.
Re: wide-int, objc
On Nov 23, 2013, at 11:22 AM, Mike Stump wrote: > Richi has asked the we break the wide-int patch so that the individual port > and front end maintainers can review their parts without have to go through > the entire patch.This patch covers the Objective-C front end. > > Ok? Ok.
Re: wide-int, darwin
On Nov 23, 2013, at 11:21 AM, Mike Stump wrote: > Richi has asked the we break the wide-int patch so that the individual port > and front end maintainers can review their parts without have to go through > the entire patch.This patch covers the darwin port. > > Ok? Ok.
Re: wide-int, darwin
On Nov 23, 2013, at 11:21 AM, Mike Stump wrote: > Richi has asked the we break the wide-int patch so that the individual port > and front end maintainers can review their parts without have to go through > the entire patch.This patch covers the darwin port. > > Ok? Ok.
Re: wide-int, fortran
On Sat, Nov 23, 2013 at 11:21:21AM -0800, Mike Stump wrote: > Richi has asked the we break the wide-int patch so that the individual port > and front end maintainers can review their parts without have to go through > the entire patch.This patch covers the fortran front end. > > Ok? > > + *logical = wi::eq_p (t, 0) ? 0 : 1; I can't find the meaning of :: in n1256.pdf. What does this do? Also, given the complete lack of a description of what this patch does and no pointer to a discussion of what this patch does, and no description of its benefit to gfortran, I vote "no". -- steve
Re: Fix for PR c++/59031
On 11/07/2013 02:14 PM, Easwaran Raman wrote: Before r193504, if a method can not be overridden, LOOKUP_NONVIRTUAL is set and the call is direct. The changes at r193504 (to fix PR c++/11750) caused a regression to this behavior. This patch attempts to fix that. Bootstraps and no test regressions on x86_64/linux. Is this a correct fix and is this ok for trunk? Thanks; I adjusted a couple of comments to be clearer, and changed TREE_TYPE to BINFO_TYPE. Here's what I've checked in: commit 6e2a16c94d25ad3489e21c0bb1ea238a3a27c9f7 Author: Easwaran Raman Date: Thu Nov 7 11:14:52 2013 -0800 PR c++/59031 * call.c (build_new_method_call_1): Comnpare function context with BASELINK_BINFO type rather than instance type before marking the call with LOOKUP_NONVIRTUAL. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 6a4386e..4107afa 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7514,7 +7514,7 @@ build_new_method_call_1 (tree instance, tree fns, vec **args, struct z_candidate *candidates = 0, *cand; tree explicit_targs = NULL_TREE; tree basetype = NULL_TREE; - tree access_binfo; + tree access_binfo, binfo; tree optype; tree first_mem_arg = NULL_TREE; tree name; @@ -7553,6 +7553,7 @@ build_new_method_call_1 (tree instance, tree fns, vec **args, if (!conversion_path) conversion_path = BASELINK_BINFO (fns); access_binfo = BASELINK_ACCESS_BINFO (fns); + binfo = BASELINK_BINFO (fns); optype = BASELINK_OPTYPE (fns); fns = BASELINK_FUNCTIONS (fns); if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) @@ -7799,13 +7800,13 @@ build_new_method_call_1 (tree instance, tree fns, vec **args, { /* Optimize away vtable lookup if we know that this function can't be overridden. We need to check if - the context and the instance type are the same, + the context and the type where we found fn are the same, actually FN might be defined in a different class type because of a using-declaration. In this case, we do not want to perform a non-virtual call. */ if (DECL_VINDEX (fn) && ! (flags & LOOKUP_NONVIRTUAL) && same_type_ignoring_top_level_qualifiers_p - (DECL_CONTEXT (fn), TREE_TYPE (instance)) + (DECL_CONTEXT (fn), BINFO_TYPE (binfo)) && resolves_to_fixed_type_p (instance, 0)) flags |= LOOKUP_NONVIRTUAL; if (explicit_targs) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4e26bd5..1fc4b59 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -359,7 +359,8 @@ struct GTY(()) tree_overload { /* Returns true iff NODE is a BASELINK. */ #define BASELINK_P(NODE) \ (TREE_CODE (NODE) == BASELINK) -/* The BINFO indicating the base from which the BASELINK_FUNCTIONS came. */ +/* The BINFO indicating the base in which lookup found the + BASELINK_FUNCTIONS. */ #define BASELINK_BINFO(NODE) \ (((struct tree_baselink*) BASELINK_CHECK (NODE))->binfo) /* The functions referred to by the BASELINK; either a FUNCTION_DECL, diff --git a/gcc/testsuite/g++.dg/inherit/virtual11.C b/gcc/testsuite/g++.dg/inherit/virtual11.C new file mode 100644 index 000..04c2412 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/virtual11.C @@ -0,0 +1,17 @@ +// PR c++/59031 +// { dg-do compile } +// { dg-options "-fdump-tree-gimple " } +class B { + public: + virtual int add (int a, int b) {return a+ b;} +}; + +class D : public B { +}; + +int foo (int a, int b) { + D d; + return d.add(a, b); +} +// { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } }
Re: [C++ Patch] PR 54485
I believe that our current practice is to have one error and then use inform for follow-on messages. OK with that change. Jason
Re: [C++ Patch] PR 58810
On 10/21/2013 02:05 PM, Paolo Carlini wrote: Thus the idea of resolving the inconsistency by removing completely one of the two checks: that in grokfndecl is more precise (separate messages for cv-qualifiers and ref-qualifiers) and seems the best candidate. The patch below passes testing modulo trivial adjustments to a couple of existing testcases. OK. Jason
Re: wide-int, fortran
On Sat, Nov 23, 2013 at 12:16 PM, Steve Kargl wrote: > On Sat, Nov 23, 2013 at 11:21:21AM -0800, Mike Stump wrote: >> Richi has asked the we break the wide-int patch so that the individual port >> and front end maintainers can review their parts without have to go through >> the entire patch.This patch covers the fortran front end. >> >> Ok? >> >> + *logical = wi::eq_p (t, 0) ? 0 : 1; > > I can't find the meaning of :: in n1256.pdf. What does this do? wi:: eq_p means the function eq_p inside the wi struct. > > Also, given the complete lack of a description of what this > patch does and no pointer to a discussion of what this > patch does, and no description of its benefit to gfortran, > I vote "no". The general description was in a different email: http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02877.html The main benefit is it allows for targets to support wider integer than two times HOST_WIDE_INT. So gfortran, is that it connects to the rest of the middle-end of GCC. Thanks, Andrew Pinski
Re: wide-int, fortran
On Sat, Nov 23, 2013 at 1:31 PM, Andrew Pinski wrote: > On Sat, Nov 23, 2013 at 12:16 PM, Steve Kargl > wrote: >> On Sat, Nov 23, 2013 at 11:21:21AM -0800, Mike Stump wrote: >>> Richi has asked the we break the wide-int patch so that the individual port >>> and front end maintainers can review their parts without have to go through >>> the entire patch.This patch covers the fortran front end. >>> >>> Ok? >>> >>> + *logical = wi::eq_p (t, 0) ? 0 : 1; >> >> I can't find the meaning of :: in n1256.pdf. What does this do? > > wi:: eq_p means the function eq_p inside the wi struct. > >> >> Also, given the complete lack of a description of what this >> patch does and no pointer to a discussion of what this >> patch does, and no description of its benefit to gfortran, >> I vote "no". > > The general description was in a different email: > http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02877.html > > The main benefit is it allows for targets to support wider integer > than two times HOST_WIDE_INT. So gfortran, is that it connects to the > rest of the middle-end of GCC. One more comment here, all of the changes in the gfortran front-end is the trans* functions which is the interface between the front-end and GCC middle-end. > > > Thanks, > Andrew Pinski
Re: wide-int, aarch64
On Sat, Nov 23, 2013 at 11:19 AM, Mike Stump wrote: > Richi has asked the we break the wide-int patch so that the individual port > and front end maintainers can review their parts without have to go through > the entire patch.This patch covers the aarch64 port. + wide_int w = real_to_integer (&m, &fail, HOST_BITS_PER_WIDE_INT * 2); Should we have a gcc_assert (!fail); after the real_to_integer? Other than that this seems obvious. Thanks, Andrew > > Ok? >
[wwwdocs] Announce Build Robot
Hi! Now that it's nicely working, I'd like to publically announce the Build Robot. As suggested, here's a patch adding it to GCC's homepage's "Development" section as well as to the "News": Index: index.html === RCS file: /cvs/gcc/wwwdocs/htdocs/index.html,v retrieving revision 1.898 diff -u -p -r1.898 index.html --- index.html 22 Nov 2013 11:50:45 - 1.898 +++ index.html 23 Nov 2013 21:31:28 - @@ -53,6 +53,12 @@ mission statement. +Toolchain Build Robot +[2013-11-23] +The http://toolchain.lug-owl.de/buildbot/";>Build Robot is + mass-compiling GCC (stage1 only) using contrib/config-list.mk and a + custom script on different build slaves. + Andes NDS32 support [2013-10-31] A port for nds32, the 32-bit architecture of AndesCore families, Index: style.mhtml === RCS file: /cvs/gcc/wwwdocs/htdocs/style.mhtml,v retrieving revision 1.122 diff -u -p -r1.122 style.mhtml --- style.mhtml 27 Aug 2013 20:46:29 - 1.122 +++ style.mhtml 23 Nov 2013 21:31:28 - @@ -214,6 +214,7 @@ Back ends Extensions Benchmarks + http://toolchain.lug-owl.de/buildbot/";>Build Robot Translations Ok? MfG, JBG -- Jan-Benedict Glaw jbg...@lug-owl.de +49-172-7608481 Signature of: What we do for ourselves dies with us. What we do for the second : others and the world remains and is immortal. (Albert Pine) signature.asc Description: Digital signature
Re: [C++ Patch] PR 58647
On 10/20/2013 12:07 PM, Paolo Carlini wrote: case COMPONENT_REF: + if (is_overloaded_fn (TREE_OPERAND (t, 1))) + return t; Hmm, I'd be inclined to strip the COMPONENT_REF in this case to produce something that's actually usable as a constant. Does that work? Jason
Re: [C++ Patch] PR 58607
OK. Jason
Re: [C++ Patch] PR 58700
On 10/12/2013 09:34 PM, Paolo Carlini wrote: this ICE on invalid, a 4.8/4.9 Regression, simply started when build_lang_decl_loc was introduced, which wants a location as first argument: when the declarator is null, we can't pass the location as declarator->id_loc. For now input_location can do, I think, restores the old behavior. OK. Jason
Re: [C++ Patch] PR 58633 (Take 2)
OK.
Re: wide-int, dfp
On Sat, Nov 23, 2013 at 11:21:10AM -0800, Mike Stump wrote: > * dfp.c: Include wide-int.h. > (decimal_real_to_integer2): Use wide-int interfaces and rename to > decimal_real_to_integer. > * dfp.h > (decimal_real_to_integer2): Return a wide_int and rename to > decimal_real_to_integer. OK. Thanks, Ben signature.asc Description: Digital signature
Re: wide-int, fortran
On Sat, Nov 23, 2013 at 01:31:04PM -0800, Andrew Pinski wrote: > On Sat, Nov 23, 2013 at 12:16 PM, Steve Kargl > wrote: > > On Sat, Nov 23, 2013 at 11:21:21AM -0800, Mike Stump wrote: > >> Richi has asked the we break the wide-int patch so that the individual > >> port and front end maintainers can review their parts without have to go > >> through the entire patch.This patch covers the fortran front end. > >> > >> Ok? > >> > >> + *logical = wi::eq_p (t, 0) ? 0 : 1; > > > > I can't find the meaning of :: in n1256.pdf. What does this do? > > wi:: eq_p means the function eq_p inside the wi struct. Where in n1256.pdf can I read about this feature? > > > > Also, given the complete lack of a description of what this > > patch does and no pointer to a discussion of what this > > patch does, and no description of its benefit to gfortran, > > I vote "no". > > The general description was in a different email: > http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02877.html Should have been included in the initial email. -- Steve
Re: Fwd: [PATCH] Scheduling result adjustment to enable macro-fusion
On Mon, Nov 4, 2013 at 1:51 PM, Wei Mi wrote: > Thanks! The three patches are commited as r204367, r204369 and r204371. > r204369 caused: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59020 -- H.J.
Re: wide-int, fortran
On Sat, Nov 23, 2013 at 4:26 PM, Steve Kargl wrote: > On Sat, Nov 23, 2013 at 01:31:04PM -0800, Andrew Pinski wrote: >> On Sat, Nov 23, 2013 at 12:16 PM, Steve Kargl >> wrote: >> > On Sat, Nov 23, 2013 at 11:21:21AM -0800, Mike Stump wrote: >> >> Richi has asked the we break the wide-int patch so that the individual >> >> port and front end maintainers can review their parts without have to go >> >> through the entire patch.This patch covers the fortran front end. >> >> >> >> Ok? >> >> >> >> + *logical = wi::eq_p (t, 0) ? 0 : 1; >> > >> > I can't find the meaning of :: in n1256.pdf. What does this do? >> >> wi:: eq_p means the function eq_p inside the wi struct. > > Where in n1256.pdf can I read about this feature? This is a C++ feature and not a C feature. Thanks, Andrew > >> > >> > Also, given the complete lack of a description of what this >> > patch does and no pointer to a discussion of what this >> > patch does, and no description of its benefit to gfortran, >> > I vote "no". >> >> The general description was in a different email: >> http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02877.html > > Should have been included in the initial email. > > -- > Steve
Re: wide-int, arc
On 23 November 2013 19:19, Mike Stump wrote: > Richi has asked the we break the wide-int patch so that the individual port > and front end maintainers can review their parts without have to go through > the entire patch.This patch covers the arc port. > > Ok? > wide-int.h says widest_int is always signed, yet the iterations count in the doloop interface is now unsigned. So, which is right, the code or the documentation? I see that dfp.c and vax.c directly include wide-int.h, but aarch64.c and arc.c don't. Is that safe? Is there a rationale which files directly include wide-int.h and which ones don't?
Re: wide-int, dwarf
On 11/23/2013 02:21 PM, Mike Stump wrote: - if (SCALAR_FLOAT_MODE_P (mode)) +#if TARGET_SUPPORTS_WIDE_INT == 0 + if (!SCALAR_FLOAT_MODE_P (mode)) + { + mem_loc_result->dw_loc_oprnd2.val_class + = dw_val_class_const_double; + mem_loc_result->dw_loc_oprnd2.v.val_double + = rtx_to_double_int (rtl); + } + else +#endif { unsigned int length = GET_MODE_SIZE (mode); unsigned char *array So if the target supports wide ints you'll always use the scalar float code? Why does that do the right thing? Jason
Re: wide-int, fortran
Steve Kargl writes: > On Sat, Nov 23, 2013 at 01:31:04PM -0800, Andrew Pinski wrote: >> On Sat, Nov 23, 2013 at 12:16 PM, Steve Kargl >> wrote: >> > On Sat, Nov 23, 2013 at 11:21:21AM -0800, Mike Stump wrote: >> >> Richi has asked the we break the wide-int patch so that the individual >> >> port and front end maintainers can review their parts without have to go >> >> through the entire patch.This patch covers the fortran front end. >> >> >> >> Ok? >> >> >> >> + *logical = wi::eq_p (t, 0) ? 0 : 1; >> > >> > I can't find the meaning of :: in n1256.pdf. What does this do? >> >> wi:: eq_p means the function eq_p inside the wi struct. > > Where in n1256.pdf can I read about this feature? Try n3376.pdf instead. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: wide-int, C++ front end
On 11/23/2013 02:20 PM, Mike Stump wrote: @@ -2605,8 +2606,7 @@ cp_tree_equal (tree t1, tree t2) switch (code1) { case INTEGER_CST: - return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2) - && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2); + return wi::to_widest (t1) == wi::to_widest (t2); Why not use wi::eq_p like you do in the C front end? Jason
libgo patch committed: Only call varargs from C
Reportedly in the new PPC ELF v2 ABI calls to varargs functions act differently from calls to normal functions. The Go compiler can call C functions directly using //extern comments, but it can't represent a C varargs function. Rather than extend the compiler, this patch changes the library so that C varargs functions are only called from C code, by introducing a non-varargs C function intermediary that Go can call and that simply calls the C function. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r dc9e1cbc4013 libgo/Makefile.am --- a/libgo/Makefile.am Sat Nov 23 10:55:58 2013 -0800 +++ b/libgo/Makefile.am Sat Nov 23 18:34:48 2013 -0800 @@ -488,6 +488,7 @@ runtime/go-unsafe-newarray.c \ runtime/go-unsafe-pointer.c \ runtime/go-unwind.c \ + runtime/go-varargs.c \ runtime/chan.c \ runtime/cpuprof.c \ runtime/env_posix.c \ diff -r dc9e1cbc4013 libgo/configure.ac --- a/libgo/configure.ac Sat Nov 23 10:55:58 2013 -0800 +++ b/libgo/configure.ac Sat Nov 23 18:34:48 2013 -0800 @@ -506,7 +506,7 @@ AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes) AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes) -AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat openat pipe2 removexattr renameat setxattr sync_file_range splice tee unlinkat unshare utimensat) +AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice tee unlinkat unshare utimensat) AC_TYPE_OFF_T AC_CHECK_TYPES([loff_t]) diff -r dc9e1cbc4013 libgo/go/syscall/exec_unix.go --- a/libgo/go/syscall/exec_unix.go Sat Nov 23 10:55:58 2013 -0800 +++ b/libgo/go/syscall/exec_unix.go Sat Nov 23 18:34:48 2013 -0800 @@ -30,7 +30,7 @@ //chdir(path *byte) _C_int //sysnb raw_fcntl(fd int, cmd int, arg int) (val int, err Errno) -//fcntl(fd _C_int, cmd _C_int, arg _C_int) _C_int +//__go_fcntl(fd _C_int, cmd _C_int, arg _C_int) _C_int //sysnb raw_close(fd int) (err Errno) //close(fd _C_int) _C_int diff -r dc9e1cbc4013 libgo/go/syscall/libcall_linux.go --- a/libgo/go/syscall/libcall_linux.go Sat Nov 23 10:55:58 2013 -0800 +++ b/libgo/go/syscall/libcall_linux.go Sat Nov 23 18:34:48 2013 -0800 @@ -9,7 +9,7 @@ import "unsafe" //sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) -//openat(dirfd _C_int, path *byte, flags _C_int, mode Mode_t) _C_int +//__go_openat(dirfd _C_int, path *byte, flags _C_int, mode Mode_t) _C_int //sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) //futimesat(dirfd _C_int, path *byte, times *[2]Timeval) _C_int diff -r dc9e1cbc4013 libgo/go/syscall/libcall_posix.go --- a/libgo/go/syscall/libcall_posix.go Sat Nov 23 10:55:58 2013 -0800 +++ b/libgo/go/syscall/libcall_posix.go Sat Nov 23 18:34:48 2013 -0800 @@ -206,7 +206,7 @@ //fchown(fd _C_int, uid Uid_t, gid Gid_t) _C_int //sys fcntl(fd int, cmd int, arg int) (val int, err error) -//fcntl(fd _C_int, cmd _C_int, arg _C_int) _C_int +//__go_fcntl(fd _C_int, cmd _C_int, arg _C_int) _C_int //sys Fdatasync(fd int) (err error) //fdatasync(fd _C_int) _C_int diff -r dc9e1cbc4013 libgo/go/syscall/libcall_posix_largefile.go --- a/libgo/go/syscall/libcall_posix_largefile.go Sat Nov 23 10:55:58 2013 -0800 +++ b/libgo/go/syscall/libcall_posix_largefile.go Sat Nov 23 18:34:48 2013 -0800 @@ -19,7 +19,7 @@ //mmap64(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte //sys Open(path string, mode int, perm uint32) (fd int, err error) -//open64(path *byte, mode _C_int, perm Mode_t) _C_int +//__go_open64(path *byte, mode _C_int, perm Mode_t) _C_int //sys Pread(fd int, p []byte, offset int64) (n int, err error) //pread64(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t diff -r dc9e1cbc4013 libgo/go/syscall/libcall_posix_regfile.go --- a/libgo/go/syscall/libcall_posix_regfile.go Sat Nov 23 10:55:58 2013 -0800 +++ b/libgo/go/syscall/libcall_posix_regfile.go Sat Nov 23 18:34:48 2013 -0800 @@ -20,7 +20,7 @@ //mmap(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte //sys Open(path string, mode int, perm uint32) (fd int, err error) -//open(path *byte, mode _C_int, perm Mode_t) _C_int +//__go_open(path *byte, mode _C_int, perm Mode_t) _C_int //sys Pread(fd int, p []byte, offset int64) (n int, err error) //pread(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t diff -r dc9e1cbc4013 libgo/runtime/go-varargs.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/libgo/runtime/go-varargs.c Sat Nov 23 18:34:48 2013 -0800 @@ -0,0 +1,47 @@ +/* go-varargs.c -- functions for calling C varargs functions. + + Copyright 2013 The Go Authors. All
Re: wide-int, dwarf
On 11/23/2013 08:47 PM, Jason Merrill wrote: On 11/23/2013 02:21 PM, Mike Stump wrote: - if (SCALAR_FLOAT_MODE_P (mode)) +#if TARGET_SUPPORTS_WIDE_INT == 0 + if (!SCALAR_FLOAT_MODE_P (mode)) +{ + mem_loc_result->dw_loc_oprnd2.val_class += dw_val_class_const_double; + mem_loc_result->dw_loc_oprnd2.v.val_double += rtx_to_double_int (rtl); +} + else +#endif { unsigned int length = GET_MODE_SIZE (mode); unsigned char *array So if the target supports wide ints you'll always use the scalar float code? Why does that do the right thing? Jason if TARGET_SUPPORTS_WIDE_INT != 0, then integers are NEVER placed in const-doubles. large integers go into CONST_WIDE_INTS so this case always represents a floating point constant and nothing else. So yes. I think that you could argue that the comment above this frag needs to be rewritten because it is wrong if TARGET_SUPPORTS_WIDE_INT != 0. kenny