aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index e6bcc21..51b9d9f 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1960,6 +1960,35 @@ evaluate_stmt (gimple *stmt)
break;
}
+ case BUILT_IN_BSWAP16:
+ case BUILT_IN_BSWAP32:
+ case BUILT_IN_BSWAP64:
+ val = get_value_for_expr (gimple_call_arg (stmt, 0), true);
+ if (val.lattice_val == UNDEFINED)
+ break;
+ else if (val.lattice_val == CONSTANT
+ && val.value
+ && TREE_CODE (val.value) == INTEGER_CST)
+ {
+ tree type = TREE_TYPE (gimple_call_lhs (stmt));
+ int prec = TYPE_PRECISION (type);
+ wide_int wval = wi::to_wide (val.value);
+ val.value
+ = wide_int_to_tree (type,
+ wide_int::from (wval, prec,
+ UNSIGNED).bswap ());
+ val.mask
+ = widest_int::from (wide_int::from (val.mask, prec,
+ UNSIGNED).bswap (),
+ UNSIGNED);
+ if (wi::sext (val.mask, prec) != -1)
+ break;
+ }
+ val.lattice_val = VARYING;
+ val.value = NULL_TREE;
+ val.mask = -1;
+ break;
+
default:;
}
}