Skip to content

arc: fix for extvsi split patterns#270

Open
Alexehv77 wants to merge 1 commit into
trunkfrom
fix_extvsi
Open

arc: fix for extvsi split patterns#270
Alexehv77 wants to merge 1 commit into
trunkfrom
fix_extvsi

Conversation

@Alexehv77

Copy link
Copy Markdown

Description change to the pattern define_insn_and_split "*extvsi_n_0"

If using && reload_completed the compiler is forced to wait until after the RA/Reload pass is entirely finished. Physical registers are already permanently locked down. If using && 1 the split is allowed to occur early such as during the combine pass when registers are still flexible pseudos. Splitting earlier (using && 1) is generally better than waiting until after reload—provided as it provides significant optimization advantages.

Description change to pattern define_insn_and_split "*extvsi_1_0" keeping "0" with && 1 is not in accordance with the GCC instruction pattern rules:

  1. According to RTL instruction definition by writing "0" we are telling the dataflow analysis that operand 0 and operand 1 must share the exact same physical register. By writing && 1 we are telling the compiler to split this instruction into pieces during the very early optimization passes (like combine) which is before physical registers are even handed out the "0" constraint.

  2. When you split an instruction early using && 1 the purpose is to allow subsequent optimization passes (like Scheduling for register pressure, cse, dce etc) to optimize the broken instructions. If you combine an early split with a restrictive "0" the df-scan gets confused about the exact life ranges of the pseudo registers. Because it thinks the destination and source are linked it may assume a register becomes dead earlier than it actually does. This prevents subsequent passes from safely reordering instructions or eliminating redundant operations resulting in less optimized code.

Description change to the pattern define_insn_and_split "*extvsi_n_0"

If using && reload_completed the compiler is forced to wait until after
the RA/Reload pass is entirely finished. Physical registers are already
permanently locked down. If using && 1 the split is allowed to occur early
such as during the combine pass when registers are still flexible pseudos.
Splitting earlier (using && 1) is generally better than waiting until after
reload—provided as it provides significant optimization advantages.

Description change to pattern define_insn_and_split "*extvsi_1_0"
keeping "0" with && 1 is not in accordance with the GCC instruction pattern rules:

1. According to RTL instruction definition by writing "0" we are telling the
dataflow analysis that operand 0 and operand 1 must share the exact same physical register.
By writing && 1 we are telling the compiler to split this instruction into pieces during the
very early optimization passes (like combine) which is before physical registers are
even handed out the "0" constraint.

2. When you split an instruction early using && 1 the purpose is to allow subsequent
optimization passes (like Scheduling for register pressure, cse, dce etc) to optimize
the broken instructions. If you combine an early split with a restrictive "0" the df-scan
gets confused about the exact life ranges of the pseudo registers.
Because it thinks the destination and source are linked it may assume a register becomes
dead earlier than it actually does. This prevents subsequent passes from safely
reordering instructions or eliminating redundant operations resulting in less optimized code.
Comment thread gcc/config/arc/arc.md
(define_insn_and_split "*extvsi_1_0"
[(set (match_operand:SI 0 "register_operand" "=r")
(sign_extract:SI (match_operand:SI 1 "register_operand" "0")
(sign_extract:SI (match_operand:SI 1 "register_operand" "r")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that this was a functional issue.
But the resulting RTL pattern is correct?

This is just for performance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants