On Thu, Aug 27, 2015 at 6:54 PM, Ajit Kumar Agarwal <ajit.kumar.agar...@xilinx.com> wrote: > > > -----Original Message----- > From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-ow...@gcc.gnu.org] On > Behalf Of Bin Cheng > Sent: Thursday, August 27, 2015 3:12 PM > To: gcc-patches@gcc.gnu.org > Subject: [PATCH GCC][rework]Improve loop bound info by simplifying > conversions in iv base > > Hi, >>>This is a rework for >>>https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02335.html, with review >>>comments addressed. For now, SCEV may compute iv base in the form of >>>>>"(signed T)((unsigned T)base + step))". This complicates other >>>optimizations/analysis depending on SCEV because it's hard to dive into type >>>conversions. >>This kind of type conversions can be simplified with >>>additional range information implied by loop initial conditions. This patch >>>does such simplification. >>>With simplified iv base, loop niter analysis can compute more accurate bound >>>information since sensible value range can be derived for "base+step". For >>>>>example, accurate loop bound&may_be_zero information is computed for cases >>>added by this patch. > >>>The code is actually moved from loop_exits_before_overflow. After this >>>patch, the corresponding code in loop_exits_before_overflow will be never >>>>>executed, so I removed that part code. The patch also includes some code >>>format changes. > >>>Bootstrap and test on x86_64. Is it OK? > > The scalar Evolution calculates the chrec ("base" , "+","step") based on > chain of recurrence through induction variable expressions and > Propagating the value in SSA representation to derive at the above chrec.. If > the base value assigned is unsigned and the declaration of I don't quite get the meaning about "If the base value assigned is unsigned...". The conversion comes from following C standard's type promotion for induction variables which have signed type smaller than int.
Thanks, bin > the base is signed, then only the above chrec is derived based on conversion > from unsigned to signed? Such type > conversions can be ignored for the calculation of iteration bound as this > cannot be overflow in any case. Is the below patch aim at that? > > Thanks & Regards > Ajit > > Thanks, > bin > > 2015-08-27 Bin Cheng <bin.ch...@arm.com> > > * tree-ssa-loop-niter.c (tree_simplify_using_condition_1): Support > new parameter. > (tree_simplify_using_condition): Ditto. > (simplify_using_initial_conditions): Ditto. > (loop_exits_before_overflow): Pass new argument to function > simplify_using_initial_conditions. Remove case for type conversions > simplification. > * tree-ssa-loop-niter.h (simplify_using_initial_conditions): New > parameter. > * tree-scalar-evolution.c (simple_iv): Simplify type conversions > in iv base using loop initial conditions. > > gcc/testsuite/ChangeLog > 2015-08-27 Bin Cheng <bin.ch...@arm.com> > > * gcc.dg/tree-ssa/loop-bound-2.c: New test. > * gcc.dg/tree-ssa/loop-bound-4.c: New test. > * gcc.dg/tree-ssa/loop-bound-6.c: New test.