+ } else if ((rel_lo == ir_relation_greater || rel_lo == ir_relation_greater_equal) &&
+ (rel_hi == ir_relation_less || rel_lo == ir_relation_less_equal) &&
+ get_mode_arithmetic(mode) == irma_twos_complement) {
+ /* works for two-complements only */
+ /* x >|\= lo && x <|<= hi ==> (x - lo) <u|<=u (hi-lo) */
+ if (rel_lo == ir_relation_greater) {
+ /* must convert to >= */
+ ir_mode *mode = get_tarval_mode(tv_lo);
+ ir_tarval *n = tarval_add(tv_lo, get_mode_one(mode));
+ if (n != tarval_bad && tarval_cmp(n, tv_lo) == ir_relation_greater) {
+ /* no overflow */
+ tv_lo = n;
+ rel_lo = ir_relation_greater_equal;
+ }
+ }
+ if (rel_lo == ir_relation_greater_equal) {
+ /* all fine */
+ ir_node *const block = get_nodes_block(cmp_hi);
+ ir_node * x = get_Cmp_left(cmp_hi);
+ ir_mode * mode = get_irn_mode(x);
+ ir_node *sub, *cmp, *c, *subc;
+
+ if (mode_is_signed(mode)) {
+ /* convert to unsigned */
+ mode = find_unsigned_mode(mode);
+ if (mode == NULL)
+ return NULL;
+ x = new_r_Conv(block, x, mode);
+ tv_lo = tarval_convert_to(tv_lo, mode);
+ tv_hi = tarval_convert_to(tv_hi, mode);
+ if (tv_lo == tarval_bad || tv_hi == tarval_bad)
+ return NULL;
+ }
+ c = new_r_Const(irg, tv_lo);
+ sub = new_r_Sub(block, x, c, mode);
+ subc = new_r_Sub(block, new_r_Const(irg, tv_hi), c, mode);
+ cmp = new_r_Cmp(block, sub, subc, rel_hi);
+ return cmp;
+ }