-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RyuJIT] Assert failure "unexpected operand size" when folding LCL_FLD into Avx.BlendVariable #10640
Comments
The compiled C# code private ColorPacket256 GetNaturalColor(Vector256<int> things, VectorPacket256 pos, VectorPacket256 norms, VectorPacket256 rds, Scene scene)
{
var colors = ColorPacket256Helper.DefaultColor;
for (int i = 0; i < scene.Lights.Length; i++)
{
var light = scene.Lights[i];
var colorPacket = light.Color.ToColorPacket256();
var lights = light.ToPacket256();
var ldis = lights.Positions - pos;
var livec = ldis.Normalize();
var neatIsectDis = TestRay(new RayPacket256(pos, livec), scene);
// is in shadow?
var mask1 = Compare(neatIsectDis, ldis.Lengths, FloatComparisonMode.LessThanOrEqualOrderedNonSignaling);
var mask2 = Compare(neatIsectDis, SetZeroVector256<float>(), FloatComparisonMode.NotEqualOrderedNonSignaling);
var isInShadow = And(mask1, mask2);
Vector256<float> illum = VectorPacket256.DotProduct(livec, norms);
Vector256<float> illumGraterThanZero = Compare(illum, SetZeroVector256<float>(), FloatComparisonMode.GreaterThanOrderedNonSignaling);
var tmpColor1 = illum * colorPacket;
var defaultRGB = SetZeroVector256<float>();
Vector256<float> lcolorR = BlendVariable(defaultRGB, tmpColor1.Xs, illumGraterThanZero);
Vector256<float> lcolorG = BlendVariable(defaultRGB, tmpColor1.Ys, illumGraterThanZero);
Vector256<float> lcolorB = BlendVariable(defaultRGB, tmpColor1.Zs, illumGraterThanZero);
ColorPacket256 lcolor = new ColorPacket256(lcolorR, lcolorG, lcolorB);
Vector256<float> specular = VectorPacket256.DotProduct(livec, rds.Normalize());
Vector256<float> specularGraterThanZero = Compare(specular, SetZeroVector256<float>(), FloatComparisonMode.GreaterThanOrderedNonSignaling);
var difColor = new ColorPacket256(1, 1, 1);
var splColor = new ColorPacket256(1, 1, 1);
var roughness = SetAllVector256<float>(1);
for (int j = 0; j < scene.Things.Length; j++)
{
Vector256<float> thingMask = StaticCast<int, float>(CompareEqual(things, SetAllVector256<int>(j)));
var rgh = SetAllVector256<float>(scene.Things[j].Surface.Roughness);
var dif = scene.Things[j].Surface.Diffuse(pos);
var spl = scene.Things[j].Surface.Specular(pos);
roughness = BlendVariable(roughness, rgh, thingMask);
difColor.Xs = BlendVariable(difColor.Xs, dif.Xs, thingMask);
difColor.Ys = BlendVariable(difColor.Ys, dif.Ys, thingMask);
difColor.Zs = BlendVariable(difColor.Zs, dif.Zs, thingMask);
splColor.Xs = BlendVariable(splColor.Xs, spl.Xs, thingMask);
splColor.Ys = BlendVariable(splColor.Ys, spl.Ys, thingMask);
splColor.Zs = BlendVariable(splColor.Zs, spl.Zs, thingMask);
}
var tmpColor2 = VectorMath.Pow(specular, roughness) * colorPacket;
Vector256<float> scolorR = BlendVariable(defaultRGB, tmpColor2.Xs, specularGraterThanZero);
Vector256<float> scolorG = BlendVariable(defaultRGB, tmpColor2.Ys, specularGraterThanZero);
Vector256<float> scolorB = BlendVariable(defaultRGB, tmpColor2.Zs, specularGraterThanZero);
ColorPacket256 scolor = new ColorPacket256(scolorR, scolorG, scolorB);
var oldColor = colors;
colors = colors + ColorPacket256Helper.Times(difColor, lcolor) + ColorPacket256Helper.Times(splColor, scolor);
colors = new ColorPacket256(BlendVariable(colors.Xs, oldColor.Xs, isInShadow), BlendVariable(colors.Ys, oldColor.Ys, isInShadow), BlendVariable(colors.Zs, oldColor.Zs, isInShadow));
}
return colors;
} |
@fiigii, do you have the full source code available somewhere so that I can validate locally? |
Looks like the failure has nothing to do with LCL_FLD/etc, it is because the code in question happens to use one of the upper 8 XMM registers (for the third source operand) and causes the immediate value to be The fix is to add the same casting logic that I added for the other immediate values in codegen. |
Fix is here: dotnet/coreclr#18820 |
The assert failture happens
when RyuJIT tries to generate the below
vblendvps
This bug is detected in the work of https://github.com/dotnet/coreclr/issues/17798, and .NET Core 2.1 works fine, so it seems introduced by the recent containment change.
@tannergooding @CarolEidt
The text was updated successfully, but these errors were encountered: