llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[mc][gfx7] Some VOP3 F32 insns (v_cubeid_f32, v_fma_f32 etc) -- negative inline constants not supported

Open atamazov opened this issue 10 years ago • 12 comments

Bugzilla Link 28170
Resolution FIXED
Resolved on Mar 28, 2017 03:16
Version trunk
OS Windows NT
Attachments 04173.tests_tg_gfx7_asm_lit1_bug.06.08.v_cubeid_etc_f32--const.zip
CC @atamazov,@dpreobra

Extended Description

The following instructions have issues with negative inline constants:

v_cubeid_f32 v_cubema_f32 v_cubesc_f32 v_cubetc_f32 v_div_fixup_f32 v_div_fmas_f32 v_fma_f32 v_mad_f32 v_mad_legacy_f32 v_max3_f32 v_med3_f32 v_min3_f32 v_mullit_f32

Number of failing lit1 tests (-search=simple) = 4173.

I am almost sure that issue appears for other sub-targets as well, e.g. gfx8

Tested with r272673 (git # da10a460d7c98278561225fda90855b303675f35)

atamazov avatar Jun 17 '16 17:06 atamazov

Closed by commit rL298265

dpreobra avatar Mar 28 '17 10:03 dpreobra

With r278539, the issue is still observed.

atamazov avatar Aug 16 '16 18:08 atamazov

More tests (3) - 00430.tests_tg_gfx7_asm_lit1_bug.06.08.min.v_mul_etc_f32_e64-const.zip Tests failing due to the same issue, other instructions.

atamazov avatar Jun 20 '16 18:06 atamazov

[Future directions] Note that enabling constructs like

v_add_f32 v0, 1 // typo: missing ".0" -- adds denorm_min instead of 1.0 v_add_i32 v0, 1.0 // typo: extra ".0" -- adds 0xbf800000 instead of 1 may lead to errors which is hard to find.

Perhaps we shall invent "reinterpret operators", for example:

v_add_f32 v0, 1 // This should lead to assembly error v_add_f32 v0, reinterpret_f32(1) // Correct. Value is is denorm_min (0x01 interpreted as float)

atamazov avatar Jun 20 '16 17:06 atamazov

The 32-bit binary representation of integer -1 is 0xffffffff (negative qNAN), while neg(0x00000001) is represented as 0x80000001 (negative numeric_limits::denorm_min()). Currently, asm syntax does not allow for the former encoding.

Looks like the solution is adding explicit syntax form of neg modifier, see Bug 28202. Neg modifier should not be applied to integer values unless explicit syntax is used.

Note this solution would require updating the tests.

atamazov avatar Jun 20 '16 16:06 atamazov

The 32-bit binary representation of integer -1 is 0xffffffff (negative qNAN), while neg(0x00000001) is represented as 0x80000001 (negative numeric_limits::denorm_min()). Currently, asm syntax does not allow for the former encoding.

atamazov avatar Jun 20 '16 16:06 atamazov

Note that floating operands like "|-1|" seem useless but possible to encode and even may have some practical use.

atamazov avatar Jun 17 '16 17:06 atamazov

assigned to @dpreobra

atamazov avatar Jun 17 '16 17:06 atamazov