This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Treat ASM_EXPR operands as real operands [patch]


In message <1058842759.3848.107.camel@frodo.toronto.redhat.com>, Diego Novillo 
writes:
 >
 >This patch fixes a rather old infrastructure limitation.  We used to
 >treat operands to ASM_EXPR as virtual for no good reason.  Furthermore,
 >we would not support statements making real definitions other than
 >assignment expressions.
 >
 >With this patch we can now properly create real killing definitions for
 >all the variables in the outputs and clobbers list of __asm__
 >expressions.  Andrew, I'm hoping that this change will allow you to test
 >the changes for globals and scalarization that we talked about a few
 >days ago.
 >
 >Most of the changes are mechanical.  Instead of having a single DEF
 >operand in a statement, we now support a varray of DEF operands.  The
 >varray is organized exactly like the USE operands.  It's an array of
 >pointers to operands.
 >
 >The patch also makes some cosmetic changes to the function dumps. 
 >Instead of closing the dump file and calling dump_function (which then
 >re-opens the very same file), we call dump_function_to_file directly.
 >
 >Bootstrapped and tested on x86 and amd64.
 >
 >
 >Diego.
 >
 >
 >	* tree-dfa.c (add_def): Renamed from set_def.  Update all users.
 >	(get_stmt_operands): Don't force ASM_EXPR operands to be virtual.
 >	(add_stmt_operand): Allow non-assignments to create new defs.
 >	* tree-dump.c (dump_function): Move header dump...
 >	(dump_function_to_file): ... here.
 >	* tree-flow-inline.h (def_ops): Renamed from def_op.  Return a
 >	varray with all the definitions made by the statement.
 >	Update all users.
 >	* tree-flow.h (struct operands_d): Rename field 'def_op' to
 >	'def_ops'.  Convert it into a varray.
 >	* tree-must-alias.c (tree_compute_must_alias): Call
 >	dump_function_to_file instead of dump_function.
 >	* tree-ssa-ccp.c (tree_ssa_ccp): Likewise.
 >	(visit_stmt): Only visit statements that make new definitions using
 >	MODIFY_EXPR.
 >	Definitions coming from other statements are considered VARYING.
 >	* tree-ssa-copyprop.c (tree_ssa_copyprop): Call
 >	dump_function_to_file instead of dump_function.
 >	* tree-ssa-dce.c (tree_ssa_dce): Likewise.
 >	* tree-ssa-dom.c (tree_ssa_dominator_optimize): Likewise.
 >	(optimize_stmt): Don't abort if a statement makes more than one
 >	definition.
 >	Check for MODIFY_EXPR statements directly, instead of relying on
 >	the the presence of a single definition.
 >	* tree-ssa-pre.c (tree_perform_ssapre): Call dump_function_to_file
 >	instead of dump_function.
 >	* tree-ssa.c (rewrite_into_ssa): Likewise.
 >	Dump the function before dominator optimizations if TDF_DETAILS is
 >	set.
 >	(rewrite_stmt): Don't abort if the statement makes more than one
 >	definition.
Great!

FWIW, I didn't realize until just now that the VUSE vs real use issue
for ASMs was going to have to be solved before I could make further
progress on the dominator optimizer.


Why?

Well, the next step in the dominator optimizer is to cprop into virtual
operands.  This is important because as PHI nodes are simplified we can
get into situations where we can replace one version of GLOBAL_VAR with a
previous one in a VUSE -- which in turn exposes more load redundancies.

That code was running into problems with ASMs -- we copy propagated a value
into an ASM -- which changed the virtual operands and removed the last
visible use of a variable.  And since the variable was apparently unused,
it was removed.  But the variable was still referenced by the ASM's
tree node.  And when we went to expand the ASM, we tried to expand the
non-existent variable and blew up.

Treating ASMs like everything else conveniently makes this problem just
go away. :-)

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]