When more than one location for an asm parameter is specified,
the most general is selected. In the specific case of an 'rm' constraint
this gives higher priority to a memory vs register location.
In case there is only one input operand this is too conservative.
The purpose of this patch is to allow higher priority for the
register location in that case.
Details
- Reviewers
echristo
Diff Detail
Event Timeline
Hi Gerolf,
I'm not sure this is the right way to go. What I'm assuming (since you don't mention) the case that you have is something where the operand is actually already in a register and you want to just go ahead and use that rather than picking the alternative that copies it to memory? Why not solve that problem by looking through the various possible constraints and if the operand you want is already in a location then pick that and worry about forcing as separate?
-eric
Hi Eric
yes, there are more general ways of handling this, and for a single operand your suggestion improves on the implementation I currently have. Wrt to the more general solution it seems that it could result in a problem - at least when implemented naively like for one operand at a time - e.g. when an operand resides in a location needed by another one. This is indicated by a comment in ChooseConstraint() " Ideally, we would pick the most specific constraint possible: if we have something that fits into a register, we would pick it. The problem here is that if we have something that could either be in a register or in memory that use of the register could cause selection of *other* operands to fail: they might only succeed if we pick memory. ".
The most general route for handling this would be to enhance cg copy prop to handle cases like vreg->mem etc. But that is more longer term and would be an overkill for the isolated instance at hand.
So I think I go ahead and add a location check to my current code. Would that stand a chance to pass your LGTM threshold?
Cheers
Gerolf
Only give register preference to the parameter when it resides in a register as Eric suggested.