Commit 92ab1986 by Alexis Hetu Committed by Alexis Hétu

Fix bit shift compilation

Bit shifts compilation was failing when the types were a mismatch, but shifting a uint by an int (or vice versa) is allowed, so types may not match, and it's fine, as long as both are integer types. Change-Id: I86c52a572625b1d09803b0a8b887a63756544101 Reviewed-on: https://swiftshader-review.googlesource.com/3887Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent d9d27bbe
......@@ -192,6 +192,7 @@ TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType
//
TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc &line)
{
bool isBitShift = false;
switch (op) {
case EOpEqual:
case EOpNotEqual:
......@@ -234,10 +235,22 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
return 0;
}
break;
case EOpBitShiftLeft:
case EOpBitShiftRight:
case EOpBitShiftLeftAssign:
case EOpBitShiftRightAssign:
// Unsigned can be bit-shifted by signed and vice versa, but we need to
// check that the basic type is an integer type.
isBitShift = true;
if(!IsInteger(left->getBasicType()) || !IsInteger(right->getBasicType()))
{
return 0;
}
break;
default: break;
}
if (left->getBasicType() != right->getBasicType())
if(!isBitShift && left->getBasicType() != right->getBasicType())
{
return 0;
}
......@@ -768,7 +781,12 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
// GLSL ES 2.0 does not support implicit type casting.
// So the basic type should always match.
if (left->getBasicType() != right->getBasicType())
// GLSL ES 3.0 supports integer shift operands of different signedness.
if(op != EOpBitShiftLeft &&
op != EOpBitShiftRight &&
op != EOpBitShiftLeftAssign &&
op != EOpBitShiftRightAssign &&
left->getBasicType() != right->getBasicType())
{
return false;
}
......
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