-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[AMDGPU][GlobalISel] Allow bitcast of bf16 #81674
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
@llvm/pr-subscribers-llvm-globalisel Author: Shilei Tian (shiltian) ChangesFull diff: https://github.com/llvm/llvm-project/pull/81674.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 311dd9d9739a6d..3290262816ef0a 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -1562,8 +1562,9 @@ bool IRTranslator::translateBitCast(const User &U,
bool IRTranslator::translateCast(unsigned Opcode, const User &U,
MachineIRBuilder &MIRBuilder) {
- if (U.getType()->getScalarType()->isBFloatTy() ||
- U.getOperand(0)->getType()->getScalarType()->isBFloatTy())
+ if (Opcode != TargetOpcode::G_BITCAST &&
+ (U.getType()->getScalarType()->isBFloatTy() ||
+ U.getOperand(0)->getType()->getScalarType()->isBFloatTy()))
return false;
Register Op = getOrCreateVReg(*U.getOperand(0));
Register Res = getOrCreateVReg(U);
|
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.
It is there for a reason. You cannot really enable it without implementing global isel support for bf16. It will start failing silently. The point of this code to fail with an error. It will also start silently failing for multiple targets.
Okay. Then I'll disable the test in #80908 since it is not supported yet. |
You can, bitcast doesn't count as a bfloat operation. As long as we fail on all the actual bfloat operations, it's OK. |
It would require a bunch more work to guarantee bfloat fallbacks. We miss them in a variety of contexts. I think effort would be better spent just adding bfloat support |
I mean specifically for G_BITCAST, where the type is immaterial |
Also, looks like there is some thinking of adding bf16 as a LLT, but the comment at the top of LowLevetType.h says:
Does that mean adding bf16 support means adding new fields to GMIR classes like G_FADD instead to carry the type? |
Nvm, I found this: https://discourse.llvm.org/t/rfc-globalisel-encoding-type-information-into-fp-operations/75107/1 and reading through it now |
This is a prime patch for #80908. This change doesn't break anything, though we can't test that much, given what mentioned in https://github.com/llvm/llvm-project/pull/80908/files#r1483394728.