aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-09-15 08:59:02 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2006-09-15 08:59:02 +0000
commit21cc37194e7036e89ac7823a78539056fc802dbb (patch)
tree4796e47592741b417d93c1f144383dadbfbfbf74 /gcc/ada
parent9bdb04a2f5df0bafb2ab16be673febd789c3a487 (diff)
downloadgcc-21cc37194e7036e89ac7823a78539056fc802dbb.zip
gcc-21cc37194e7036e89ac7823a78539056fc802dbb.tar.gz
gcc-21cc37194e7036e89ac7823a78539056fc802dbb.tar.bz2
re PR ada/18817 (ACATS c380004 fails at run time)
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. From-SVN: r116964
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/utils.c16
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 77cf3d31..e23e39a 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c
index c59a33e..4358547 100644
--- a/gcc/ada/utils.c
+++ b/gcc/ada/utils.c
@@ -2072,6 +2072,22 @@ max_size (tree exp, bool max_p)
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),