Skip to content
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

[AMDGPU] Incorrect parsing of bf16 literals #79369

Closed
rampitec opened this issue Jan 24, 2024 · 1 comment · Fixed by #80908
Closed

[AMDGPU] Incorrect parsing of bf16 literals #79369

rampitec opened this issue Jan 24, 2024 · 1 comment · Fixed by #80908
Assignees

Comments

@rampitec
Copy link
Collaborator

rampitec commented Jan 24, 2024

bf16 immediate operands are not handled correctly by asm parser (but seem OK in the codegen):

llvm-mc -arch=amdgcn -mcpu=gfx1200 -show-encoding <<< 'v_dot2_bf16_bf16 v5, v1, v2, 100.0'
v_dot2_bf16_bf16 v5, v1, v2, 0x5640     ; encoding: [0x05,0x00,0x67,0xd6,0x01,0x05,0xfe,0x03,0x40,0x56,0x00,0x00]

bf16 constants are essentially fp32 with all zero low 16 bits. So 100.0 shall be encoded as 0x42c80000, and since we only accept 16 bits in the asm hex for it has to be 0x42c8.

llvm-mc -arch=amdgcn -mcpu=gfx1200 -show-encoding <<< 'v_dot2_bf16_bf16 v5, v1, v2, 1.0'
v_dot2_bf16_bf16 v5, v1, v2, 0x3c00     ; encoding: [0x05,0x00,0x67,0xd6,0x01,0x05,0xfe,0x03,0x00,0x3c,0x00,0x00]

This shall be inline immediate.

Basically we are parsing bf16 constants as f16.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 24, 2024

@llvm/issue-subscribers-backend-amdgpu

Author: Stanislav Mekhanoshin (rampitec)

bf16 immediate operands are not handled correctly by asm parser (but seem OK in the codegen): ``` llvm-mc -arch=amdgcn -mcpu=gfx1200 -show-encoding <<< 'v_dot2_bf16_bf16 v5, v1, v2, 100.0' v_dot2_bf16_bf16 v5, v1, v2, 0x5640 ; encoding: [0x05,0x00,0x67,0xd6,0x01,0x05,0xfe,0x03,0x40,0x56,0x00,0x00] ``` bf16 constants are essentially fp32 with all zero low 16 bits. So 100.0 shall be encoded as 0x42c80000, and since we only accept 16 bits in the asm hex for it has to be 0x42c8. ``` llvm-mc -arch=amdgcn -mcpu=gfx1200 -show-encoding <<< 'v_dot2_bf16_bf16 v5, v1, v2, 1.0' v_dot2_bf16_bf16 v5, v1, v2, 0x3c00 ; encoding: [0x05,0x00,0x67,0xd6,0x01,0x05,0xfe,0x03,0x00,0x3c,0x00,0x00] ``` This shall be inline immediate.

Basically we a parsing bf16 constants as f16.

shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 6, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 7, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 7, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 8, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 8, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 8, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 9, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 9, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 9, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 10, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 12, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 12, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 12, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 13, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 13, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 13, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 13, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 14, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 14, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 14, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 14, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 14, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 14, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 15, 2024
This patch removes unused functions that check if an immediate is a 16-bit inline
literals. This serves as prime patches to fix llvm#79369.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 16, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 16, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit to shiltian/llvm-project that referenced this issue Feb 16, 2024
Currently it looks like we generally use `i16` to represent `bf16` in those tablegen
files. I'm not sure of the reason behind it. My wild guess is the type `bf16` was
not available when we enabled the support. This patch is trying to use `bf16`
directly in those tablegen files, aiming at fixing llvm#79369. Of course for llvm#79369
a workaround can be to treat all `INT16` variants as `BFloat` in `getOpFltSemantics`,
but it doesn't look good IMHO.

Since I'm fairly new to AMDGPU backend, I'd appreciate it if you can point out
where I don't understand correctly.
shiltian added a commit that referenced this issue Feb 16, 2024
Currently we generally use `i16` to represent `bf16` in those tablegen
files. This patch is trying to use `bf16` directly.

Fix #79369.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants