+2006-09-15 Roger Sayle <roger@eyesopen.com>
+
+ PR ada/18817
+ * utils.c (max_size): Perform constant folding of (A ? B : C) - D
+ into A ? B - D : C - D when calculating the size of a MINUS_EXPR.
+
2006-09-13 Olivier Hainque <hainque@adacore.com>
PR ada/29025
if (code == COMPOUND_EXPR)
return max_size (TREE_OPERAND (exp, 1), max_p);
+ /* Calculate "(A ? B : C) - D" as "A ? B - D : C - D" which
+ may provide a tighter bound on max_size. */
+ if (code == MINUS_EXPR
+ && TREE_CODE (TREE_OPERAND (exp, 0)) == COND_EXPR)
+ {
+ tree lhs = fold_build2 (MINUS_EXPR, type,
+ TREE_OPERAND (TREE_OPERAND (exp, 0), 1),
+ TREE_OPERAND (exp, 1));
+ tree rhs = fold_build2 (MINUS_EXPR, type,
+ TREE_OPERAND (TREE_OPERAND (exp, 0), 2),
+ TREE_OPERAND (exp, 1));
+ return fold_build2 (max_p ? MAX_EXPR : MIN_EXPR, type,
+ max_size (lhs, max_p),
+ max_size (rhs, max_p));
+ }
+
{
tree lhs = max_size (TREE_OPERAND (exp, 0), max_p);
tree rhs = max_size (TREE_OPERAND (exp, 1),
-c380004
c52103x
c52104x
c52104y
cb1010d
templat
# Tests must be sorted in alphabetical order
-# c380004: should be front-end compile time error, PR ada/18817
# c52103x, c52104x, c52104y: -fstack-check doesn't work, PR middle-end/20548
# cb1010a, cb1010c, cb1010d: likewise