-
Notifications
You must be signed in to change notification settings - Fork 14.3k
AMDGPU: Use OtherPredicates for v_dot2_bf16_bf16(f16_f16) pseudo #84354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is because SubtargetPredicate is not copied from pseudo to dpp16 and dpp8 real. Actually this is the common issue for insts with _Realtriple_ --- We should avoid using SubtargetPredicate to define pseudo: the predicate will be lost in real.
@llvm/pr-subscribers-backend-amdgpu Author: Changpeng Fang (changpeng) ChangesThis is because SubtargetPredicate is not copied from pseudo to dpp16 and dpp8 real. Actually this is the common issue for insts with Realtriple --- We should avoid using SubtargetPredicate to define pseudo: the predicate will be lost in real. Full diff: https://github.com/llvm/llvm-project/pull/84354.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index 334cfad478f151..3340ded9d36000 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -893,7 +893,7 @@ let SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0 in {
defm V_MINIMUMMAXIMUM_F16 : VOP3Inst<"v_minimummaximum_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>>;
} // End SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0
-let SubtargetPredicate = HasDot9Insts, IsDOT=1 in {
+let OtherPredicates = [HasDot9Insts], IsDOT=1 in {
defm V_DOT2_F16_F16 : VOP3Inst<"v_dot2_f16_f16", VOP3_DOT_Profile<VOP_F16_V2F16_V2F16_F16>, int_amdgcn_fdot2_f16_f16>;
defm V_DOT2_BF16_BF16 : VOP3Inst<"v_dot2_bf16_bf16", VOP3_DOT_Profile<VOP_BF16_V2BF16_V2BF16_BF16>, int_amdgcn_fdot2_bf16_bf16>;
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but this is really unfortunate. Can we try to address dpp predicates?
let SubtargetPredicate = HasDPP8; I am thinking whether we can put hasDPP8 into OtherPredicates (using concat). But we need to be |
let SubtargetPredicate = HasDPP8; // do we really need? Actually why do we need to set both SubtargetPredicate and AssemblerPredicate? One of them enough? |
Imagine you have the same instruction in different targets, so you are using 'SubtargetPredicate = HasFeature' on the pseudo. But the encoding is different, so you this HasFeature is not sufficient, you need to use AssemblerPredicate to distinguish between targets for real instructions. |
Is it redundant to have HasDPP8 in both SubtargetPredicate and AssemblerPredicate for a real? |
Yes, both should not be needed. |
Then we can remove "let SubtargetPredicate = ...", and copy SubtargetPredicate from pseudo to real for dpp16 and dpp8. |
|
#84517) We usually expect to copy SubtargetPredicate (and OtherPredicates) from pseudo to real. However, in dpp16 and dpp8, there are assignments like SubtargetPredicate = HasDPP/HasDPP16/HasDpp8. These assignments override predicates copied from pseudo, and thus the predicates used to define pseudo get lost. Losing predicates is a subtle issue usually not easy to be found. It may result in instructions being generated on GPUs that do not support the features to generate them. #84354 addressed one of such issues, and inspired this work. Fortunately, we found that the assignment of SubtargetPredicate usually comes together with assignment of AssemblerPredicate, and with the same value. For example: let AssemblerPredicate = HasDPP16; let SubtargetPredicate = HasDPP16; One of them is redundant and can be removed. In this work, we remove the redundant assignment of SubtargetPredicate, and then copy it from pseudo for VOP*_DPP and VOP*_DPP8. With this change, we can safely use SubtargetPredicate to define pseudo instructions.
This is because SubtargetPredicate is not copied from pseudo to dpp16 and dpp8 real. Actually this is the common issue for insts with Realtriple --- We should avoid using SubtargetPredicate to define pseudo: the predicate will be lost in real.