This is the mail archive of the 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: [PATCH 2/2] asm inline

On Sun, 2 Dec 2018, Segher Boessenkool wrote:

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 5aa782b..7e9ed99 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4109,6 +4109,9 @@ estimate_num_insns (gimple *stmt, eni_weights *weights)
	   with very long asm statements.  */
	if (count > 1000)
	  count = 1000;
+	/* If this asm is asm inline, count anything as minimum size.  */
+	if (gimple_asm_inline_p (as_a <gasm *> (stmt)))
+	  count = !!count;
	return MAX (1, count);


what is the point of !!count when we take the max with 1 on the very
next line? Is it in prevision of a time when we may remove the MAX? (sorry if this was covered in previous iterations)

By the way, not related to the patch, but I wonder why we cannot have a
cost of 0. My main use of inline asm is as an optimization barrier:
possibly marked volatile to prevent more optimizations. I certainly
expect it to generate exactly 0 instruction in most cases. Although if I am not careful it could easily generate moves from x87 to sse/memory for instance. I guess a minimal cost is safer and doesn't affect decisions too badly.

Marc Glisse

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