Since I probably still have a test case to hand, should I propose
an alternative patch that fixes my problem by modifying gen_op?
Yeah, I think so.
So here's an alternative patch that fixes the problem for me:
diff --git a/tccgen.c b/tccgen.c
index ae07563..9dfeb2b 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -1827,6 +1827,8 @@ ST_FUNC void gen_op(int op)
vtop->type.t = t;
}
}
+ if (vtop->r & VT_LVAL)
+ gv(is_float(vtop->type.t & VT_BTYPE) ? RC_FLOAT : RC_INT);
}
#ifndef TCC_TARGET_ARM
It probably doesn't change the generated code significantly, though I
should perhaps warn that apart from the cases I alluded to earlier,
where a value computed is not used, there may also be a few cases
where converting the value to an rvalue earlier than it is needed
hurts the register allocation, as in something like f(a + 0, b + 0, c
+ 0, d + 0, e + 0, f + 0). I wouldn't worry about it, though.
I've just noticed that the patch above doesn't have the comment I
wrote, something like:
+ // Make sure that we have converted to an rvalue:
Do you like this new patch?
I need to fix this problem somehow for arm64.