- /* For scalar operations we need to avoid evaluating operands
- unnecessarily. However, for vector operations we always need to
- evaluate both operands. Unfortunately we only know which of the
- two cases apply after we know the type of the second operand.
- Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS. */
- int oldpos = *pos;
-
- arg2 = evaluate_subexp (nullptr, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
- *pos = oldpos;
- type1 = check_typedef (value_type (arg1));
- type2 = check_typedef (value_type (arg2));
-
- if ((type1->code () == TYPE_CODE_ARRAY && type1->is_vector ())
- || (type2->code () == TYPE_CODE_ARRAY && type2->is_vector ()))
- {
- arg2 = evaluate_subexp (nullptr, exp, pos, noside);
-
- return opencl_relop (exp, arg1, arg2, op);
- }
- else
- {
- /* For scalar built-in types, only evaluate the right
- hand operand if the left hand operand compares
- unequal(&&)/equal(||) to 0. */
- int res;
- int tmp = value_logical_not (arg1);
-
- if (op == BINOP_LOGICAL_OR)
- tmp = !tmp;
-
- arg2
- = evaluate_subexp (nullptr, exp, pos, tmp ? EVAL_SKIP : noside);
- type1 = language_bool_type (exp->language_defn, exp->gdbarch);
-
- if (op == BINOP_LOGICAL_AND)
- res = !tmp && !value_logical_not (arg2);
- else /* BINOP_LOGICAL_OR */
- res = tmp || !value_logical_not (arg2);
-
- return value_from_longest (type1, res);
- }