- tree lb_type = gcc_type_for_clast_expr (stmt->LB, region, newivs,
- newivs_index, params_index);
- tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, newivs,
- newivs_index, params_index);
- tree type = max_precision_type (lb_type, ub_type);
- tree lb = clast_to_gcc_expression (type, stmt->LB, region, newivs,
- newivs_index, params_index);
- tree ub = clast_to_gcc_expression (type, stmt->UB, region, newivs,
- newivs_index, params_index);
- tree one = POINTER_TYPE_P (type) ? size_one_node
- : fold_convert (type, integer_one_node);
- /* Adding +1 and using LT_EXPR helps with loop latches that have a
- loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes
- 2^{32|64}, and the condition lb <= ub is true, even if we do not want this.
- However lb < ub + 1 is false, as expected. */
- tree ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR
- : PLUS_EXPR, type, ub, one);
-
- /* When ub + 1 wraps around, use lb <= ub. */
- if (integer_zerop (ub_one))
- cond_expr = fold_build2 (LE_EXPR, boolean_type_node, lb, ub);
+
+ *type = type_for_clast_for (stmt, ip);
+ *lb = clast_to_gcc_expression (*type, stmt->LB, ip);
+ *ub = clast_to_gcc_expression (*type, stmt->UB, ip);
+
+ /* When ub is simply a constant or a parameter, use lb <= ub. */
+ if (TREE_CODE (*ub) == INTEGER_CST || TREE_CODE (*ub) == SSA_NAME)
+ cond_expr = fold_build2 (LE_EXPR, boolean_type_node, *lb, *ub);