GLSL: Fold constant SHRT_MIN/INT_MIN/LLONG_MIN % -1 to 0.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
#include <cstdlib>
|
||||
#include <climits>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -264,7 +265,29 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
|
||||
if (rightUnionArray[i] == 0)
|
||||
newConstArray[i] = leftUnionArray[i];
|
||||
else
|
||||
newConstArray[i] = leftUnionArray[i] % rightUnionArray[i];
|
||||
switch (getType().getBasicType()) {
|
||||
case EbtInt:
|
||||
if (rightUnionArray[i].getIConst() == -1 && leftUnionArray[i].getIConst() == INT_MIN) {
|
||||
newConstArray[i].setIConst(0);
|
||||
break;
|
||||
} else goto modulo_default;
|
||||
|
||||
case EbtInt64:
|
||||
if (rightUnionArray[i].getI64Const() == -1 && leftUnionArray[i].getI64Const() == LLONG_MIN) {
|
||||
newConstArray[i].setI64Const(0);
|
||||
break;
|
||||
} else goto modulo_default;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
if (rightUnionArray[i].getIConst() == -1 && leftUnionArray[i].getIConst() == SHRT_MIN) {
|
||||
newConstArray[i].setIConst(0);
|
||||
break;
|
||||
} else goto modulo_default;
|
||||
#endif
|
||||
default:
|
||||
modulo_default:
|
||||
newConstArray[i] = leftUnionArray[i] % rightUnionArray[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user