Skip to content

Conversation

@linehill
Copy link

This commit reduces superfluous move instructions in the object code
(at least for x86_64) by changing internal representation of HSA
registers in gccbrig. Instead representing HSA's untyped registers as
unsigned int the gccbrig analyzes brig code and builds the register
variables as a type used in tree expressions at most. This gives
better chance to optimize CONVERT_VIEW_EXPRs away.

This commit reduces superfluous move instructions in the object code
(at least for x86_64) by changing internal representation of HSA
registers in gccbrig. Instead representing HSA's untyped registers as
unsigned int the gccbrig analyzes brig code and builds the register
variables as a type used in tree expressions at most. This gives
better chance to optimize CONVERT_VIEW_EXPRs away.
else
element = convert (operand_type, element);
}
element = build_reinterpret_cast (operand_type, element);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this correct? Don't we need proper casting (via the convert call) when the integer sizes differ to ensure no garbage is left to the upper bits?

Copy link
Author

Choose a reason for hiding this comment

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

I changed build_reinterpret_cast to do unsigned convert (zero extend or clip out upper bits when sizes differ). Signedness does not seem to matter here in the tests I have run but I check couple more cases for this.


tree_stl_vec
brig_code_entry_handler::build_operands (const BrigInstBase &brig_inst)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please drop the comment, why it's there? Also below?

build_or_analyze_operands (brig_inst, /* analyze = */ true);
}

/* Implements both the build_operands () and analyze_operands () call
Copy link
Collaborator

Choose a reason for hiding this comment

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

goes -> go

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also briefly explain what is being analyzed.

}

/* Implements both the build_operands () and analyze_operands () call
so changes goes in tandem. Performs build_operands () when ANALYZE
Copy link
Collaborator

Choose a reason for hiding this comment

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

-> "only analyze the operands and return an empty list."

operand = build_reinterpret_cast (operand_type, operand);
else if (reg_width > instr_width)
{
/* Clip the operand because the instruction's bitwidth
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, is this really safe to replace with an interpret cast?

for (regs_use_index::const_iterator it = begin_it; it != end_it; it++)
{
std::string hsa_reg = gccbrig_hsa_reg_name_from_hash (it->first);
printf ("%s:\n", hsa_reg.c_str ());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it correct to always output to 'stdout' with the verbose output, or is there some stream variable for it in GCC?


struct reg_use_info
{
/* The generic tree types as the registers is interpreted and their
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is a bit unclear. Also GCC style requires two spaces after dots.

Something like this would be clearer:
"This vector keeps count of the times an HSAIL register is used for storing data of a given type..."

/* Test for casting from/to representation of HSA registers. */

/* HSA registers are untyped but in gccbrig they are presented as */
/* variables with a type selected by analysis. Currently, each */
Copy link
Collaborator

Choose a reason for hiding this comment

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

two spaces after dot

/* HSA registers are untyped but in gccbrig they are presented as */
/* variables with a type selected by analysis. Currently, each */
/* register variable, per function, has a type as it is used at */
/* most. Therefore, register variable can be nearly any type. The */
Copy link
Collaborator

Choose a reason for hiding this comment

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

dittos

{
private_u64 %foo;
private_u64 %bar;
private_b128 %baz;
Copy link
Collaborator

Choose a reason for hiding this comment

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

indent error?

Henry Linjamäki added 2 commits November 16, 2017 16:46
* Style fixes.
* Remove reg use info printing.
* Rename build_reinterpret_cast to build_resize_convert_view to
  reflect the new semantics better.
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