Lines Matching refs:left

29 static std::unique_ptr<Expression> eliminate_no_op_boolean(const Expression& left,
41 return left.clone();
47 static std::unique_ptr<Expression> short_circuit_boolean(const Expression& left,
50 bool leftVal = left.as<Literal>().boolValue();
52 // When the literal is on the left, we can sometimes eliminate the other expression entirely.
56 return left.clone();
61 return eliminate_no_op_boolean(right, op, left);
65 const Expression& left,
71 switch (left.compareConstant(right)) {
77 return Literal::MakeBool(context, left.fLine, equality);
87 const Expression& left,
90 SkASSERT(left.type().isVector());
91 SkASSERT(left.type() == right.type());
92 const Type& type = left.type();
95 if (std::unique_ptr<Expression> result = simplify_vector_equality(context, left, op, right)) {
121 double value = foldFn(*left.getConstantValue(i), *right.getConstantValue(i));
126 args.push_back(Literal::Make(left.fLine, value, &componentType));
128 return ConstructorCompound::Make(context, left.fLine, type, std::move(args));
232 const Expression& left,
239 return cast_expression(context, left, resultType);
241 if (is_constant_value(left, 0.0)) { // 0 + x
248 return cast_expression(context, left, resultType);
250 if (is_constant_value(left, 1.0)) { // 1 * x
253 if (is_constant_value(right, 0.0) && !left.hasSideEffects()) { // x * 0
256 if (is_constant_value(left, 0.0) && !right.hasSideEffects()) { // 0 * x
257 return cast_expression(context, left, resultType);
263 return cast_expression(context, left, resultType);
265 if (is_constant_value(left, 0.0)) { // 0 - x (to `-x`)
274 return cast_expression(context, left, resultType);
281 if (std::unique_ptr<Expression> var = cast_expression(context, left, resultType)) {
291 if (std::unique_ptr<Expression> var = cast_expression(context, left, resultType)) {
340 const Expression* left = GetConstantValueForVariable(leftExpr);
343 // If this is the comma operator, the left side is evaluated but not otherwise used in any way.
344 // So if the left side has no side effects, it can just be eliminated entirely.
345 if (op.kind() == Token::Kind::TK_COMMA && !left->hasSideEffects()) {
352 if (op.kind() == Token::Kind::TK_EQ && Analysis::IsSameExpressionTree(*left, *right)) {
357 if (left->isBoolLiteral() && right->isBoolLiteral()) {
358 bool leftVal = left->as<Literal>().boolValue();
372 // If the left side is a Boolean literal, apply short-circuit optimizations.
373 if (left->isBoolLiteral()) {
374 return short_circuit_boolean(*left, op, *right);
379 // ... and the left side has no side effects...
380 if (!left->hasSideEffects()) {
382 return short_circuit_boolean(*right, op, *left);
386 return eliminate_no_op_boolean(*left, op, *right);
389 if (op.kind() == Token::Kind::TK_EQEQ && Analysis::IsSameExpressionTree(*left, *right)) {
395 if (op.kind() == Token::Kind::TK_NEQ && Analysis::IsSameExpressionTree(*left, *right)) {
406 const Type& leftType = left->type();
410 std::unique_ptr<Expression> expr = simplify_no_op_arithmetic(context, *left, op, *right,
418 if (!left->isCompileTimeConstant() || !right->isCompileTimeConstant()) {
426 if (left->isIntLiteral() && right->isIntLiteral()) {
427 SKSL_INT leftVal = left->as<Literal>().intValue();
482 if (left->isFloatLiteral() && right->isFloatLiteral()) {
483 SKSL_FLOAT leftVal = left->as<Literal>().floatValue();
506 return simplify_vector(context, *left, op, *right);
509 return simplify_vector(context, *left, op, *right);
512 return simplify_vector_equality(context, *left, op, *right);
520 return simplify_vector(context, *left, op, ConstructorSplat(*right, left->type()));
523 return simplify_vector(context, *left, op, ConstructorSplat(*right, left->type()));
526 return simplify_vector_equality(context, *left, op,
527 ConstructorSplat(*right, left->type()));
535 return simplify_vector(context, ConstructorSplat(*left, right->type()), op, *right);
538 return simplify_vector(context, ConstructorSplat(*left, right->type()), op, *right);
541 return simplify_vector_equality(context, ConstructorSplat(*left, right->type()),
562 switch (left->compareConstant(*right)) {