Re: [PATCH] Builtins handling in IVOPT

2013-11-22 Thread Zdenek Dvorak
Hi, If a pointer typed use is plainly value passed to a func call, it is not an address use, right? But as you said, x86 lea may help here. But that's what you are matching ... (well, for builtins you know will expand that to a memory reference). What I dislike in the patch is the

Re: [PATCH] Builtins handling in IVOPT

2013-11-22 Thread Zdenek Dvorak
Hi, If a pointer typed use is plainly value passed to a func call, it is not an address use, right? But as you said, x86 lea may help here. But that's what you are matching ... (well, for builtins you know will expand that to a memory reference). What I dislike in the patch is the

Re: [PATCH] Builtins handling in IVOPT

2013-11-21 Thread Zdenek Dvorak
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

Re: [PATCH] Fix PR57343

2013-05-27 Thread Zdenek Dvorak
Hi, Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk? PR tree-optimization/57343 * tree-ssa-loop-niter.c (number_of_iterations_ne_max): Do not use multiple_of_p if not TYPE_OVERFLOW_UNDEFINED. (number_of_iterations_cond): Do not build the folded

Re: [PATCH] Fix PR57396

2013-05-24 Thread Zdenek Dvorak
Hi, Bootstrap and regtest running on x86_64-unknown-linux-gnu. Zdenek, does this look ok? double_int_constant_multiple_p seems to be only used from aff_combination_constant_multiple_p. yes, Zdenek

Re: [PATCH] New switch optimization pass (PR tree-optimization/54742)

2013-05-15 Thread Zdenek Dvorak
Hi, I realize you're trying to do the same, but by using the SESE copier, you're implicitly trying to do an incremental update. I think you're going to really need to look at the assumptions of that code and verify that the switch FSA optimization doesn't violate those assumptions.

Re: [PATCH] Fix PR56035

2013-01-22 Thread Zdenek Dvorak
Hi, We ICEd on attached testcase because we didn't properly detected the latch edge. Furthermore, I think the code for re-computing latches is somehow broken at the moment. In fix_loop_structure we have /* If there was no latch, schedule the loop for removal. */ if

Re: [PATCH] Fix PR56035

2013-01-22 Thread Zdenek Dvorak
Hi, We ICEd on attached testcase because we didn't properly detected the latch edge. Furthermore, I think the code for re-computing latches is somehow broken at the moment. In fix_loop_structure we have /* If there was no latch, schedule the loop for removal. */ if

Re: [PATCH] Fix PR55833 + cheaper checking

