Lines Matching refs:ir

73 #include "ir.h"
113 void reverse_to_shifts(ir_expression *ir);
114 void find_lsb_to_float_cast(ir_expression *ir);
115 void find_msb_to_float_cast(ir_expression *ir);
116 void imul_high_to_mul(ir_expression *ir);
117 void sqrt_to_abs_sqrt(ir_expression *ir);
144 lower_instructions_visitor::sub_to_add_neg(ir_expression *ir)
146 ir->operation = ir_binop_add;
147 ir->init_num_operands();
148 ir->operands[1] = new(ir) ir_expression(ir_unop_neg, ir->operands[1]->type,
149 ir->operands[1], NULL);
154 lower_instructions_visitor::ldexp_to_arith(ir_expression *ir)
211 const unsigned vec_elem = ir->type->vector_elements;
219 ir_variable *x = new(ir) ir_variable(ir->type, "x", ir_var_temporary);
220 ir_variable *exp = new(ir) ir_variable(ivec, "exp", ir_var_temporary);
221 ir_variable *result = new(ir) ir_variable(uvec, "result", ir_var_temporary);
224 new(ir) ir_variable(ivec, "extracted_biased_exp", ir_var_temporary);
226 new(ir) ir_variable(ivec, "resulting_biased_exp", ir_var_temporary);
229 new(ir) ir_variable(uvec, "sign_mantissa", ir_var_temporary);
232 new(ir) ir_variable(bvec, "flush_to_zero", ir_var_temporary);
234 new(ir) ir_variable(bvec, "zero_mantissa", ir_var_temporary);
240 i.insert_before(assign(x, ir->operands[0]));
242 i.insert_before(assign(exp, ir->operands[1]));
248 new(ir) ir_constant(23, vec_elem))));
264 new(ir) ir_constant(255, vec_elem))));
269 new(ir) ir_constant(0x807fffffu, vec_elem))));
283 ir_constant::zero(ir, ivec))));
286 ir_constant::zero(ir, ivec),
293 new(ir) ir_constant(255, vec_elem)))));
297 new(ir) ir_constant(0x80000000u, vec_elem)),
308 new(ir) ir_constant(23u, vec_elem),
309 new(ir) ir_constant(8u, vec_elem))));
314 new(ir) ir_constant(23, vec_elem)))));
317 ir->operation = ir_triop_csel;
318 ir->init_num_operands();
319 ir->operands[0] = gequal(extracted_biased_exp,
320 new(ir) ir_constant(255, vec_elem));
321 ir->operands[1] = new(ir) ir_dereference_variable(x);
322 ir->operands[2] = bitcast_u2f(result);
328 lower_instructions_visitor::dldexp_to_arith(ir_expression *ir)
334 const unsigned vec_elem = ir->type->vector_elements;
341 ir_constant *zeroi = ir_constant::zero(ir, ivec);
343 ir_constant *sign_mask = new(ir) ir_constant(0x80000000u);
345 ir_constant *exp_shift = new(ir) ir_constant(20u);
346 ir_constant *exp_width = new(ir) ir_constant(11u);
347 ir_constant *exp_bias = new(ir) ir_constant(1022, vec_elem);
350 ir_variable *x = new(ir) ir_variable(ir->type, "x", ir_var_temporary);
351 ir_variable *exp = new(ir) ir_variable(ivec, "exp", ir_var_temporary);
353 ir_variable *zero_sign_x = new(ir) ir_variable(ir->type, "zero_sign_x",
357 new(ir) ir_variable(ivec, "extracted_biased_exp", ir_var_temporary);
359 new(ir) ir_variable(ivec, "resulting_biased_exp", ir_var_temporary);
362 new(ir) ir_variable(bvec, "is_not_zero_or_underflow", ir_var_temporary);
368 i.insert_before(assign(x, ir->operands[0]));
370 i.insert_before(assign(exp, ir->operands[1]));
393 new(ir) ir_variable(glsl_type::uvec2_type, "unpacked", ir_var_temporary);
398 i.insert_before(assign(unpacked, bit_and(swizzle_y(unpacked), sign_mask->clone(ir, NULL)),
400 i.insert_before(assign(unpacked, ir_constant::zero(ir, glsl_type::uint_type), WRITEMASK_X));
408 new(ir) ir_constant(0x1, vec_elem))));
426 new(ir) ir_variable(glsl_type::uvec2_type, "unpacked", ir_var_temporary);
435 exp_shift->clone(ir, NULL),
436 exp_width->clone(ir, NULL));
443 ir->operation = ir_quadop_vector;
444 ir->init_num_operands();
445 ir->operands[0] = results[0];
446 ir->operands[1] = results[1];
447 ir->operands[2] = results[2];
448 ir->operands[3] = results[3];
458 lower_instructions_visitor::dfrexp_sig_to_arith(ir_expression *ir)
460 const unsigned vec_elem = ir->type->vector_elements;
476 new(ir) ir_variable(bvec, "is_not_zero", ir_var_temporary);
479 ir_constant *dzero = new(ir) ir_constant(0.0, vec_elem);
483 nequal(abs(ir->operands[0]->clone(ir, NULL)), dzero)));
489 ir_constant *zero = new(ir) ir_constant(0u, 1);
490 ir_constant *sign_mantissa_mask = new(ir) ir_constant(0x800fffffu, 1);
493 ir_constant *exponent_value = new(ir) ir_constant(0x3fe00000u, 1);
496 new(ir) ir_variable(glsl_type::uint_type, "bits", ir_var_temporary);
498 new(ir) ir_variable(glsl_type::uvec2_type, "unpacked", ir_var_temporary);
500 ir_rvalue *x = swizzle(ir->operands[0]->clone(ir, NULL), elem, 1);
520 ir->operation = ir_quadop_vector;
521 ir->init_num_operands();
522 ir->operands[0] = results[0];
523 ir->operands[1] = results[1];
524 ir->operands[2] = results[2];
525 ir->operands[3] = results[3];
531 lower_instructions_visitor::dfrexp_exp_to_arith(ir_expression *ir)
533 const unsigned vec_elem = ir->type->vector_elements;
549 new(ir) ir_variable(bvec, "is_not_zero", ir_var_temporary);
551 new(ir) ir_variable(uvec, "high_words", ir_var_temporary);
552 ir_constant *dzero = new(ir) ir_constant(0.0, vec_elem);
553 ir_constant *izero = new(ir) ir_constant(0, vec_elem);
555 ir_rvalue *absval = abs(ir->operands[0]);
559 i.insert_before(assign(is_not_zero, nequal(absval->clone(ir, NULL), dzero)));
563 ir_rvalue *x = swizzle(absval->clone(ir, NULL), elem, 1);
570 ir_constant *exponent_shift = new(ir) ir_constant(20, vec_elem);
571 ir_constant *exponent_bias = new(ir) ir_constant(-1022, vec_elem);
574 ir->operation = ir_triop_csel;
575 ir->init_num_operands();
576 ir->operands[0] = new(ir) ir_dereference_variable(is_not_zero);
577 ir->operands[1] = add(exponent_bias, u2i(rshift(high_words, exponent_shift)));
578 ir->operands[2] = izero;
584 lower_instructions_visitor::carry_to_arith(ir_expression *ir)
594 ir_rvalue *x_clone = ir->operands[0]->clone(ir, NULL);
595 ir->operation = ir_unop_i2u;
596 ir->init_num_operands();
597 ir->operands[0] = b2i(less(add(ir->operands[0], ir->operands[1]), x_clone));
598 ir->operands[1] = NULL;
604 lower_instructions_visitor::borrow_to_arith(ir_expression *ir)
613 ir->operation = ir_unop_i2u;
614 ir->init_num_operands();
615 ir->operands[0] = b2i(less(ir->operands[0], ir->operands[1]));
616 ir->operands[1] = NULL;
622 lower_instructions_visitor::double_dot_to_fma(ir_expression *ir)
624 ir_variable *temp = new(ir) ir_variable(ir->operands[0]->type->get_base_type(), "dot_res",
628 int nc = ir->operands[0]->type->components();
632 assig = assign(temp, mul(swizzle(ir->operands[0]->clone(ir, NULL), i, 1),
633 swizzle(ir->operands[1]->clone(ir, NULL), i, 1)));
635 assig = assign(temp, fma(swizzle(ir->operands[0]->clone(ir, NULL), i, 1),
636 swizzle(ir->operands[1]->clone(ir, NULL), i, 1),
642 ir->operation = ir_triop_fma;
643 ir->init_num_operands();
644 ir->operands[0] = swizzle(ir->operands[0], 0, 1);
645 ir->operands[1] = swizzle(ir->operands[1], 0, 1);
646 ir->operands[2] = new(ir) ir_dereference_variable(temp);
653 lower_instructions_visitor::double_lrp(ir_expression *ir)
656 ir_rvalue *op0 = ir->operands[0], *op2 = ir->operands[2];
657 ir_constant *one = new(ir) ir_constant(1.0, op2->type->vector_elements);
669 ir->operation = ir_triop_fma;
670 ir->init_num_operands();
671 ir->operands[0] = swizzle(op2, swizval, op0->type->vector_elements);
672 ir->operands[2] = mul(sub(one, op2->clone(ir, NULL)), op0);
678 lower_instructions_visitor::dceil_to_dfrac(ir_expression *ir)
686 ir_constant *zero = new(ir) ir_constant(0.0, ir->operands[0]->type->vector_elements);
687 ir_constant *one = new(ir) ir_constant(1.0, ir->operands[0]->type->vector_elements);
688 ir_variable *frtemp = new(ir) ir_variable(ir->operands[0]->type, "frtemp",
692 i.insert_before(assign(frtemp, fract(ir->operands[0])));
694 ir->operation = ir_binop_add;
695 ir->init_num_operands();
696 ir->operands[0] = sub(ir->operands[0]->clone(ir, NULL), frtemp);
697 ir->operands[1] = csel(nequal(frtemp, zero), one, zero->clone(ir, NULL));
703 lower_instructions_visitor::dfloor_to_dfrac(ir_expression *ir)
709 ir->operation = ir_binop_sub;
710 ir->init_num_operands();
711 ir->operands[1] = fract(ir->operands[0]->clone(ir, NULL));
716 lower_instructions_visitor::dround_even_to_dfrac(ir_expression *ir)
730 ir_variable *frtemp = new(ir) ir_variable(ir->operands[0]->type, "frtemp",
732 ir_variable *temp = new(ir) ir_variable(ir->operands[0]->type, "temp",
734 ir_variable *t2 = new(ir) ir_variable(ir->operands[0]->type, "t2",
736 ir_constant *p5 = new(ir) ir_constant(0.5, ir->operands[0]->type->vector_elements);
737 ir_constant *one = new(ir) ir_constant(1.0, ir->operands[0]->type->vector_elements);
738 ir_constant *zero = new(ir) ir_constant(0.0, ir->operands[0]->type->vector_elements);
741 i.insert_before(assign(temp, add(ir->operands[0], p5)));
749 ir->operation = ir_triop_csel;
750 ir->init_num_operands();
751 ir->operands[0] = equal(fract(ir->operands[0]->clone(ir, NULL)),
752 p5->clone(ir, NULL));
753 ir->operands[1] = csel(equal(fract(mul(t2, p5->clone(ir, NULL))),
757 ir->operands[2] = new(ir) ir_dereference_variable(t2);
763 lower_instructions_visitor::dtrunc_to_dfrac(ir_expression *ir)
770 ir_rvalue *arg = ir->operands[0];
773 ir_constant *zero = new(ir) ir_constant(0.0, arg->type->vector_elements);
774 ir_constant *one = new(ir) ir_constant(1.0, arg->type->vector_elements);
775 ir_variable *frtemp = new(ir) ir_variable(arg->type, "frtemp",
777 ir_variable *temp = new(ir) ir_variable(ir->operands[0]->type, "temp",
783 i.insert_before(assign(temp, sub(arg->clone(ir, NULL), frtemp)));
785 ir->operation = ir_triop_csel;
786 ir->init_num_operands();
787 ir->operands[0] = gequal(arg->clone(ir, NULL), zero);
788 ir->operands[1] = new (ir) ir_dereference_variable(temp);
789 ir->operands[2] = add(temp,
790 csel(equal(frtemp, zero->clone(ir, NULL)),
791 zero->clone(ir, NULL),
798 lower_instructions_visitor::dsign_to_csel(ir_expression *ir)
804 ir_rvalue *arg = ir->operands[0];
805 ir_constant *zero = new(ir) ir_constant(0.0, arg->type->vector_elements);
806 ir_constant *one = new(ir) ir_constant(1.0, arg->type->vector_elements);
807 ir_constant *neg_one = new(ir) ir_constant(-1.0, arg->type->vector_elements);
809 ir->operation = ir_triop_csel;
810 ir->init_num_operands();
811 ir->operands[0] = less(arg->clone(ir, NULL),
812 zero->clone(ir, NULL));
813 ir->operands[1] = neg_one;
814 ir->operands[2] = csel(greater(arg, zero),
816 zero->clone(ir, NULL));
822 lower_instructions_visitor::bit_count_to_math(ir_expression *ir)
828 const unsigned elements = ir->operands[0]->type->vector_elements;
829 ir_variable *temp = new(ir) ir_variable(glsl_type::uvec(elements), "temp",
831 ir_constant *c55555555 = new(ir) ir_constant(0x55555555u);
832 ir_constant *c33333333 = new(ir) ir_constant(0x33333333u);
833 ir_constant *c0F0F0F0F = new(ir) ir_constant(0x0F0F0F0Fu);
834 ir_constant *c01010101 = new(ir) ir_constant(0x01010101u);
835 ir_constant *c1 = new(ir) ir_constant(1u);
836 ir_constant *c2 = new(ir) ir_constant(2u);
837 ir_constant *c4 = new(ir) ir_constant(4u);
838 ir_constant *c24 = new(ir) ir_constant(24u);
842 if (ir->operands[0]->type->base_type == GLSL_TYPE_UINT) {
843 base_ir->insert_before(assign(temp, ir->operands[0]));
845 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
846 base_ir->insert_before(assign(temp, i2u(ir->operands[0])));
856 c33333333->clone(ir, NULL)))));
859 ir->operation = ir_unop_u2i;
860 ir->init_num_operands();
861 ir->operands[0] = rshift(mul(bit_and(add(temp, rshift(temp, c4)), c0F0F0F0F),
869 lower_instructions_visitor::extract_to_shifts(ir_expression *ir)
872 new(ir) ir_variable(ir->operands[0]->type, "bits", ir_var_temporary);
875 base_ir->insert_before(assign(bits, ir->operands[2]));
877 if (ir->operands[0]->type->base_type == GLSL_TYPE_UINT) {
879 new(ir) ir_constant(1u, ir->operands[0]->type->vector_elements);
881 new(ir) ir_constant(32u, ir->operands[0]->type->vector_elements);
883 new(ir) ir_constant(0xFFFFFFFFu, ir->operands[0]->type->vector_elements);
892 sub(lshift(c1, bits), c1->clone(ir, NULL)));
903 ir->operation = ir_binop_bit_and;
904 ir->init_num_operands();
905 ir->operands[0] = rshift(ir->operands[0], ir->operands[1]);
906 ir->operands[1] = mask;
907 ir->operands[2] = NULL;
910 new(ir) ir_constant(int(0), ir->operands[0]->type->vector_elements);
912 new(ir) ir_constant(int(32), ir->operands[0]->type->vector_elements);
914 new(ir) ir_variable(ir->operands[0]->type, "temp", ir_var_temporary);
922 rshift(lshift(ir->operands[0], sub(temp, ir->operands[1])), temp);
934 ir->operation = ir_triop_csel;
935 ir->init_num_operands();
936 ir->operands[0] = equal(c0, bits);
937 ir->operands[1] = c0->clone(ir, NULL);
938 ir->operands[2] = expr;
945 lower_instructions_visitor::insert_to_shifts(ir_expression *ir)
951 new(ir) ir_variable(ir->operands[0]->type, "offset", ir_var_temporary);
953 new(ir) ir_variable(ir->operands[0]->type, "bits", ir_var_temporary);
955 new(ir) ir_variable(ir->operands[0]->type, "mask", ir_var_temporary);
957 if (ir->operands[0]->type->base_type == GLSL_TYPE_INT) {
958 c1 = new(ir) ir_constant(int(1), ir->operands[0]->type->vector_elements);
959 c32 = new(ir) ir_constant(int(32), ir->operands[0]->type->vector_elements);
960 cFFFFFFFF = new(ir) ir_constant(int(0xFFFFFFFF), ir->operands[0]->type->vector_elements);
962 assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
964 c1 = new(ir) ir_constant(1u, ir->operands[0]->type->vector_elements);
965 c32 = new(ir) ir_constant(32u, ir->operands[0]->type->vector_elements);
966 cFFFFFFFF = new(ir) ir_constant(0xFFFFFFFFu, ir->operands[0]->type->vector_elements);
970 base_ir->insert_before(assign(offset, ir->operands[2]));
973 base_ir->insert_before(assign(bits, ir->operands[3]));
997 c1->clone(ir, NULL)),
1001 ir->operation = ir_binop_bit_or;
1002 ir->init_num_operands();
1003 ir->operands[0] = bit_and(ir->operands[0], bit_not(mask));
1004 ir->operands[1] = bit_and(lshift(ir->operands[1], offset), mask);
1005 ir->operands[2] = NULL;
1006 ir->operands[3] = NULL;
1012 lower_instructions_visitor::reverse_to_shifts(ir_expression *ir)
1019 new(ir) ir_constant(1u, ir->operands[0]->type->vector_elements);
1021 new(ir) ir_constant(2u, ir->operands[0]->type->vector_elements);
1023 new(ir) ir_constant(4u, ir->operands[0]->type->vector_elements);
1025 new(ir) ir_constant(8u, ir->operands[0]->type->vector_elements);
1027 new(ir) ir_constant(16u, ir->operands[0]->type->vector_elements);
1029 new(ir) ir_constant(0x33333333u, ir->operands[0]->type->vector_elements);
1031 new(ir) ir_constant(0x55555555u, ir->operands[0]->type->vector_elements);
1033 new(ir) ir_constant(0x0F0F0F0Fu, ir->operands[0]->type->vector_elements);
1035 new(ir) ir_constant(0x00FF00FFu, ir->operands[0]->type->vector_elements);
1037 new(ir) ir_variable(glsl_type::uvec(ir->operands[0]->type->vector_elements),
1043 if (ir->operands[0]->type->base_type == GLSL_TYPE_UINT) {
1044 i.insert_before(assign(temp, ir->operands[0]));
1046 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
1047 i.insert_before(assign(temp, i2u(ir->operands[0])));
1055 lshift(bit_and(temp, c55555555->clone(ir, NULL)),
1056 c1->clone(ir, NULL)))));
1062 lshift(bit_and(temp, c33333333->clone(ir, NULL)),
1063 c2->clone(ir, NULL)))));
1070 lshift(bit_and(temp, c0F0F0F0F->clone(ir, NULL)),
1071 c4->clone(ir, NULL)))));
1081 lshift(bit_and(temp, c00FF00FF->clone(ir, NULL)),
1082 c8->clone(ir, NULL)))));
1084 if (ir->operands[0]->type->base_type == GLSL_TYPE_UINT) {
1085 ir->operation = ir_binop_bit_or;
1086 ir->init_num_operands();
1087 ir->operands[0] = rshift(temp, c16);
1088 ir->operands[1] = lshift(temp, c16->clone(ir, NULL));
1090 ir->operation = ir_unop_u2i;
1091 ir->init_num_operands();
1092 ir->operands[0] = bit_or(rshift(temp, c16),
1093 lshift(temp, c16->clone(ir, NULL)));
1100 lower_instructions_visitor::find_lsb_to_float_cast(ir_expression *ir)
1106 const unsigned elements = ir->operands[0]->type->vector_elements;
1107 ir_constant *c0 = new(ir) ir_constant(unsigned(0), elements);
1108 ir_constant *cminus1 = new(ir) ir_constant(int(-1), elements);
1109 ir_constant *c23 = new(ir) ir_constant(int(23), elements);
1110 ir_constant *c7F = new(ir) ir_constant(int(0x7F), elements);
1112 new(ir) ir_variable(glsl_type::ivec(elements), "temp", ir_var_temporary);
1114 new(ir) ir_variable(glsl_type::uvec(elements), "lsb_only", ir_var_temporary);
1116 new(ir) ir_variable(glsl_type::vec(elements), "as_float", ir_var_temporary);
1118 new(ir) ir_variable(glsl_type::ivec(elements), "lsb", ir_var_temporary);
1124 if (ir->operands[0]->type->base_type == GLSL_TYPE_INT) {
1125 i.insert_before(assign(temp, ir->operands[0]));
1127 assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
1128 i.insert_before(assign(temp, u2i(ir->operands[0])));
1171 ir->operation = ir_triop_csel;
1172 ir->init_num_operands();
1173 ir->operands[0] = equal(lsb_only, c0);
1174 ir->operands[1] = cminus1;
1175 ir->operands[2] = new(ir) ir_dereference_variable(lsb);
1181 lower_instructions_visitor::find_msb_to_float_cast(ir_expression *ir)
1187 const unsigned elements = ir->operands[0]->type->vector_elements;
1188 ir_constant *c0 = new(ir) ir_constant(int(0), elements);
1189 ir_constant *cminus1 = new(ir) ir_constant(int(-1), elements);
1190 ir_constant *c23 = new(ir) ir_constant(int(23), elements);
1191 ir_constant *c7F = new(ir) ir_constant(int(0x7F), elements);
1192 ir_constant *c000000FF = new(ir) ir_constant(0x000000FFu, elements);
1193 ir_constant *cFFFFFF00 = new(ir) ir_constant(0xFFFFFF00u, elements);
1195 new(ir) ir_variable(glsl_type::uvec(elements), "temp", ir_var_temporary);
1197 new(ir) ir_variable(glsl_type::vec(elements), "as_float", ir_var_temporary);
1199 new(ir) ir_variable(glsl_type::ivec(elements), "msb", ir_var_temporary);
1205 if (ir->operands[0]->type->base_type == GLSL_TYPE_UINT) {
1206 i.insert_before(assign(temp, ir->operands[0]));
1208 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
1227 new(ir) ir_variable(glsl_type::ivec(elements), "as_int", ir_var_temporary);
1228 ir_constant *c31 = new(ir) ir_constant(int(31), elements);
1231 i.insert_before(assign(as_int, ir->operands[0]));
1272 ir->operation = ir_triop_csel;
1273 ir->init_num_operands();
1274 ir->operands[0] = less(msb, c0);
1275 ir->operands[1] = cminus1;
1276 ir->operands[2] = new(ir) ir_dereference_variable(msb);
1292 lower_instructions_visitor::imul_high_to_mul(ir_expression *ir)
1317 const unsigned elements = ir->operands[0]->type->vector_elements;
1319 new(ir) ir_variable(glsl_type::uvec(elements), "src1", ir_var_temporary);
1321 new(ir) ir_variable(glsl_type::uvec(elements), "src1h", ir_var_temporary);
1323 new(ir) ir_variable(glsl_type::uvec(elements), "src1l", ir_var_temporary);
1325 new(ir) ir_variable(glsl_type::uvec(elements), "src2", ir_var_temporary);
1327 new(ir) ir_variable(glsl_type::uvec(elements), "src2h", ir_var_temporary);
1329 new(ir) ir_variable(glsl_type::uvec(elements), "src2l", ir_var_temporary);
1331 new(ir) ir_variable(glsl_type::uvec(elements), "t1", ir_var_temporary);
1333 new(ir) ir_variable(glsl_type::uvec(elements), "t2", ir_var_temporary);
1335 new(ir) ir_variable(glsl_type::uvec(elements), "lo", ir_var_temporary);
1337 new(ir) ir_variable(glsl_type::uvec(elements), "hi", ir_var_temporary);
1339 ir_constant *c0000FFFF = new(ir) ir_constant(0x0000FFFFu, elements);
1340 ir_constant *c16 = new(ir) ir_constant(16u, elements);
1351 if (ir->operands[0]->type->base_type == GLSL_TYPE_UINT) {
1352 i.insert_before(assign(src1, ir->operands[0]));
1353 i.insert_before(assign(src2, ir->operands[1]));
1355 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
1358 new(ir) ir_variable(glsl_type::ivec(elements), "itmp1", ir_var_temporary);
1360 new(ir) ir_variable(glsl_type::ivec(elements), "itmp2", ir_var_temporary);
1361 ir_constant *c0 = new(ir) ir_constant(int(0), elements);
1365 i.insert_before(assign(itmp1, ir->operands[0]));
1366 i.insert_before(assign(itmp2, ir->operands[1]));
1369 new(ir) ir_variable(glsl_type::bvec(elements), "different_signs",
1375 less(itmp2, c0->clone(ir, NULL)))));
1382 i.insert_before(assign(src2l, bit_and(src2, c0000FFFF->clone(ir, NULL))));
1384 i.insert_before(assign(src2h, rshift(src2, c16->clone(ir, NULL))));
1396 i.insert_before(assign(hi, add(hi, _carry(lo, lshift(t1, c16->clone(ir, NULL))))));
1397 i.insert_before(assign(lo, add(lo, lshift(t1, c16->clone(ir, NULL)))));
1399 i.insert_before(assign(hi, add(hi, _carry(lo, lshift(t2, c16->clone(ir, NULL))))));
1400 i.insert_before(assign(lo, add(lo, lshift(t2, c16->clone(ir, NULL)))));
1403 assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
1405 ir->operation = ir_binop_add;
1406 ir->init_num_operands();
1407 ir->operands[0] = add(hi, rshift(t1, c16->clone(ir, NULL)));
1408 ir->operands[1] = rshift(t2, c16->clone(ir, NULL));
1410 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
1412 i.insert_before(assign(hi, add(add(hi, rshift(t1, c16->clone(ir, NULL))),
1413 rshift(t2, c16->clone(ir, NULL)))));
1421 new(ir) ir_variable(glsl_type::ivec(elements), "neg_hi", ir_var_temporary);
1422 ir_constant *c1 = new(ir) ir_constant(1u, elements);
1428 ir->operation = ir_triop_csel;
1429 ir->init_num_operands();
1430 ir->operands[0] = new(ir) ir_dereference_variable(different_signs);
1431 ir->operands[1] = new(ir) ir_dereference_variable(neg_hi);
1432 ir->operands[2] = u2i(hi);
1437 lower_instructions_visitor::sqrt_to_abs_sqrt(ir_expression *ir)
1439 ir->operands[0] = new(ir) ir_expression(ir_unop_abs, ir->operands[0]);
1444 lower_instructions_visitor::visit_leave(ir_expression *ir)
1446 switch (ir->operation) {
1448 if (ir->operands[0]->type->is_double())
1449 double_dot_to_fma(ir);
1452 if (ir->operands[0]->type->is_double())
1453 double_lrp(ir);
1457 sub_to_add_neg(ir);
1461 if (lowering(LDEXP_TO_ARITH) && ir->type->is_float())
1462 ldexp_to_arith(ir);
1463 if (lowering(DFREXP_DLDEXP_TO_ARITH) && ir->type->is_double())
1464 dldexp_to_arith(ir);
1468 if (lowering(DFREXP_DLDEXP_TO_ARITH) && ir->operands[0]->type->is_double())
1469 dfrexp_exp_to_arith(ir);
1473 if (lowering(DFREXP_DLDEXP_TO_ARITH) && ir->operands[0]->type->is_double())
1474 dfrexp_sig_to_arith(ir);
1479 carry_to_arith(ir);
1484 borrow_to_arith(ir);
1488 if (lowering(DOPS_TO_DFRAC) && ir->type->is_double())
1489 dtrunc_to_dfrac(ir);
1493 if (lowering(DOPS_TO_DFRAC) && ir->type->is_double())
1494 dceil_to_dfrac(ir);
1498 if (lowering(DOPS_TO_DFRAC) && ir->type->is_double())
1499 dfloor_to_dfrac(ir);
1503 if (lowering(DOPS_TO_DFRAC) && ir->type->is_double())
1504 dround_even_to_dfrac(ir);
1508 if (lowering(DOPS_TO_DFRAC) && ir->type->is_double())
1509 dsign_to_csel(ir);
1514 bit_count_to_math(ir);
1519 extract_to_shifts(ir);
1524 insert_to_shifts(ir);
1529 reverse_to_shifts(ir);
1534 find_lsb_to_float_cast(ir);
1539 find_msb_to_float_cast(ir);
1544 imul_high_to_mul(ir);
1550 sqrt_to_abs_sqrt(ir);