summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-08 00:03:08 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-08 00:03:08 +0000
commit4739ef9aaa1fc3c8e0ad199a1be663296a13c7f2 (patch)
treec7e51d564515ad836ba64ff4909f61006732ab2a /gcc/tree-ssa-dom.c
parent5ffc9e009356ac12836ea5d855cd48454acadfca (diff)
downloadgcc-4739ef9aaa1fc3c8e0ad199a1be663296a13c7f2.tar.gz
* tree-ssa-dom.c (simplify_switch_and_lookup_avail_expr): Look
through any value-preserving cast. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84244 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index c03e2bb0675..740fe9bc9b2 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -2460,15 +2460,33 @@ simplify_switch_and_lookup_avail_expr (tree stmt,
def = TREE_OPERAND (def, 1);
if (TREE_CODE (def) == NOP_EXPR)
{
+ int need_precision;
+ bool fail;
+
def = TREE_OPERAND (def, 0);
+
+#ifdef ENABLE_CHECKING
+ /* ??? Why was Jeff testing this? We are gimple... */
+ if (!is_gimple_val (def))
+ abort ();
+#endif
+
to = TREE_TYPE (cond);
ti = TREE_TYPE (def);
- /* If we have an extension that preserves sign, then we
+ /* If we have an extension that preserves value, then we
can copy the source value into the switch. */
- if (TYPE_UNSIGNED (to) == TYPE_UNSIGNED (ti)
- && TYPE_PRECISION (to) >= TYPE_PRECISION (ti)
- && is_gimple_val (def))
+
+ need_precision = TYPE_PRECISION (ti);
+ fail = false;
+ if (TYPE_UNSIGNED (to) && !TYPE_UNSIGNED (ti))
+ fail = true;
+ else if (!TYPE_UNSIGNED (to) && TYPE_UNSIGNED (ti))
+ need_precision += 1;
+ if (TYPE_PRECISION (to) < need_precision)
+ fail = true;
+
+ if (!fail)
{
SWITCH_COND (stmt) = def;
ann->modified = 1;