[llvm] [AMDGPU] Add lit() asm operand modifier for SP3 compatibility. (PR #68839)

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 00:26:09 PDT 2023


rampitec wrote:

> It makes more sense to me: use literal and abs bit on that literal. The `abs(<num>)` thing is constant evaluated. Just in case if we support actual literal encoding one day. I do not really understand a meaning of lit(abs()) other than the ask to constant evaluate a number and then use as a literal.

Moreover, neg(abs()) is supported. abs(neg()) is not. Which also makes sense, as you cannot really do abs(neg()) in a non-constant case:
```
lvm-mc -arch=amdgcn -mcpu=tonga -show-encoding  <<< 'v_sqrt_f32 v2, abs(neg(-123.0))'
	.text
<stdin>:1:20: error: failed parsing operand.
v_sqrt_f32 v2, abs(neg(-123.0))
                   ^
llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding  <<< 'v_sqrt_f32 v2, neg(abs(-123.0))'
	.text
	v_sqrt_f32_e32 v2, 0xc2f60000           ; encoding: [0xff,0x4e,0x04,0x7e,0x00,0x00,0xf6,0xc2]
```
And then:
```
llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding  <<< 'v_sqrt_f32 v2, neg(abs(lit(-123.0)))'
	.text
	v_sqrt_f32_e32 v2, 0xc2f60000           ; encoding: [0xff,0x4e,0x04,0x7e,0x00,0x00,0xf6,0xc2]
```
I.e. useful and meaningful combinations are supported.

https://github.com/llvm/llvm-project/pull/68839


More information about the llvm-commits mailing list