Use ConcatIntoIf in const-eval builtin tests.

This CL updates atan2 and atan to use the ConcatIntoIf helper
instead of doing the case concatention.

Bug: tint:1581
Change-Id: I4ea3153aefcab18db88ab81dd499b9f9e37e7906
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106846
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
dan sinclair 2022-10-25 14:47:31 +00:00 committed by Dawn LUCI CQ
parent 30bc8d76e7
commit 0423c3ccd0
2 changed files with 4875 additions and 4879 deletions

View File

@ -169,46 +169,44 @@ std::vector<Case> Atan2Cases() {
C({Vec(T(1.0), T(1.0)), Vec(T(0.0), -T(0.0))}, Vec(kPiOver2<T>, kPiOver2<T>)).FloatComp(), C({Vec(T(1.0), T(1.0)), Vec(T(0.0), -T(0.0))}, Vec(kPiOver2<T>, kPiOver2<T>)).FloatComp(),
}; };
if constexpr (!finite_only) { ConcatIntoIf<!finite_only>( //
std::vector<Case> non_finite_cases = { cases, std::vector<Case>{
// If y is +/-INF and x is finite, +/-PI/2 is returned // If y is +/-INF and x is finite, +/-PI/2 is returned
C({T::Inf(), T(0.0)}, kPiOver2<T>).PosOrNeg().FloatComp(), C({T::Inf(), T(0.0)}, kPiOver2<T>).PosOrNeg().FloatComp(),
C({-T::Inf(), T(0.0)}, kPiOver2<T>).PosOrNeg().FloatComp(), C({-T::Inf(), T(0.0)}, kPiOver2<T>).PosOrNeg().FloatComp(),
// If y is +/-INF and x is -INF, +/-3PI/4 is returned // If y is +/-INF and x is -INF, +/-3PI/4 is returned
C({T::Inf(), -T::Inf()}, k3PiOver4<T>).PosOrNeg().FloatComp(), C({T::Inf(), -T::Inf()}, k3PiOver4<T>).PosOrNeg().FloatComp(),
C({-T::Inf(), -T::Inf()}, k3PiOver4<T>).PosOrNeg().FloatComp(), C({-T::Inf(), -T::Inf()}, k3PiOver4<T>).PosOrNeg().FloatComp(),
// If y is +/-INF and x is +INF, +/-PI/4 is returned // If y is +/-INF and x is +INF, +/-PI/4 is returned
C({T::Inf(), T::Inf()}, kPiOver4<T>).PosOrNeg().FloatComp(), C({T::Inf(), T::Inf()}, kPiOver4<T>).PosOrNeg().FloatComp(),
C({-T::Inf(), T::Inf()}, kPiOver4<T>).PosOrNeg().FloatComp(), C({-T::Inf(), T::Inf()}, kPiOver4<T>).PosOrNeg().FloatComp(),
// If x is -INF and y is finite and positive, +PI is returned // If x is -INF and y is finite and positive, +PI is returned
C({T(0.0), -T::Inf()}, kPi<T>).FloatComp(), C({T(0.0), -T::Inf()}, kPi<T>).FloatComp(),
// If x is -INF and y is finite and negative, -PI is returned // If x is -INF and y is finite and negative, -PI is returned
C({-T(0.0), -T::Inf()}, -kPi<T>).FloatComp(), C({-T(0.0), -T::Inf()}, -kPi<T>).FloatComp(),
// If x is +INF and y is finite and positive, +0 is returned // If x is +INF and y is finite and positive, +0 is returned
C({T(0.0), T::Inf()}, T(0.0)), C({T(0.0), T::Inf()}, T(0.0)),
// If x is +INF and y is finite and negative, -0 is returned // If x is +INF and y is finite and negative, -0 is returned
C({-T(0.0), T::Inf()}, -T(0.0)), C({-T(0.0), T::Inf()}, -T(0.0)),
// If either x is NaN or y is NaN, NaN is returned // If either x is NaN or y is NaN, NaN is returned
C({T::NaN(), T(0.0)}, T::NaN()), C({T::NaN(), T(0.0)}, T::NaN()),
C({T(0.0), T::NaN()}, T::NaN()), C({T(0.0), T::NaN()}, T::NaN()),
C({T::NaN(), T::NaN()}, T::NaN()), C({T::NaN(), T::NaN()}, T::NaN()),
// Vector tests // Vector tests
C({Vec(T::Inf(), -T::Inf(), T::Inf(), -T::Inf()), // C({Vec(T::Inf(), -T::Inf(), T::Inf(), -T::Inf()), //
Vec(T(0.0), T(0.0), -T::Inf(), -T::Inf())}, // Vec(T(0.0), T(0.0), -T::Inf(), -T::Inf())}, //
Vec(kPiOver2<T>, kPiOver2<T>, k3PiOver4<T>, k3PiOver4<T>)) Vec(kPiOver2<T>, kPiOver2<T>, k3PiOver4<T>, k3PiOver4<T>))
.PosOrNeg() .PosOrNeg()
.FloatComp(), .FloatComp(),
}; });
cases = Concat(cases, non_finite_cases);
}
return cases; return cases;
} }
@ -233,22 +231,20 @@ std::vector<Case> AtanCases() {
C({Vec(T(0.0), T(1.0), -T(1.0))}, Vec(T(0.0), kPiOver4<T>, -kPiOver4<T>)).FloatComp(), C({Vec(T(0.0), T(1.0), -T(1.0))}, Vec(T(0.0), kPiOver4<T>, -kPiOver4<T>)).FloatComp(),
}; };
if constexpr (!finite_only) { ConcatIntoIf<!finite_only>( //
std::vector<Case> non_finite_cases = { cases, std::vector<Case>{
// If i is +/-INF, +/-PI/2 is returned // If i is +/-INF, +/-PI/2 is returned
C({T::Inf()}, kPiOver2<T>).PosOrNeg().FloatComp(), C({T::Inf()}, kPiOver2<T>).PosOrNeg().FloatComp(),
C({-T::Inf()}, -kPiOver2<T>).FloatComp(), C({-T::Inf()}, -kPiOver2<T>).FloatComp(),
// If i is NaN, NaN is returned // If i is NaN, NaN is returned
C({T::NaN()}, T::NaN()), C({T::NaN()}, T::NaN()),
// Vector tests // Vector tests
C({Vec(T::Inf(), -T::Inf(), T::Inf(), -T::Inf())}, // C({Vec(T::Inf(), -T::Inf(), T::Inf(), -T::Inf())}, //
Vec(kPiOver2<T>, -kPiOver2<T>, kPiOver2<T>, -kPiOver2<T>)) Vec(kPiOver2<T>, -kPiOver2<T>, kPiOver2<T>, -kPiOver2<T>))
.FloatComp(), .FloatComp(),
}; });
cases = Concat(cases, non_finite_cases);
}
return cases; return cases;
} }

File diff suppressed because it is too large Load Diff