On 12/16/2016 12:29 AM, Trevor Saunders wrote:
On Thu, Dec 15, 2016 at 06:54:43PM -0700, Jeff Law wrote:
unsigned cnt = 0;
+ bitmap live_bytes = NULL;
+ bitmap orig_live_bytes = NULL;
*use_stmt = NULL;
+ /* REF is a memory write. Go ahead and get its base, size, extent
+ information and encode the bytes written into LIVE_BYTES. We can
+ handle any case where we have a known base and maximum size.
+
+ However, experimentation has shown that bit level tracking is not
+ useful in practice, so we only track at the byte level.
+
+ Furthermore, experimentation has shown that 99% of the cases
+ that require byte tracking are 64 bytes or less. */
+ if (valid_ao_ref_for_dse (ref)
+ && (ref->max_size / BITS_PER_UNIT
+ <= PARAM_VALUE (PARAM_DSE_MAX_OBJECT_SIZE)))
+ {
+ live_bytes = BITMAP_ALLOC (NULL);
+ orig_live_bytes = BITMAP_ALLOC (NULL);
+ bitmap_set_range (live_bytes,
+ ref->offset / BITS_PER_UNIT,
+ ref->max_size / BITS_PER_UNIT);
+ bitmap_copy (orig_live_bytes, live_bytes);
would it maybe make sense to use sbitmaps since the length is known to
be short, and doesn't change after allocation?
It would. I tend to default to bitmaps these days (odd since I was
probably the largest user of sbitmaps for a long time).
@@ -164,7 +341,15 @@ dse_possible_dead_store_p (ao_ref *ref, gimple *stmt,
gimple **use_stmt)
}
if (fail)
- return false;
+ {
+ /* STMT might be partially dead and we may be able to reduce
+ how many memory locations it stores into. */
+ if (live_bytes
+ && !bitmap_equal_p (live_bytes, orig_live_bytes)
+ && !gimple_clobber_p (stmt))
+ trim_partially_dead_store (orig_live_bytes, live_bytes, stmt);
+ return false;
shouldn't you free the bitmaps here?
Yes. I think switching to an auto-sbitmap would resolve this as well.
jeff