Commit 5cdb91a4 by Nicolas Capens

Fix min/max signed zero and NaN handling.

Make min(x, y) equal to (x < y ? x : y) and max(x, y) equal to (x > y ? x : y), including the behavior for signed zeros and NaNs. This also enables optimizing them into min and max SSE2 instructions on x86. Bug swiftshader:19 Change-Id: I047b90e9da9f3c72657ab7c619bc91b92a700a45 Reviewed-on: https://swiftshader-review.googlesource.com/8771Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 3d689f72
...@@ -52,7 +52,6 @@ static bool validImageSize(GLint level, GLsizei width, GLsizei height) ...@@ -52,7 +52,6 @@ static bool validImageSize(GLint level, GLsizei width, GLsizei height)
return true; return true;
} }
static bool validateColorBufferFormat(GLenum textureFormat, GLenum colorbufferFormat) static bool validateColorBufferFormat(GLenum textureFormat, GLenum colorbufferFormat)
{ {
GLenum validationError = ValidateCompressedFormat(textureFormat, egl::getClientVersion(), false); GLenum validationError = ValidateCompressedFormat(textureFormat, egl::getClientVersion(), false);
......
...@@ -460,8 +460,8 @@ TEST(SubzeroReactorTest, MinMax) ...@@ -460,8 +460,8 @@ TEST(SubzeroReactorTest, MinMax)
EXPECT_EQ(out[0][0], 0x00000000); EXPECT_EQ(out[0][0], 0x00000000);
EXPECT_EQ(out[0][1], 0x00000000); EXPECT_EQ(out[0][1], 0x00000000);
EXPECT_EQ(out[0][2], 0x80000000); EXPECT_EQ(out[0][2], 0x00000000);
EXPECT_EQ(out[0][3], 0x00000000); EXPECT_EQ(out[0][3], 0x80000000);
EXPECT_EQ(out[1][0], 0x3F800000); EXPECT_EQ(out[1][0], 0x3F800000);
EXPECT_EQ(out[1][1], 0x3F800000); EXPECT_EQ(out[1][1], 0x3F800000);
......
...@@ -6040,11 +6040,11 @@ namespace sw ...@@ -6040,11 +6040,11 @@ namespace sw
RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y) RValue<Float4> Max(RValue<Float4> x, RValue<Float4> y)
{ {
Ice::Variable *condition = ::function->makeVariable(Ice::IceType_v4i1); Ice::Variable *condition = ::function->makeVariable(Ice::IceType_v4i1);
auto cmp = Ice::InstFcmp::create(::function, Ice::InstFcmp::Ule, condition, x.value, y.value); auto cmp = Ice::InstFcmp::create(::function, Ice::InstFcmp::Ogt, condition, x.value, y.value);
::basicBlock->appendInst(cmp); ::basicBlock->appendInst(cmp);
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32); Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32);
auto select = Ice::InstSelect::create(::function, result, condition, y.value, x.value); auto select = Ice::InstSelect::create(::function, result, condition, x.value, y.value);
::basicBlock->appendInst(select); ::basicBlock->appendInst(select);
return RValue<Float4>(V(result)); return RValue<Float4>(V(result));
...@@ -6053,11 +6053,11 @@ namespace sw ...@@ -6053,11 +6053,11 @@ namespace sw
RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y) RValue<Float4> Min(RValue<Float4> x, RValue<Float4> y)
{ {
Ice::Variable *condition = ::function->makeVariable(Ice::IceType_v4i1); Ice::Variable *condition = ::function->makeVariable(Ice::IceType_v4i1);
auto cmp = Ice::InstFcmp::create(::function, Ice::InstFcmp::Ugt, condition, x.value, y.value); auto cmp = Ice::InstFcmp::create(::function, Ice::InstFcmp::Olt, condition, x.value, y.value);
::basicBlock->appendInst(cmp); ::basicBlock->appendInst(cmp);
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32); Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32);
auto select = Ice::InstSelect::create(::function, result, condition, y.value, x.value); auto select = Ice::InstSelect::create(::function, result, condition, x.value, y.value);
::basicBlock->appendInst(select); ::basicBlock->appendInst(select);
return RValue<Float4>(V(result)); return RValue<Float4>(V(result));
......
pnacl-subzero @ 47b6ba6d
Subproject commit c48bb8b02c98ae49438e43aa1143a958784822a5 Subproject commit 47b6ba6db7c8b8dd36ac54dbd19ae7b4a5b77424
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment