ir_constant_expression: Extract dot product calculation for reuse.