summaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-store-merging.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-06-03 11:51:10 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-06-03 11:51:10 +0000
commitc14add82fa4ec24a09e48d56094d9f46310f0809 (patch)
tree74d872b2a20990ecc63ce48b040263450fdce3df /gcc/gimple-ssa-store-merging.c
parent5b9a3332c27e2f4ea372f2fc53bcbd27e204fb73 (diff)
re PR tree-optimization/86034 (wrong code for bit-field manipulation at -Os)
PR tree-optimization/86034 * gimple-ssa-store-merging.c (output_merged_store): Convert the RHS to the unsigned bitfield type in a bit insertion sequence if it does not have a larger precision than the bitfield size. (process_store): Also bypass widening conversions for BIT_INSERT_EXPR. From-SVN: r261128
Diffstat (limited to 'gcc/gimple-ssa-store-merging.c')
-rw-r--r--gcc/gimple-ssa-store-merging.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index 3c63e75fcf6..b972f9bef84 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -3778,7 +3778,14 @@ imm_store_chain_info::output_merged_store (merged_store_group *group)
const HOST_WIDE_INT end_gap
= (try_bitpos + try_size) - (info->bitpos + info->bitsize);
tree tem = info->ops[0].val;
- if ((BYTES_BIG_ENDIAN ? start_gap : end_gap) > 0)
+ if (TYPE_PRECISION (TREE_TYPE (tem)) <= info->bitsize)
+ {
+ tree bitfield_type
+ = build_nonstandard_integer_type (info->bitsize,
+ UNSIGNED);
+ tem = gimple_convert (&seq, loc, bitfield_type, tem);
+ }
+ else if ((BYTES_BIG_ENDIAN ? start_gap : end_gap) > 0)
{
const unsigned HOST_WIDE_INT imask
= (HOST_WIDE_INT_1U << info->bitsize) - 1;
@@ -4270,13 +4277,12 @@ pass_store_merging::process_store (gimple *stmt)
|| !multiple_p (bitpos, BITS_PER_UNIT))
&& const_bitsize <= 64)
{
- /* Bypass a truncating conversion to the bit-field type. */
+ /* Bypass a conversion to the bit-field type. */
if (is_gimple_assign (def_stmt) && CONVERT_EXPR_CODE_P (rhs_code))
{
tree rhs1 = gimple_assign_rhs1 (def_stmt);
if (TREE_CODE (rhs1) == SSA_NAME
- && INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
- && const_bitsize <= TYPE_PRECISION (TREE_TYPE (rhs1)))
+ && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)))
rhs = rhs1;
}
rhs_code = BIT_INSERT_EXPR;