[llvm-dev] Ok with mismatch between dead-markings in BUNDLE and bundled instructions?
Matthias Braun via llvm-dev
llvm-dev at lists.llvm.org
Wed Jun 28 17:18:35 PDT 2017
> On Jun 28, 2017, at 2:28 AM, Björn Pettersson A <bjorn.a.pettersson at ericsson.com> wrote:
> Not sure if I could follow everything in this discussion regarding subregisters. But I think the problem posted by Mikael just happened to involve subregisters, and the discussions about subregisters is confusing when it comes to Mikaels original question/problem.
> I think that the bundle could look something like this just as well:
> BUNDLE %vreg1<def,dead>
> * %vreg1<def> = add %vreg2, %vreg3
> * call @foo, %vreg1<internal-use>
> No subregisters involved.
> %vreg1 is dead after the bundle.
> %vreg1 is not dead when defined at the "add", because it is used later in the same bundle.
CodeGen shouldn't and doesn't care. The order inside a bundle is unspecified. There are a number of things that would make sense:
- The bundled instructions are executed in parallel and the call reads the value of vreg1 before the add happened
- The bundled instructions are executed in sequence and the call reads the definition from the add
- Both instructions are predicated and we don't even execute the call or the add at all in each run
The gist is: The generic CodeGen code doesn't know how a bundle behaves internally. As far as codegen is concerned executing the bundle is an atomic operation so it feels alot like a single instruction with just all operands merged together.
To make things confusing: A lot of the post-RA passes are not setup to traverse the bundle and the instructions inside, they only ever look at the first instruction. The way this is dealt with today is that we add the summary operands on the first instruction of a bundle (typically BUNDLE or sometimes a target specific opcode).
> Should perhaps the %vreg1 not be included in the BUNDLE head at all here?
The vreg1 has to be in the header.
> (but shouldn't the BUNDLE head be a summary of what is going on inside the bundle, so leaving out information about %vreg1 being defined seems wrong)
> To me it seems wrong to add "dead" to the def of %vreg1 at the add (considering the internal-use).
> Maybe that even answers the question that the "mismatch" between dead-markings should be OK.
> Or would it be OK to mark %vreg1 as dead at the add, even though we have a later internal-use?
I think the answer here is that targets shouldn't expect dead/kill to mean something for the ordering inside the bundle. The flags are only about the effects when viewing the whole bundle as a unit. Hence we also need the internal-use flag, because normal instructions cannot read something that is defined by the same instruction. But a BUNDLE can read data that is defined as part of the same BUNDLE.
More information about the llvm-dev