2013-01-15 Thread Zdenek Dvorak
Hi, Yes, you should check whether you are in an irreducible loop. This is done by testing EDGE_IRREDUCIBLE_LOOP flag, Alright, I was wondering whether there's any other way. Unfortunately, here I couldn't do something like if (loop_preheader_edge (loop)-flags

Re: [PATCH] Fix PR55833 + cheaper checking

2013-01-14 Thread Zdenek Dvorak
Hi, On Thu, Jan 10, 2013 at 11:19:43PM +0100, Zdenek Dvorak wrote: I agree -- at the very least, unswitch_single_loop should check whether there is any possiblity it could have affected irreducible loops information (this should only be the case when some already existing irreducible

Re: [PATCH] Fix PR55833 + cheaper checking

2013-01-10 Thread Zdenek Dvorak
Hi, On Thu, Jan 10, 2013 at 6:31 PM, Marek Polacek wrote: + /* We changed the CFG. Recompute irreducible BBs and edges. */ + mark_irreducible_loops (); This is a very expensive fix for a really unusual situation. I don't think this is the right thing to do... I agree -- at the

Re: [PATCH] Fix iv_number_of_iterations (PR rtl-optimization/55838)

2013-01-03 Thread Zdenek Dvorak
Hi, When one (or both) IVs have extend_mode wider than mode, but step doesn't fit into mode (the IV is (subreg:MODE (plus:EXTEND_MODE base (mult:EXTEND_MODE i step)) lowpart) ), such as for EXTEND_MODE SImode, MODE QImode and step e.g. 129, 128, 256 or 517, iv_number_of_iterations can create

Re: [patch, mips] Fix for PR 54619, GCC aborting with -O -mips16

2012-11-15 Thread Zdenek Dvorak
Hi, I think tree-ssa-loop-ivopts is simply asking for the wrong thing, and needs to be changed. As I say, Sandra had some fixes in this area. This patch: http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00319.html Sadly, that patch has fallen off the bottom of my priority list

Re: Ping: RFA: Improve doloop_begin support

2012-10-16 Thread Zdenek Dvorak
Hi, 2012-09-26 Jorn Rennecke joern.renne...@arc.com * loop-doloop.c (doloop_modify): Pass doloop_end pattern to gen_doloop_begin. * loop-doloop.c (doloop_optimize): Pass flag to indicate if loop is entered at top to gen_doloop_end. *

Re: Ping: RFA: Improve doloop_begin support

2012-10-16 Thread Zdenek Dvorak
Hi, The loop appears to be entered at the top, yet both my original and your test fail. Looking what happens with your test in more detail, I find that loop-latch == desc-in_edge-dest is true, but forwarder_block_p (loop-latch) fails: 562 if (dest-loop_father-header ==

Re: Ping: RFA: Improve doloop_begin support

2012-10-16 Thread Zdenek Dvorak
Quoting Zdenek Dvorak rakd...@iuuk.mff.cuni.cz: no -- you should also test that latch contains no active insns. I.e., factorize out whatever forwarder_block_p does except for the test (dest-loop_father-header == dest) test, Like this? * basic-block.h (forwarder_block_p_1

Re: [RFC, ivopts] fix bugs in ivopts address cost computation

2012-06-06 Thread Zdenek Dvorak
Hi, (7) If the computed address cost turns out to be 0, the current code (for some unknown reason) is turning that into 1, which can screw up the relative costs of address computations vs other operations like addition. I've come up with the attached patch to try to fix these things.  

Re: Preserve pointer types in ivopts

2012-03-16 Thread Zdenek Dvorak
Yes, that could work. ?Though it might end up being incredibly ugly ;) In the code? Should really only change a few lines in the patch I would have thought. I'll get back to you when I have a new version - thanks for the tip. No, in the GIMPLE IL. Richard. And I can just imagine

Re: Preserve pointer types in ivopts

2012-03-16 Thread Zdenek Dvorak
Hello, On 03/16/2012 02:46 PM, Richard Guenther wrote: In the end what we want is a POINTER_PLUS_EXPR variant that does not make alias-analysis assume the result still points to within the objects the pointer pointed to before the increment/decrement. Hold on, is alias analysis really

Re: Preserve pointer types in ivopts

2012-03-15 Thread Zdenek Dvorak
Hi, Currently, tree-ssa-loop-ivopts assumes that pointers and integers can be used interchangeably. It prefers to compute everything in unsigned integer types rather than pointer types. On a new target that I'm working on, this assumption is problematic; casting a pointer to an integer and

Re: Preserve pointer types in ivopts

2012-03-15 Thread Zdenek Dvorak
Hi, Well, what are our rules for whether overflow on POINTER_PLUS_EXPR is defined or not? A quick search through the headers and docs doesn't turn up anything. Would there be a downside to defining it as wrapping? Can you show an example where a POINTER_PLUS_EXPR produced by ivopts

Re: [PATCH] Fix RTL sharing bug in loop unswitching (PR rtl-optimization/52092)

2012-02-03 Thread Zdenek Dvorak
Hi, It seems loop-iv.c happily creates shared RTL in lots of places, loop-unroll.c solves that by unsharing everything it adds, this is an attempt to do the same in unswitching to unshare everything iv_analyze came up with. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for

Re: PR rtl-optimization/49710 (segfault in loop peeling)

2012-01-04 Thread Zdenek Dvorak
Hi, --- 316,333 normally. We may assume that e-dest is not a header of any loop, as it now has exactly one predecessor. */ while (loop_outer (e-src-loop_father) ! dominated_by_p (CDI_DOMINATORS, !e-src-loop_father-latch,

Re: PR rtl-optimization/51069 (verify_loop_info failed)

2011-12-28 Thread Zdenek Dvorak
Hi, Just a nit, can't you break out of the loop when irred_invalidated is set to true as well? There is no need to look through any further edges. I.e. perhaps: if (!irred_invalidated) FOR_EACH_EDGE (ae, ei, e-src-succs) if (ae != e ae-dest != EXIT_BLOCK_PTR

Re: [PATCH, PR50322] Fix test-case ivopts-lt.c to use int of same size as pointer.

2011-09-14 Thread Zdenek Dvorak
Hi, The attached patch fixes PR50322. The test-case is supposed to succeed if the loop counter data-type has the same size as a pointer. The patch defines TYPE to be an int datatype of the same size as a pointer, and uses it. After this fix, there's no need for the avr xfails anymore.

Re: ivopts improvement

2011-08-25 Thread Zdenek Dvorak
Hi, here's the updated version of the patch. The goal is to remove the 'i' iterator from the following example, by replacing 'i n' with 'p base + n'. void f (char *base, unsigned long int i, unsigned long int n) { char *p = base + i; do { *p = '\0'; p++;

Re: [PATCH 2/2] Fix PR47594: Build signed niter expressions

2011-08-02 Thread Zdenek Dvorak
Hi, * tree-ssa-loop-niter.c (number_of_iterations_ne): Use the signed types for the trivial case, then convert to unsigned. (number_of_iterations_lt): Use the original signed types. (number_of_iterations_cond): Same. (find_loop_niter): Build signed integer

Re: [patch] Fix PR tree-optimization/49471

2011-07-31 Thread Zdenek Dvorak
Hi, It'll collide with Sebastians patch in that area.  I suggested a INTEGRAL_TYPE_P check instead of the simple_iv one, it should be cheaper.  Zdenek, do you think it will be incorrect in some cases? well, it does not make much sense -- reductions of integral type would be taken

Re: [patch] Fix PR tree-optimization/49471

2011-07-30 Thread Zdenek Dvorak
Hi, This patch fixes the build failure of cactusADM and dealII spec2006 benchmarks when autopar is enabled. (for powerpc they fail only when -m32 is additionally enabled) The problem originated in canonicalize_loop_ivs, where we iterate the header's phis in order to base all the

Re: PATCH] PR 49580

2011-07-05 Thread Zdenek Dvorak
Hi, I moved the adjustment of the loop's iterations from gimple_duplicate_sese_tail to tree-parloops.c, right before the call to gimple_duplicate_sese_tail. I repeated the bootstrap, regression and spec runs - no new regressions. OK to commit? OK, Zdenek Index: gcc/tree-parloops.c

Re: PATCH] PR 49580

2011-06-30 Thread Zdenek Dvorak
Hi, This patch fixes the build failure of gcc spec2006 benchmark. The change is in gimple_duplicate_sese_tail(), where we need to subtract 1 from the loop's number of iterations. The stmt created to change the rhs of the loop's condition, used to be inserted right after the defining stmt

Re: [PATCH PR45098] Disallow NULL pointer in pointer arithmetic

2011-06-20 Thread Zdenek Dvorak
I don't think we should move this kind of undefinedness from C to the GIMPLE semantics. What do other languages allow that we have to support (what did KR C specify?). I don't think there is a formal specification of KR C, just the (somewhat informal) book. On topic of pointer arithmetics,

Re: [PATCH PR45098] Disallow NULL pointer in pointer arithmetic

2011-06-20 Thread Zdenek Dvorak
I don't think we should move this kind of undefinedness from C to the GIMPLE semantics. What do other languages allow that we have to support (what did KR C specify?). I don't think there is a formal specification of KR C, just the (somewhat informal) book. On topic of pointer

Re: [PATCH PR45098] Disallow NULL pointer in pointer arithmetic

2011-06-17 Thread Zdenek Dvorak
Interesting.  I'd never thought about the generation/use angle to prove a pointer was non-null.  ISTM we could use that same logic to infer that more pointers are non-null in extract_range_from_binary_expr. Interested in tackling that improvement, obviously as an independent patch?

Re: [PATCH PR45098] Disallow NULL pointer in pointer arithmetic

2011-06-17 Thread Zdenek Dvorak
Hi, Index: tree-vrp.c === --- tree-vrp.c  (revision 173703) +++ tree-vrp.c  (working copy) @@ -2273,7 +2273,12 @@ extract_range_from_binary_expr (value_ra        {          /* For pointer types, we are really

Re: [PATCH PR45098] Disallow NULL pointer in pointer arithmetic

2011-06-16 Thread Zdenek Dvorak
diff -u gcc/tree-ssa-loop-niter.c (working copy) gcc/tree-ssa-loop-niter.c (working copy) --- gcc/tree-ssa-loop-niter.c (working copy) +++ gcc/tree-ssa-loop-niter.c (working copy) @@ -2875,6 +2875,16 @@    low = lower_bound_in_type (type, type);    high = upper_bound_in_type (type,

Re: [PATCH PR45098, 7/10] Nowrap limits iterations

2011-05-31 Thread Zdenek Dvorak
Hi, As far as I can tell, what is current calculated in i_bound (and assigned to nb_iterations_upper_bound), is the maximum amount of times any statement in the loop is executed, where any includes exit tests. Differently put, the maximum amount of times the loop header is executed. hmm...

Re: [PATCH PR45098, 7/10] Nowrap limits iterations

2011-05-30 Thread Zdenek Dvorak
Hi, The header block of the loop is bb 4, the latch block is bb 3: ... (gdb) p loop.header.index $4 = 4 (gdb) p loop.latch.index $5 = 3 ... The number of times the latch edge is executed, is 10. But loop-nb_iterations_upper_bound, or max_niter is 11: this is a bit

Re: [PATCH, PR49121] [4.7 Regression] FAIL: gcc.dg/tree-ssa/ivopt_infer_2.c scan-tree-dump-times ivopts Replacing 0

2011-05-24 Thread Zdenek Dvorak
Hi, The analysis is correct, and the test case needs to be adapted. I adapted the testcase such that it still replaces the exit test if 'a' is declared as 'char a[400]', but not if it is declared as 'extern char a[]'. ok for trunk? OK, Zdenek

Re: [PATCH PR45098, 7/10] Nowrap limits iterations

2011-05-21 Thread Zdenek Dvorak
Hi, Would it be possible to add the handling of these cases to estimate_numbers_of_iterations, rather than doing it just for ivopts? Yes, I did that now. Thanks, - Tom 2011-05-05 Tom de Vries t...@codesourcery.com PR target/45098 * tree-ssa-loop-niter.c

Re: [PATCH, PR45098, 2/10]

2011-05-18 Thread Zdenek Dvorak
Hi, 2011-05-05 Tom de Vries t...@codesourcery.com PR target/45098 * tree-ssa-loop-ivopts.c (seq_cost): Fix call to rtx_cost. OK, Zdenek

Re: [PATCH PR45098, 4/10] Iv init cost.

2011-05-18 Thread Zdenek Dvorak
Hi, Resubmitting with comment. The init cost of an iv will in general not be zero. It will be exceptional that the iv register happens to be initialized with the proper value at no cost. In general, there will at the very least be a regcopy or a const set. OK. Please add a comment

Re: [PATCH PR45098, 9/10] Cheap shift-add.

2011-05-18 Thread Zdenek Dvorak
Hi, + sa_cost = (TREE_CODE (expr) != MINUS_EXPR + ? shiftadd_cost[speed][mode][m] + : (mult == op1 +? shiftsub1_cost[speed][mode][m] +: shiftsub0_cost[speed][mode][m])); + res = new_cost (sa_cost, 0); + res = add_costs (res, mult

Re: [PATCH, SMS 3/3] Skip DEBUG_INSN in loop-doloop.c

2011-05-08 Thread Zdenek Dvorak
Hi, This small fix was inserted to skip DEBUG_INSNs while recognizing doloop pattern in loop-doloop.c file. It's a fix for the already approved do-loop patch (not in mainline yet, http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01718.html) in loop-doloop.c The patch was tested together with

[patch] PR 48837

2011-05-06 Thread Zdenek Dvorak
Hi, when accumulator transformation is performed on a function like foo(a) { if (a 0) return 1 + foo (a - 1) return bla(); } this becomes foo(a) { int tmp = 0; while (a 0) tm = 1 + tmp; return tmp + bla(); } Before, bla was a tail-call, but after the optimization, it is

Re: ivopts improvement

2011-03-14 Thread Zdenek Dvorak
Hi, + /* Determine if the exit test is formulated in terms of the phi or the + increment of the use iv. */ + use_uses_inced_iv += gimple_code (SSA_NAME_DEF_STMT (use-iv-ssa_name)) != GIMPLE_PHI; + + /* Determine if the exit test is before or after the increment of the +

Re: ivopts improvement

2011-03-14 Thread Zdenek Dvorak
Hi, it is trying to allow for do { *p = '\0'; i++; /* use_uses_inced_iv == true */ p++; /* use_after_cand_inc == true */ if (!(i n)) break; } while (1); and for do { *p = '\0'; if (!(i n)) break; i++; /*

Re: ivopts improvement

2011-03-04 Thread Zdenek Dvorak
Hi, /* Whether the loop body includes any function calls. */ bool body_includes_call; + + /* Whether the loop body includes any function calls that possibly have side + effects. */ + bool body_includes_side_effect_call; }; /* An assignment of iv candidates to uses.