* Two more doloop patches
@ 2009-04-03 12:45 Bernd Schmidt
2009-04-03 17:53 ` Zdenek Dvorak
0 siblings, 1 reply; 3+ messages in thread
From: Bernd Schmidt @ 2009-04-03 12:45 UTC (permalink / raw)
To: GCC Patches; +Cc: Zdenek Dvorak
[-- Attachment #1: Type: text/plain, Size: 857 bytes --]
These two patches strengthen functions in loop-iv.c so that we allow
frame and stack pointers in the expressions we're examining. For loops
that walk an array on the stack, the exit test often is a pointer
comparison involving addresses based on fp or sp, and the compiler can
make useful simplifications if these substitutions are allowed.
Bootstrapped and regression tested on i686-linux (irrelevant extra
failures in libmudflap due to expect truncating compilre output).
Equivalent patches have been in our Blackfin 4.3 tree for a while now
and had a fair amount of testing.
Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
[-- Attachment #2: fn-invariant.diff --]
[-- Type: text/plain, Size: 1638 bytes --]
* loop-iv.c (replace_single_def_regs): Follow chains of
single-definition regs. Use reg notes where possible. Allow not just
constants, but anything that's function_invariant_p.
Index: loop-iv.c
===================================================================
--- loop-iv.c (revision 145357)
+++ loop-iv.c (working copy)
@@ -1376,23 +1376,43 @@ replace_single_def_regs (rtx *reg, void
{
unsigned regno;
df_ref adef;
- rtx set;
+ rtx set, src;
rtx *expr = (rtx *)expr1;
if (!REG_P (*reg))
return 0;
regno = REGNO (*reg);
- adef = DF_REG_DEF_CHAIN (regno);
- if (adef == NULL || DF_REF_NEXT_REG (adef) != NULL
- || DF_REF_IS_ARTIFICIAL (adef))
- return -1;
+ for (;;)
+ {
+ rtx note;
+ adef = DF_REG_DEF_CHAIN (regno);
+ if (adef == NULL || DF_REF_NEXT_REG (adef) != NULL
+ || DF_REF_IS_ARTIFICIAL (adef))
+ return -1;
- set = single_set (DF_REF_INSN (adef));
- if (set == NULL || SET_DEST (set) != *reg || !CONSTANT_P (SET_SRC (set)))
+ set = single_set (DF_REF_INSN (adef));
+ if (set == NULL || !REG_P (SET_DEST (set))
+ || REGNO (SET_DEST (set)) != regno)
+ return -1;
+
+ note = find_reg_equal_equiv_note (DF_REF_INSN (adef));
+ if (note && function_invariant_p (XEXP (note, 0)))
+ src = XEXP (note, 0);
+ else
+ src = SET_SRC (set);
+
+ if (REG_P (SET_SRC (set)))
+ {
+ regno = REGNO (SET_SRC (set));
+ continue;
+ }
+ break;
+ }
+ if (!function_invariant_p (src))
return -1;
- *expr = simplify_replace_rtx (*expr, *reg, SET_SRC (set));
+ *expr = simplify_replace_rtx (*expr, *reg, src);
return 1;
}
[-- Attachment #3: rhs-invariant.diff --]
[-- Type: text/plain, Size: 880 bytes --]
* loop-iv.c (simple_rhs_p): Allow regs that are function_invariant_p.
Index: loop-iv.c
===================================================================
--- loop-iv.c (revision 145357)
+++ loop-iv.c (working copy)
@@ -1341,10 +1341,10 @@ simple_rhs_p (rtx rhs)
op1 = XEXP (rhs, 1);
/* Allow reg OP const and reg OP reg. */
if (!(REG_P (op0) && !HARD_REGISTER_P (op0))
- && !CONSTANT_P (op0))
+ && !function_invariant_p (op0))
return false;
if (!(REG_P (op1) && !HARD_REGISTER_P (op1))
- && !CONSTANT_P (op1))
+ && !function_invariant_p (op1))
return false;
return true;
@@ -1358,7 +1358,7 @@ simple_rhs_p (rtx rhs)
/* Allow reg OP const. */
if (!(REG_P (op0) && !HARD_REGISTER_P (op0)))
return false;
- if (!CONSTANT_P (op1))
+ if (!function_invariant_p (op1))
return false;
return true;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Two more doloop patches
2009-04-03 12:45 Two more doloop patches Bernd Schmidt
@ 2009-04-03 17:53 ` Zdenek Dvorak
2009-04-24 11:28 ` Bernd Schmidt
0 siblings, 1 reply; 3+ messages in thread
From: Zdenek Dvorak @ 2009-04-03 17:53 UTC (permalink / raw)
To: Bernd Schmidt; +Cc: GCC Patches
Hi,
> These two patches strengthen functions in loop-iv.c so that we allow
> frame and stack pointers in the expressions we're examining. For loops
> that walk an array on the stack, the exit test often is a pointer
> comparison involving addresses based on fp or sp, and the compiler can
> make useful simplifications if these substitutions are allowed.
>
> Bootstrapped and regression tested on i686-linux (irrelevant extra
> failures in libmudflap due to expect truncating compilre output).
> Equivalent patches have been in our Blackfin 4.3 tree for a while now
> and had a fair amount of testing.
> + note = find_reg_equal_equiv_note (DF_REF_INSN (adef));
> + if (note && function_invariant_p (XEXP (note, 0)))
> + src = XEXP (note, 0);
> + else
> + src = SET_SRC (set);
> +
> + if (REG_P (SET_SRC (set)))
> + {
> + regno = REGNO (SET_SRC (set));
> + continue;
> + }
> + break;
maybe
if (note && function_invariant_p (XEXP (note, 0)))
{
src = XEXP (note, 0);
break;
}
src = SET_SRC (set);
if (REG_P (src))
...
?
Otherwise OK,
Zdenek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Two more doloop patches
2009-04-03 17:53 ` Zdenek Dvorak
@ 2009-04-24 11:28 ` Bernd Schmidt
0 siblings, 0 replies; 3+ messages in thread
From: Bernd Schmidt @ 2009-04-24 11:28 UTC (permalink / raw)
To: Zdenek Dvorak; +Cc: GCC Patches
Zdenek Dvorak wrote:
> Hi,
>
>> These two patches strengthen functions in loop-iv.c so that we allow
>> frame and stack pointers in the expressions we're examining. For loops
>> that walk an array on the stack, the exit test often is a pointer
>> comparison involving addresses based on fp or sp, and the compiler can
>> make useful simplifications if these substitutions are allowed.
>>
>> Bootstrapped and regression tested on i686-linux (irrelevant extra
>> failures in libmudflap due to expect truncating compilre output).
>> Equivalent patches have been in our Blackfin 4.3 tree for a while now
>> and had a fair amount of testing.
>
>> + note = find_reg_equal_equiv_note (DF_REF_INSN (adef));
>> + if (note && function_invariant_p (XEXP (note, 0)))
>> + src = XEXP (note, 0);
>> + else
>> + src = SET_SRC (set);
>> +
>> + if (REG_P (SET_SRC (set)))
>> + {
>> + regno = REGNO (SET_SRC (set));
>> + continue;
>> + }
>> + break;
>
> maybe
>
> if (note && function_invariant_p (XEXP (note, 0)))
> {
> src = XEXP (note, 0);
> break;
> }
> src = SET_SRC (set);
>
> if (REG_P (src))
> ...
>
> ?
>
> Otherwise OK,
Changed, retested to make sure that bfin-elf produces identical output,
and bootstrapped on i686-linux. Committed.
Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-04-24 11:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-03 12:45 Two more doloop patches Bernd Schmidt
2009-04-03 17:53 ` Zdenek Dvorak
2009-04-24 11:28 ` Bernd Schmidt
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).