Any def of EXEC prevents rematerialization of any VOP instruction
because of the physreg use. Create a callback to check if the
physreg use can be ingored to allow rematerialization.
Details
Diff Detail
Unit Tests
Event Timeline
Commit message should say TII
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
131 | This also needs to verify it's a VALU use, you could still have an implicit exec read of a scalar instruction |
The definition of "ambient" is so vague that I have no idea what it's trying to convey.
There is already a concept of "pristine" registers, which sounds similar. How is this different?
It is not the same as pristine registers. For pristine registers the idea is that value in a register must be preserved but actually unused in a function. In this case value is not preserved and actually may be used, it is just not directly used in an instruction. The EXEC register holds "execution mask", essentially a mask of active threads. We add it as an implicit operand to all VALU instructions to model the dependency on this mask. However, these instructions do not really read EXEC, it is just a predicate. This implicit use is more or less an "environment" thing.
I agree that "ambient" sounds vague and would appreciate any suggestion.
I think it would be a lot better to add the concept of a "rematerializable" physical register. I think that currently physical registers are considered volatile, unless they are constant, but there was some talk a while back about refining the classification to allow exactly this sort of thing.
There was such idea, but it unfortunately not applicable here. SALU instructions and even some VALU instructions can use EXEC as a data operand. That is only a special implicit use on a VALU instruction is a non-data use to be ignored.
Yes, that's what I meant. I.e. not "it this register always rematerializable", but "it this register rematerializable in this situation".
It will require more work, because we may need to insert instructions that restore the value of that physical register, and currently that's not happening.
We specifically do not want anything trying to manage the value of the register here. It's a predicate register and we want the value to be whatever it happens to be at that point. If the predicate was on for a lane at the def, it's fine if that bit is off at the use. The inverse would be an invalid situation to begin with
Yes. It's a bitmask of active lanes. It's safe to rematerialize the instruction for lanes which are active at the def, but only a subset are at the use which would look like a different register value
Then either implement "isRematerializableUse", and add support for rematerializing it that does nothing for your target, or change it to something like "isIgnorableUse".
What I'm trying to accomplish is to make it applicable to other targets as well, so I'm trying to classify it as a special case of an issue that can occur elsewhere.
Update this comment?