Commit b4a058bb by Jamie Madill

Revert "Support constant folding of trigonometry built-ins"

Part of a chain breaking the clang build: http://build.chromium.org/p/chromium.gpu.fyi/builders/GPU%20Linux%20Builder/builds/33588 This reverts commit af930db1. Change-Id: Ic0bf09b4088a1ee285fed0fbd77dfc4c682fcd12 Reviewed-on: https://chromium-review.googlesource.com/265144Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 50b7178d
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <float.h> #include <float.h>
#include <limits.h> #include <limits.h>
#include <math.h>
#include <algorithm> #include <algorithm>
#include "compiler/translator/HashNames.h" #include "compiler/translator/HashNames.h"
...@@ -20,10 +19,6 @@ ...@@ -20,10 +19,6 @@
namespace namespace
{ {
const float kPi = 3.14159265358979323846f;
const float kDegreesToRadiansMultiplier = kPi / 180.0f;
const float kRadiansToDegreesMultiplier = 180.0f / kPi;
TPrecision GetHigherPrecision(TPrecision left, TPrecision right) TPrecision GetHigherPrecision(TPrecision left, TPrecision right)
{ {
return left > right ? left : right; return left > right ? left : right;
...@@ -1190,100 +1185,6 @@ TIntermTyped *TIntermConstantUnion::fold( ...@@ -1190,100 +1185,6 @@ TIntermTyped *TIntermConstantUnion::fold(
} }
break; break;
case EOpRadians:
if (getType().getBasicType() == EbtFloat)
{
tempConstArray[i].setFConst(kDegreesToRadiansMultiplier * unionArray[i].getFConst());
break;
}
infoSink.info.message(
EPrefixInternalError, getLine(),
"Unary operation not folded into constant");
return nullptr;
case EOpDegrees:
if (getType().getBasicType() == EbtFloat)
{
tempConstArray[i].setFConst(kRadiansToDegreesMultiplier * unionArray[i].getFConst());
break;
}
infoSink.info.message(
EPrefixInternalError, getLine(),
"Unary operation not folded into constant");
return nullptr;
case EOpSin:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&sin), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpCos:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&cos), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpTan:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&tan), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpAsin:
// For asin(x), results are undefined if |x| > 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && abs(unionArray[i].getFConst()) > 1.0)
tempConstArray[i].setFConst(0.0);
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&asin), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpAcos:
// For acos(x), results are undefined if |x| > 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && abs(unionArray[i].getFConst()) > 1.0)
tempConstArray[i].setFConst(0.0);
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&acos), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpAtan:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&atan), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpSinh:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&sinh), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpCosh:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&cosh), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpTanh:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&tanh), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpAsinh:
if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&asinh), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpAcosh:
// For acosh(x), results are undefined if x < 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && unionArray[i].getFConst() < 1.0)
tempConstArray[i].setFConst(0.0);
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&acosh), infoSink, &tempConstArray[i]))
return nullptr;
break;
case EOpAtanh:
// For atanh(x), results are undefined if |x| >= 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && abs(unionArray[i].getFConst()) >= 1.0)
tempConstArray[i].setFConst(0.0);
else if (!foldFloatTypeUnary(unionArray[i], static_cast<FloatTypeUnaryFunc>(&atanh), infoSink, &tempConstArray[i]))
return nullptr;
break;
default: default:
return NULL; return NULL;
} }
...@@ -1294,23 +1195,6 @@ TIntermTyped *TIntermConstantUnion::fold( ...@@ -1294,23 +1195,6 @@ TIntermTyped *TIntermConstantUnion::fold(
} }
} }
bool TIntermConstantUnion::foldFloatTypeUnary(const ConstantUnion &parameter, FloatTypeUnaryFunc builtinFunc,
TInfoSink &infoSink, ConstantUnion *result) const
{
ASSERT(builtinFunc);
if (getType().getBasicType() == EbtFloat)
{
result->setFConst(builtinFunc(parameter.getFConst()));
return true;
}
infoSink.info.message(
EPrefixInternalError, getLine(),
"Unary operation not folded into constant");
return false;
}
// static // static
TString TIntermTraverser::hash(const TString &name, ShHashFunction64 hashFunction) TString TIntermTraverser::hash(const TString &name, ShHashFunction64 hashFunction)
{ {
......
...@@ -292,10 +292,6 @@ class TIntermConstantUnion : public TIntermTyped ...@@ -292,10 +292,6 @@ class TIntermConstantUnion : public TIntermTyped
protected: protected:
ConstantUnion *mUnionArrayPointer; ConstantUnion *mUnionArrayPointer;
private:
typedef float(*FloatTypeUnaryFunc) (float);
bool foldFloatTypeUnary(const ConstantUnion &parameter, FloatTypeUnaryFunc builtinFunc, TInfoSink &infoSink, ConstantUnion *result) const;
}; };
// //
......
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