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 disli

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

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)); > __bui

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 folde

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. */ >

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 (!first

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 & EDGE_IRR

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

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

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 cr

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 o

Re: Ping: RFA: Improve doloop_begin support

2012-10-16 Thread Zdenek Dvorak
> Quoting Zdenek Dvorak : > > >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? > &

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_fathe

Re: Ping: RFA: Improve doloop_begin support

2012-10-16 Thread Zdenek Dvorak
Hi, > 2012-09-26 J"orn Rennecke > > * 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. > * config/arm/thumb2.md (doloop_e

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 the

Re: Correcting transform_to_exit_first_loop + fix to PR46886

2012-04-20 Thread Zdenek Dvorak
Hi, > Ok with these changes if you give Zdenek 24h to comment, too. fine with me, Zdenek

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

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

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 i

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 a

Re: [PATCH] Fix PR 50971 and PR 35629: Only one loop detected when there should be two

2012-03-14 Thread Zdenek Dvorak
Hi, > On Tue, Mar 13, 2012 at 7:31 PM, Andrew Pinski wrote: > > Ping?  Rebootstrapped on x86_64-linux-gnu with no regressions. > > Zdenek, can you have a look here? I think the patch is reasonable, but > you should have a better idea ;) I do not understand the patch very well. In the comment

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->l

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_P

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 > an

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'; >

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 c

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 wo

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 al

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

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 s

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 K&R C specify?). > > I don't think there is a formal specification of K&R C, just the (somewhat > informal) book. On topic of pointe

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 K&R C specify?). I don't think there is a formal specification of K&R C, just the (somewhat informal) book. On topic of pointer arithmetic

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 > >> >> >        { > >> >> >

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 point

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 independen

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_b

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

2011-06-16 Thread Zdenek Dvorak
Hi, > 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 (ty

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

2011-06-16 Thread Zdenek Dvorak
Hi, > Consider the following example. > > extern unsigned int foo (int*) __attribute__((pure)); > unsigned int > tr (int array[], int n) > { > unsigned int i; > unsigned int sum = 0; > for (i = 0; i < n; i++) > sum += foo (&array[i]); > return sum; > } > > For 32-bit pointers, the an

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

2011-06-11 Thread Zdenek Dvorak
Hi, > > I think a better fix would be to make the nb_iterations_upper_bound > > semantics > > consistent with that of nb_iterations. Let me try to do it, hopefully this > > should > > be mostly mechanical, > > > > This patch changes the semantics of nb_iterations_upper_bound and > nb_iteratio

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. hm

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:

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 > > PR target/45098 > * tree-ssa-loop-niter.c (infer_loop_bounds_

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

2011-05-20 Thread Zdenek Dvorak
Hi, > On 05/18/2011 11:20 PM, Zdenek Dvorak wrote: > >> + sa_cost = (TREE_CODE (expr) != MINUS_EXPR > >> + ? shiftadd_cost[speed][mode][m] > >> + : (mult == op1 > >> +? shiftsub1_cost[speed][mode][m] > >>

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,

Re: [PATCH PR45098, 5/10] Bound cost

2011-05-18 Thread Zdenek Dvorak
Hi, > Resubmitting with comment. > > This improves the estimation of cost of bound calculation: > - It tries to estimate whether an ssa_name can be used in the loop > at zero cost, or whether a regcopy is needed to keep the ssa_name > alive during the loop, and counts the cost of the regcopy.

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

2011-05-18 Thread Zdenek Dvorak
Hi, > This patch attemps to estimate the number of iterations of the loop based on > nonwrapping arithmetic in the loop body. > > 2011-05-05 Tom de Vries > > PR target/45098 > * tree-ssa-loop-ivopts.c (struct ivopts_data): Add fields > max_iterations_p and max_iterations. >

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 e

Re: [PATCH, PR45098, 3/10]

2011-05-18 Thread Zdenek Dvorak
Hi, > 2011-05-05 Tom de Vries > > PR target/45098 > * tree-ssa-loop-ivopts.c (computation_cost): Prevent cost of 0. this looks strange. Something like cost = seq_cost (seq, speed); if (MEM_P (rslt)) the current code; else cost += rtx_cost (rslt, SET, speed)); woul

Re: [PATCH, PR45098, 2/10]

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

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

[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 i

Re: ivopts improvement

2011-03-15 Thread Zdenek Dvorak
Hi, > I'll try to explain what my intention with the code is, by looking at a > pre-ivopt level example. > > : > p_5 = p_3(D) + i_4(D); > > : > # p_1 = PHI > # i_2 = PHI > *p_1 = 0; > p_6 = p_1 + 1; > i_7 = i_2 + 1; > if (i_7 < n_8(D)) > goto ; > else > goto ; > > : >

Re: ivopts improvement

2011-03-14 Thread Zdenek Dvorak
Hi, > > (since the use_uses_inced_iv test is meaningless). > > To me it seems use_uses_inced_iv has meaning: > - it models something: it states whether the comparison is using > the iv increment result or the iv phi result. but that has nothing to do with the value of the iv. For instance, in

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'; >

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 in

Re: ivopts improvement

2011-03-14 Thread Zdenek Dvorak
Hi, > diff -u gcc/tree-ssa-loop-ivopts.c gcc/tree-ssa-loop-ivopts.c > --- gcc/tree-ssa-loop-ivopts.c(working copy) > +++ gcc/tree-ssa-loop-ivopts.c(working copy) > @@ -1194,6 +1300,7 @@ record_use (struct ivopts_data *data, tr > gimple stmt, enum use_type use_type) > { >

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