Skip to content

Special float NaN/Inf checks on fp16 types are implicitly extended to fp32 #7496

@miguel-petersen

Description

@miguel-petersen

Description

It seems that any fp16 NaN/Inf check with dx.op.isSpecialFloat is implicitly extended (fpext) to dx.op.isSpecialFloat.f32.

Validation seems to accept dx.op.isSpecialFloat.f16 with a fully signed shader. However, certain vendor/drivers crash on dx.op.isSpecialFloat.f16, despite it seeming valid. I assume due to lack of test coverage. If I mirror this extension myself, fpext -> dx.op.isSpecialFloat.f32, all's well.

Steps to Reproduce

Compile the below with "-T lib_6_5 -enable-16bit-types".

export bool Foo(half v) {
	return isinf(v);
}

export bool Foo(float v) {
	return isinf(v);
}

https://godbolt.org/z/hYvoesxjf

Actual Behavior

Notice the fpext:

define i1 @"\01?Foo@@YA_N$f16@@Z"(half %v) #0 {
  %1 = fpext half %v to float
  %IsInf = call i1 @dx.op.isSpecialFloat.f32(i32 9, float %1)
  ret i1 %IsInf
}

; Function Attrs: nounwind readnone
define i1 @"\01?Foo@@YA_NM@Z"(float %v) #0 {
  %IsInf = call i1 @dx.op.isSpecialFloat.f32(i32 9, float %v)
  ret i1 %IsInf
}

Environment

  • DXC version - 1.8.2502
  • Host Operating System - Windows 11 24H2

Metadata

Metadata

Assignees

Labels

bugBug, regression, crashneeds-triageAwaiting triage

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions