Skip to content

Incorrect DXC codegen for constant buffer bool vector access #1740

Description

This code:

bool2 b2;
float main() : SV_TARGET
{
  uint x = b2[1];
  return x;
}

Compiles into:

define void @main() {
  %"$Globals_cbuffer" = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
  %1 = call %dx.types.CBufRet.i32 @dx.op.cbufferLoadLegacy.i32(i32 59, %dx.types.Handle %"$Globals_cbuffer", i32 0)  ; CBufferLoadLegacy(handle,regIndex)
  %2 = extractvalue %dx.types.CBufRet.i32 %1, 1
  %.i1 = icmp eq i32 %2, 0 ; <------------ !!!
  %3 = uitofp i1 %.i1 to float
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %3)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  ret void
}

This is incorrect, it should be icmp ne, not icmp eq.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugBug, regression, crash

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions