diff mbox

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

Message ID 4DD9348A.8030807@codesourcery.com
State New
Headers show

Commit Message

Tom de Vries May 22, 2011, 4:06 p.m. UTC
On 05/21/2011 09:40 AM, Eric Botcazou wrote:
>> 2011-05-05  Tom de Vries  <tom@codesourcery.com>
>>
>> 	PR target/45098
>> 	* tree-ssa-loop-ivopts.c: Include expmed.h.
>> 	(get_shiftadd_cost): New function.
>> 	(force_expr_to_var_cost): Declare forward.  Use get_shiftadd_cost.
> 
> This breaks the Ada compiler on x86:
> 
> /home/eric/build/gcc/native32/./gcc/xgcc -B/home/eric/build/gcc/native32/./gcc/ -B/home/eric/install/gcc/i586-suse-linux/bin/ -B/home/eric/install/gcc/i586-suse-linux/lib/ -isystem /home/eric/install/gcc/i586-suse-linux/include -isystem /home/eric/install/gcc/i586-suse-linux/sys-include    -c -g -O2  -fPIC  -W -Wall -gnatpg   
> a-calend.adb -o a-calend.o
> +===========================GNAT BUG DETECTED==============================+
> | 4.7.0 20110521 (experimental) [trunk revision 173887] (i586-suse-linux-gnu) 
> GCC error:|
> | in int_cst_value, at tree.c:9970                                         |
> | Error detected around a-calend.adb:1254:7          
> 
> To reproduce, do:
>   gcc/gnat1 gcc/ada/rts/a-calend.adb -gnatg -O -Igcc/ada/rts
> in the build dir.
> 

I didn't manage to reproduce the breakage, but I think this patch will fix it.

The patch makes sure cst_and_fits_in_hwi is tested before using int_cst_value.

Regtested on x86_64.

Ok for trunk?

2011-05-22  Tom de Vries  <tom@codesourcery.com>

	PR target/45098
	* tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Fixed const test
	for call to get_shiftadd_cost.

Comments

Richard Biener May 22, 2011, 6:01 p.m. UTC | #1
On Sun, May 22, 2011 at 6:06 PM, Tom de Vries <vries@codesourcery.com> wrote:
> On 05/21/2011 09:40 AM, Eric Botcazou wrote:
>>> 2011-05-05  Tom de Vries  <tom@codesourcery.com>
>>>
>>>      PR target/45098
>>>      * tree-ssa-loop-ivopts.c: Include expmed.h.
>>>      (get_shiftadd_cost): New function.
>>>      (force_expr_to_var_cost): Declare forward.  Use get_shiftadd_cost.
>>
>> This breaks the Ada compiler on x86:
>>
>> /home/eric/build/gcc/native32/./gcc/xgcc -B/home/eric/build/gcc/native32/./gcc/ -B/home/eric/install/gcc/i586-suse-linux/bin/ -B/home/eric/install/gcc/i586-suse-linux/lib/ -isystem /home/eric/install/gcc/i586-suse-linux/include -isystem /home/eric/install/gcc/i586-suse-linux/sys-include    -c -g -O2  -fPIC  -W -Wall -gnatpg
>> a-calend.adb -o a-calend.o
>> +===========================GNAT BUG DETECTED==============================+
>> | 4.7.0 20110521 (experimental) [trunk revision 173887] (i586-suse-linux-gnu)
>> GCC error:|
>> | in int_cst_value, at tree.c:9970                                         |
>> | Error detected around a-calend.adb:1254:7
>>
>> To reproduce, do:
>>   gcc/gnat1 gcc/ada/rts/a-calend.adb -gnatg -O -Igcc/ada/rts
>> in the build dir.
>>
>
> I didn't manage to reproduce the breakage, but I think this patch will fix it.
>
> The patch makes sure cst_and_fits_in_hwi is tested before using int_cst_value.
>
> Regtested on x86_64.
>
> Ok for trunk?

Ok.

Thanks,
Richard.

> 2011-05-22  Tom de Vries  <tom@codesourcery.com>
>
>        PR target/45098
>        * tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Fixed const test
>        for call to get_shiftadd_cost.
>
Eric Botcazou May 22, 2011, 6:59 p.m. UTC | #2
> I didn't manage to reproduce the breakage, but I think this patch will fix
> it.

You need a 32-bit host.

> The patch makes sure cst_and_fits_in_hwi is tested before using
> int_cst_value.

This should be sufficient indeed, thanks.

> 2011-05-22  Tom de Vries  <tom@codesourcery.com>
>
> 	PR target/45098
> 	* tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Fixed const test
> 	for call to get_shiftadd_cost.

Present tense in the ChangeLog.
diff mbox

Patch

Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c	(revision 173703)
+++ gcc/tree-ssa-loop-ivopts.c	(working copy)
@@ -3683,7 +3683,7 @@ 
             mult = op0;
 
           if (mult != NULL_TREE
-              && TREE_CODE (TREE_OPERAND (mult, 1)) == INTEGER_CST
+              && cst_and_fits_in_hwi (TREE_OPERAND (mult, 1))
               && get_shiftadd_cost (expr, mode, cost0, cost1, mult, speed,
                                     &sa_cost))
             return sa_cost;