Skip to content

Commit

Permalink
Fix generic IInteger mod implementation. (#5037)
Browse files Browse the repository at this point in the history
  • Loading branch information
csyonghe authored Sep 9, 2024
1 parent 69ee8f6 commit 110d82f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/slang/core.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ ${{{{
__intrinsic_op($(kIROp_Sub)) This sub(This other);
__intrinsic_op($(kIROp_Mul)) This mul(This other);
__intrinsic_op($(kIROp_Div)) This div(This other);
__intrinsic_op($(kIROp_FRem)) This mod(This other);
__intrinsic_op($(kIROp_IRem)) This mod(This other);
__intrinsic_op($(kIROp_Neg)) This neg();
__intrinsic_op($(kIROp_Lsh)) This shl(int other);
__intrinsic_op($(kIROp_Rsh)) This shr(int other);
Expand Down
23 changes: 23 additions & 0 deletions tests/bugs/gh-5026.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type

// CHECK: type: int32_t
// CHECK-NEXT: 0
// CHECK-NEXT: 0
// CHECK-NEXT: 0
// CHECK-NEXT: 0

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

T myMod<T : __BuiltinArithmeticType>(T x, T y)
{
return x % y;
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int c = 1;
int d = 1;
outputBuffer[dispatchThreadID.x] = myMod(c,d);
}

0 comments on commit 110d82f

Please sign in to comment.