Re: divide 64-bit by constant for 32-bit target machines

2012-06-15 Thread Richard Earnshaw
On 14/06/12 19:46, Dinar Temirbulatov wrote: Hi, OK for trunk? thanks, Dinar. I'm still not comfortable about the code bloat that this is likely to incurr at -O2. R. On Tue, Jun 12, 2012 at 11:00 AM, Paolo Bonzini bonz...@gnu.org wrote: Il 12/06/2012 08:52, Dinar

Re: divide 64-bit by constant for 32-bit target machines

2012-06-15 Thread Dinar Temirbulatov
Hi, Richard, How about if I add and utilize umul_highpart_di to the libgcc instead of expanding multiplication for the high part directly, or add my own function with with pre-shift, post-shift, and 64-bit constant and 64-bit operand as function parameters for division for less than -O3?

Re: divide 64-bit by constant for 32-bit target machines

2012-06-14 Thread Dinar Temirbulatov
Hi, OK for trunk? thanks, Dinar. On Tue, Jun 12, 2012 at 11:00 AM, Paolo Bonzini bonz...@gnu.org wrote: Il 12/06/2012 08:52, Dinar Temirbulatov ha scritto: is safe?  That is, that the underflows cannot produce a wrong result? [snip] Thanks very much! Paolo 2012-06-14

Re: divide 64-bit by constant for 32-bit target machines

2012-06-08 Thread Dinar Temirbulatov
Hi, Paolo. Here is the new version of patch. I have tested this version with gcc testsuite only on i686 without new regressions, for now. Mips and arm tests are in progress. One strange thing I noticed: No need for this gen_reg_rtx, either, by passing a NULL_RTX target below. +      

Re: divide 64-bit by constant for 32-bit target machines

2012-06-07 Thread Dinar Temirbulatov
Hi, Here is new version of patch based up on Paolo review, again tested on arm-7l, mips-32r2 (74k), i686 without new regressions. thanks, Dinar. On Sat, May 26, 2012 at 4:45 PM, Paolo Bonzini bonz...@gnu.org wrote: Il 26/05/2012 14:35, Paolo Bonzini ha scritto:        

Re: divide 64-bit by constant for 32-bit target machines

2012-06-07 Thread Paolo Bonzini
Il 07/06/2012 12:21, Dinar Temirbulatov ha scritto: oh, I found typo in comment in the end of patch. fixed. Great improvement, thanks! Unfortunately we're not there yet, but much closer! I could understand the new code much better so I suggest some more improvements below, both to the comments

Re: divide 64-bit by constant for 32-bit target machines

2012-05-26 Thread Paolo Bonzini
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 2cecf45..9d6983b 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -7131,6 +7131,8 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) *total = COSTS_N_INSNS (2); else if

Re: divide 64-bit by constant for 32-bit target machines

2012-05-26 Thread Paolo Bonzini
Il 25/05/2012 12:20, Dinar Temirbulatov ha scritto: + emit_store_flag_force (c, GT, u0, tmp, mode, 1, 1); + emit_store_flag_force (c1, GT, u1, tmp, mode, 1, 1); + result = expand_binop (mode, ior_optab, c, c1, cres, 1, OPTAB_LIB_WIDEN); + if (!result) + return

Re: divide 64-bit by constant for 32-bit target machines

2012-05-26 Thread Paolo Bonzini
Il 26/05/2012 14:35, Paolo Bonzini ha scritto: /* We have to return z2 + ((u0 + u1) GET_MODE_BITSIZE (word_mode)). u0 + u1 are the upper two words of the three-word intermediate result and they could have up to 2 * GET_MODE_BITSIZE

Re: divide 64-bit by constant for 32-bit target machines

2012-05-25 Thread Dinar Temirbulatov
Hi, I have replaced expand_mult to expand_widening_mult and removed all direct references to DImode, SImode modes in the expand_mult_highpart_optab funtion. The attached patch was tested on arm-7l, mips-32r2 (74k), i686 without new regressions. Richard, do you think it is ready now?

Re: divide 64-bit by constant for 32-bit target machines

2012-05-22 Thread Dinar Temirbulatov
Hi, Here is the new version of the patch I have fixed two errors in the previous version, on mips32 the compiler could not expand division and terminated with ICE, this change fixed the issue: /* Extrating the higher part of the sum */ tmp = gen_highpart (SImode, tmp); tmp

Re: divide 64-bit by constant for 32-bit target machines

2012-05-22 Thread Richard Henderson
On 05/22/12 07:05, Dinar Temirbulatov wrote: + if ((size - 1 BITS_PER_WORD +BITS_PER_WORD == 32 mode == DImode) Do note that this patch will not go in with hard-coded SImode and DImode references. Which, really, you do not even need. GET_MODE_BITSIZE (mode) == 2*BITS_PER_WORD

Re: divide 64-bit by constant for 32-bit target machines

2012-05-03 Thread Dinar Temirbulatov
Hi, Here is updated version of patch. I added comments describing the algorithm. Hi Dinar.  I'm afraid it gives the wrong results for some dividends  * 82625484914982912 / 2023346444509052928: gives 4096, should be zero  * 18317463604061229328 / 2023346444509052928: gives 4109, should be 9  *

Re: divide 64-bit by constant for 32-bit target machines

2012-05-03 Thread Richard Earnshaw
On 03/05/12 11:27, Dinar Temirbulatov wrote: Hi, Here is updated version of patch. I added comments describing the algorithm. Hi Dinar. I'm afraid it gives the wrong results for some dividends * 82625484914982912 / 2023346444509052928: gives 4096, should be zero * 18317463604061229328 /

Re: divide 64-bit by constant for 32-bit target machines

2012-04-23 Thread Andrew Haley
On 04/20/2012 01:57 PM, Dinar Temirbulatov wrote: Here is the patch that adds support for divide 64-bit by constant for 32-bit target machines, this patch was tested on arm-7a with no new regressions, also I am not sure on how to avoid for example i686 targets since div operation there is fast

Re: divide 64-bit by constant for 32-bit target machines

2012-04-23 Thread Michael Hope
On 21 April 2012 00:57, Dinar Temirbulatov dtemirbula...@gmail.com wrote: Hi, Here is the patch that adds support for divide 64-bit by constant for 32-bit target machines, this patch was tested on arm-7a with no new regressions, also I am not sure on how to avoid for example i686 targets

divide 64-bit by constant for 32-bit target machines

2012-04-20 Thread Dinar Temirbulatov
Hi, Here is the patch that adds support for divide 64-bit by constant for 32-bit target machines, this patch was tested on arm-7a with no new regressions, also I am not sure on how to avoid for example i686 targets since div operation there is fast compared to over targets and it showed better