Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-09 Thread Kugan
On 08/09/14 19:48, Richard Biener wrote: On Sun, Sep 7, 2014 at 11:50 AM, Kugan kugan.vivekanandara...@linaro.org wrote: On 05/09/14 19:50, Richard Biener wrote: Well - the best way would be to expose the target specifics to GIMPLE at some point in the optimization pipeline. My guess

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-09 Thread Richard Biener
On Tue, Sep 9, 2014 at 12:06 PM, Kugan kugan.vivekanandara...@linaro.org wrote: On 08/09/14 19:48, Richard Biener wrote: On Sun, Sep 7, 2014 at 11:50 AM, Kugan kugan.vivekanandara...@linaro.org wrote: On 05/09/14 19:50, Richard Biener wrote: Well - the best way would be to expose the

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-08 Thread Richard Biener
On Sun, Sep 7, 2014 at 11:50 AM, Kugan kugan.vivekanandara...@linaro.org wrote: On 05/09/14 19:50, Richard Biener wrote: Well - the best way would be to expose the target specifics to GIMPLE at some point in the optimization pipeline. My guess would be that it's appropriate after loop

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-07 Thread Kugan
On 05/09/14 19:50, Richard Biener wrote: Well - the best way would be to expose the target specifics to GIMPLE at some point in the optimization pipeline. My guess would be that it's appropriate after loop optimizations (but maybe before induction variable optimization). That is, have a

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-05 Thread Richard Biener
On Fri, Sep 5, 2014 at 3:33 AM, Kugan kugan.vivekanandara...@linaro.org wrote: Here is an attempt to do the value range computation in promoted_mode's type when it is overflowing. Bootstrapped on x86-84. Err - I think you misunderstood this as a suggestion to do this ;) value-ranges should be

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-04 Thread Richard Biener
On Thu, Sep 4, 2014 at 5:41 AM, Kugan kugan.vivekanandara...@linaro.org wrote: I added this part of the code (in cfgexpand.c) to handle binary/unary/.. gimple operations and used the LHS value range to infer the assigned value range. I will revert this part of the code as this is wrong. I

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-04 Thread Kugan
Here is an attempt to do the value range computation in promoted_mode's type when it is overflowing. Bootstrapped on x86-84. Err - I think you misunderstood this as a suggestion to do this ;) value-ranges should be computed according to the type not according to the (promoted) mode.

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-03 Thread Kugan
I added this part of the code (in cfgexpand.c) to handle binary/unary/.. gimple operations and used the LHS value range to infer the assigned value range. I will revert this part of the code as this is wrong. I dont think checking promoted_mode for temp will be necessary here as convert_move

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-01 Thread Jakub Jelinek
On Wed, Aug 27, 2014 at 12:25:14PM +0200, Uros Bizjak wrote: Something like following (untested) patch that also fixes the testcase perhaps? -- cut here-- Index: cfgexpand.c === --- cfgexpand.c (revision 214445) +++

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-09-01 Thread Uros Bizjak
On Mon, Sep 1, 2014 at 10:47 AM, Jakub Jelinek ja...@redhat.com wrote: On Wed, Aug 27, 2014 at 12:25:14PM +0200, Uros Bizjak wrote: Something like following (untested) patch that also fixes the testcase perhaps? -- cut here-- Index: cfgexpand.c

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-28 Thread Marc Glisse
On Thu, 28 Aug 2014, Kugan wrote: On 27/08/14 23:02, Kugan wrote: On 27/08/14 20:01, Uros Bizjak wrote: Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode.

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-28 Thread Kugan
On 28/08/14 16:44, Marc Glisse wrote: On Thu, 28 Aug 2014, Kugan wrote: On 27/08/14 23:02, Kugan wrote: On 27/08/14 20:01, Uros Bizjak wrote: Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-28 Thread Kugan
On 27/08/14 20:07, Richard Biener wrote: On Wed, Aug 27, 2014 at 12:01 PM, Uros Bizjak ubiz...@gmail.com wrote: Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode.

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-28 Thread Richard Biener
On Thu, Aug 28, 2014 at 9:50 AM, Kugan kugan.vivekanandara...@linaro.org wrote: On 27/08/14 20:07, Richard Biener wrote: On Wed, Aug 27, 2014 at 12:01 PM, Uros Bizjak ubiz...@gmail.com wrote: Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments):

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-27 Thread Uros Bizjak
Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode. (promoted_for_signed_and_unsigned_p): New function. (expand_expr_real_1): Check promoted_for_signed_and_unsigned_p and set the

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-27 Thread Richard Biener
On Wed, Aug 27, 2014 at 12:01 PM, Uros Bizjak ubiz...@gmail.com wrote: Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode. (promoted_for_signed_and_unsigned_p): New function.

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-27 Thread Richard Biener
On Wed, Aug 27, 2014 at 12:25 PM, Uros Bizjak ubiz...@gmail.com wrote: On Wed, Aug 27, 2014 at 12:07 PM, Richard Biener richard.guent...@gmail.com wrote: 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-27 Thread Uros Bizjak
On Wed, Aug 27, 2014 at 12:07 PM, Richard Biener richard.guent...@gmail.com wrote: 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode. (promoted_for_signed_and_unsigned_p): New function.

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-27 Thread Kugan
On 27/08/14 20:01, Uros Bizjak wrote: Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode. (promoted_for_signed_and_unsigned_p): New function. (expand_expr_real_1): Check

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-27 Thread Kugan
On 27/08/14 23:02, Kugan wrote: On 27/08/14 20:01, Uros Bizjak wrote: Hello! 2014-08-07 Kugan Vivekanandarajah kug...@linaro.org * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode. (promoted_for_signed_and_unsigned_p): New function.

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-06 Thread Richard Biener
On Tue, Aug 5, 2014 at 4:21 PM, Jakub Jelinek ja...@redhat.com wrote: On Tue, Aug 05, 2014 at 04:17:41PM +0200, Richard Biener wrote: what's the semantic of setting SRP_SIGNED_AND_UNSIGNED on the subreg? That is, for the created (subreg:lhs_mode (reg:PROMOTE_MODE of ssa N))?

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-06 Thread Kugan
On 06/08/14 22:09, Richard Biener wrote: On Tue, Aug 5, 2014 at 4:21 PM, Jakub Jelinek ja...@redhat.com wrote: On Tue, Aug 05, 2014 at 04:17:41PM +0200, Richard Biener wrote: what's the semantic of setting SRP_SIGNED_AND_UNSIGNED on the subreg? That is, for the created (subreg:lhs_mode

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-06 Thread Richard Biener
On Wed, Aug 6, 2014 at 3:21 PM, Kugan kugan.vivekanandara...@linaro.org wrote: On 06/08/14 22:09, Richard Biener wrote: On Tue, Aug 5, 2014 at 4:21 PM, Jakub Jelinek ja...@redhat.com wrote: On Tue, Aug 05, 2014 at 04:17:41PM +0200, Richard Biener wrote: what's the semantic of setting

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-06 Thread Kugan
On 06/08/14 23:29, Richard Biener wrote: On Wed, Aug 6, 2014 at 3:21 PM, Kugan kugan.vivekanandara...@linaro.org wrote: On 06/08/14 22:09, Richard Biener wrote: On Tue, Aug 5, 2014 at 4:21 PM, Jakub Jelinek ja...@redhat.com wrote: On Tue, Aug 05, 2014 at 04:17:41PM +0200, Richard Biener

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-05 Thread Richard Biener
On Fri, Aug 1, 2014 at 6:03 PM, Kugan kugan.vivekanandara...@linaro.org wrote: if (rhs_uns) return wi::ge_p (min, 0); // if min = 0 then range contains positive values else return wi::le_p (max, wi::max_value (TYPE_PRECISION (TREE_TYPE (ssa)), SIGNED); // if max =

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-05 Thread Jakub Jelinek
On Tue, Aug 05, 2014 at 04:17:41PM +0200, Richard Biener wrote: what's the semantic of setting SRP_SIGNED_AND_UNSIGNED on the subreg? That is, for the created (subreg:lhs_mode (reg:PROMOTE_MODE of ssa N))? SRP_SIGNED_AND_UNSIGNED on a subreg should mean that the subreg is both zero and sign

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-03 Thread Kugan
On 02/08/14 02:03, Kugan wrote: if (rhs_uns) return wi::ge_p (min, 0); // if min = 0 then range contains positive values else return wi::le_p (max, wi::max_value (TYPE_PRECISION (TREE_TYPE (ssa)), SIGNED); // if max = signed-max-of-type then range doesn't need sign-extension I

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-01 Thread Richard Biener
On Fri, Aug 1, 2014 at 6:51 AM, Kugan kugan.vivekanandara...@linaro.org wrote: + lhs_type = lang_hooks.types.type_for_mode (lhs_mode, lhs_uns); ... + ((!lhs_uns !wi::neg_p (min, TYPE_SIGN (lhs_type))) ... + type_min = wide_int::from (TYPE_MIN_VALUE (lhs_type), prec, +

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-01 Thread Kugan
if (rhs_uns) return wi::ge_p (min, 0); // if min = 0 then range contains positive values else return wi::le_p (max, wi::max_value (TYPE_PRECISION (TREE_TYPE (ssa)), SIGNED); // if max = signed-max-of-type then range doesn't need sign-extension I think we will have to check that

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-31 Thread Kugan
+ lhs_type = lang_hooks.types.type_for_mode (lhs_mode, lhs_uns); ... + ((!lhs_uns !wi::neg_p (min, TYPE_SIGN (lhs_type))) ... + type_min = wide_int::from (TYPE_MIN_VALUE (lhs_type), prec, +TYPE_SIGN (TREE_TYPE (ssa))); + type_max = wide_int::from

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-23 Thread Richard Biener
On Mon, Jul 14, 2014 at 4:57 AM, Kugan kugan.vivekanandara...@linaro.org wrote: On 11/07/14 22:47, Richard Biener wrote: On Fri, Jul 11, 2014 at 1:52 PM, Kugan kugan.vivekanandara...@linaro.org wrote: Thanks foe the review and suggestions. On 10/07/14 22:15, Richard Biener wrote: On Mon,

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-14 Thread Bernhard Reutner-Fischer
On 14 July 2014 04:58:17 Kugan kugan.vivekanandara...@linaro.org wrote: On 11/07/14 22:47, Richard Biener wrote: On Fri, Jul 11, 2014 at 1:52 PM, Kugan kugan.vivekanandara...@linaro.org wrote: Thanks foe the review and suggestions. On 10/07/14 22:15, Richard Biener wrote: On Mon, Jul 7,

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-13 Thread Kugan
On 11/07/14 22:47, Richard Biener wrote: On Fri, Jul 11, 2014 at 1:52 PM, Kugan kugan.vivekanandara...@linaro.org wrote: Thanks foe the review and suggestions. On 10/07/14 22:15, Richard Biener wrote: On Mon, Jul 7, 2014 at 8:55 AM, Kugan kugan.vivekanandara...@linaro.org wrote: [...]

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-11 Thread Kugan
Thanks foe the review and suggestions. On 10/07/14 22:15, Richard Biener wrote: On Mon, Jul 7, 2014 at 8:55 AM, Kugan kugan.vivekanandara...@linaro.org wrote: [...] For -fwrapv, it is due to how PROMOTE_MODE is defined in arm back-end. In the test-case, a function (which has signed char

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-11 Thread Richard Biener
On Fri, Jul 11, 2014 at 1:52 PM, Kugan kugan.vivekanandara...@linaro.org wrote: Thanks foe the review and suggestions. On 10/07/14 22:15, Richard Biener wrote: On Mon, Jul 7, 2014 at 8:55 AM, Kugan kugan.vivekanandara...@linaro.org wrote: [...] For -fwrapv, it is due to how PROMOTE_MODE

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-10 Thread Richard Biener
On Mon, Jul 7, 2014 at 8:55 AM, Kugan kugan.vivekanandara...@linaro.org wrote: For -fwrapv I don't see why you'd get into trouble ever, the VRP computation should be well aware of the -fwrapv semantics and the value ranges should reflect that. For -fno-strict-overflow, I have no idea since it

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-07-07 Thread Kugan
For -fwrapv I don't see why you'd get into trouble ever, the VRP computation should be well aware of the -fwrapv semantics and the value ranges should reflect that. For -fno-strict-overflow, I have no idea since it is very weirdly defined. In any case, for your example above, the loop is

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-06-25 Thread Kugan
On 24/06/14 22:21, Jakub Jelinek wrote: On Tue, Jun 24, 2014 at 09:53:35PM +1000, Kugan wrote: 2014-06-24 Kugan Vivekanandarajah kug...@linaro.org * gcc/calls.c (precompute_arguments: Check is_promoted_for_type and set the promoted mode. (is_promoted_for_type) : New

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-06-25 Thread Jakub Jelinek
On Wed, Jun 25, 2014 at 06:14:57PM +1000, Kugan wrote: For these flags, value ranges generated are not usable for extension eliminations. Therefore, without this some of the test cases in regression fails. For example: short a; void foo (void) { for (a = 0; a = 0; a++) ; } -Os

Re: [PATCH 2/2] Enable elimination of zext/sext

2014-06-24 Thread Jakub Jelinek
On Tue, Jun 24, 2014 at 09:53:35PM +1000, Kugan wrote: 2014-06-24 Kugan Vivekanandarajah kug...@linaro.org * gcc/calls.c (precompute_arguments: Check is_promoted_for_type and set the promoted mode. (is_promoted_for_type) : New function. (expand_expr_real_1) : Check