* [RFC PATCH, i386]: Implement ix86_set_reg_reg_cost, fix PR 53250 "Splitting reg" failure.
@ 2012-05-07 20:35 Uros Bizjak
2012-05-07 20:40 ` Uros Bizjak
0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2012-05-07 20:35 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Sandiford
Hello!
Attached patch implements reg->reg move cost function for x86, as
required by new lower-subreg.c patch. The patch fixes:
FAIL: gcc.dg/lower-subreg-1.c scan-rtl-dump subreg1 "Splitting reg"
failure on 32bit x86 targets, and for following testcase:
long long test (long long a, long long b)
{
return a * b;
}
reverts generated asm code from:
test:
subl $12, %esp
movl %edi, 8(%esp)
movl 28(%esp), %edi
movl %ebx, (%esp)
movl 16(%esp), %ecx
movl %esi, 4(%esp)
movl 20(%esp), %ebx
movl 24(%esp), %esi
movl %edi, %eax
imull %ecx, %eax
imull %esi, %ebx
addl %eax, %ebx
movl %ecx, %eax
mull %esi
movl 4(%esp), %esi
movl %edx, %edi
addl %ebx, %edi
movl (%esp), %ebx
movl %edi, %edx
movl 8(%esp), %edi
addl $12, %esp
ret
back to:
test:
pushl %ebx
movl 8(%esp), %edx
movl 16(%esp), %eax
movl 12(%esp), %ebx
movl 20(%esp), %ecx
imull %eax, %ebx
imull %edx, %ecx
mull %edx
addl %ebx, %ecx
addl %ecx, %edx
popl %ebx
ret
Patch was tested on x86_64-pc-linux-gnu {,-m32}.
I have also #define LOG_COST 1 temporarily and looked at generated
cost calculations for various -msse* settings.
I will wait for a day for possible comments on the implementation
before the patch will be committed to mainline SVN.
Uros.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH, i386]: Implement ix86_set_reg_reg_cost, fix PR 53250 "Splitting reg" failure.
2012-05-07 20:35 [RFC PATCH, i386]: Implement ix86_set_reg_reg_cost, fix PR 53250 "Splitting reg" failure Uros Bizjak
@ 2012-05-07 20:40 ` Uros Bizjak
2012-05-08 16:03 ` Uros Bizjak
0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2012-05-07 20:40 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Sandiford
[-- Attachment #1: Type: text/plain, Size: 564 bytes --]
On Mon, May 7, 2012 at 10:35 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
Now with a patch and ChangeLog:
2012-05-07 Uros Bizjak <ubizjak@gmail.com>
PR target/53250
* config/i386/i386.c (ix86_set_reg_reg_cost): New function.
(ix86_rtx_costs): Handle SET.
> Patch was tested on x86_64-pc-linux-gnu {,-m32}.
>
> I have also #define LOG_COST 1 temporarily and looked at generated
> cost calculations for various -msse* settings.
>
> I will wait for a day for possible comments on the implementation
> before the patch will be committed to mainline SVN.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 2246 bytes --]
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 187259)
+++ config/i386/i386.c (working copy)
@@ -31861,6 +31861,52 @@ ix86_modes_tieable_p (enum machine_mode mode1, enu
return false;
}
+/* Return the cost of moving between two registers of mode MODE. */
+
+static int
+ix86_set_reg_reg_cost (enum machine_mode mode)
+{
+ unsigned int units = UNITS_PER_WORD;
+
+ switch (GET_MODE_CLASS (mode))
+ {
+ default:
+ break;
+
+ case MODE_CC:
+ units = GET_MODE_SIZE (CCmode);
+ break;
+
+ case MODE_FLOAT:
+ if ((TARGET_SSE2 && mode == TFmode)
+ || (TARGET_80387 && mode == XFmode)
+ || ((TARGET_80387 || TARGET_SSE2) && mode == DFmode)
+ || ((TARGET_80387 || TARGET_SSE) && mode == SFmode))
+ units = GET_MODE_SIZE (mode);
+ break;
+
+ case MODE_COMPLEX_FLOAT:
+ if ((TARGET_SSE2 && mode == TCmode)
+ || (TARGET_80387 && mode == XCmode)
+ || ((TARGET_80387 || TARGET_SSE2) && mode == DCmode)
+ || ((TARGET_80387 || TARGET_SSE) && mode == SCmode))
+ units = GET_MODE_SIZE (mode);
+ break;
+
+ case MODE_VECTOR_INT:
+ case MODE_VECTOR_FLOAT:
+ if ((TARGET_AVX && VALID_AVX256_REG_MODE (mode))
+ || (TARGET_SSE2 && VALID_SSE2_REG_MODE (mode))
+ || (TARGET_SSE && VALID_SSE_REG_MODE (mode))
+ || (TARGET_MMX && VALID_MMX_REG_MODE (mode)))
+ units = GET_MODE_SIZE (mode);
+ }
+
+ /* Return the cost of moving between two registers of mode MODE,
+ assuming that the move will be in pieces of at most UNITS bytes. */
+ return COSTS_N_INSNS ((GET_MODE_SIZE (mode) + units - 1) / units);
+}
+
/* Compute a (partial) cost for rtx X. Return true if the complete
cost has been computed, and false if subexpressions should be
scanned. In either case, *TOTAL contains the cost result. */
@@ -31875,6 +31921,15 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i,
switch (code)
{
+ case SET:
+ if (register_operand (SET_DEST (x), VOIDmode)
+ && reg_or_0_operand (SET_SRC (x), VOIDmode))
+ {
+ *total = ix86_set_reg_reg_cost (GET_MODE (SET_DEST (x)));
+ return true;
+ }
+ return false;
+
case CONST_INT:
case CONST:
case LABEL_REF:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH, i386]: Implement ix86_set_reg_reg_cost, fix PR 53250 "Splitting reg" failure.
2012-05-07 20:40 ` Uros Bizjak
@ 2012-05-08 16:03 ` Uros Bizjak
0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2012-05-08 16:03 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Sandiford
On Mon, May 7, 2012 at 10:40 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> 2012-05-07 Uros Bizjak <ubizjak@gmail.com>
>
> PR target/53250
> * config/i386/i386.c (ix86_set_reg_reg_cost): New function.
> (ix86_rtx_costs): Handle SET.
>
>> Patch was tested on x86_64-pc-linux-gnu {,-m32}.
>>
>> I have also #define LOG_COST 1 temporarily and looked at generated
>> cost calculations for various -msse* settings.
>>
>> I will wait for a day for possible comments on the implementation
>> before the patch will be committed to mainline SVN.
Committed to mainline SVN at r187289.
Uros.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-08 16:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-07 20:35 [RFC PATCH, i386]: Implement ix86_set_reg_reg_cost, fix PR 53250 "Splitting reg" failure Uros Bizjak
2012-05-07 20:40 ` Uros Bizjak
2012-05-08 16:03 ` Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).