This is the mail archive of the
mailing list for the GCC project.
[RFA] [tree-optimization/80576] Handle non-constant sizes in DSE
- From: Jeff Law <law at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 16 Aug 2019 11:23:46 -0600
- Subject: [RFA] [tree-optimization/80576] Handle non-constant sizes in DSE
This patch improves our ability to detect dead stores by handling cases
where the size memcpy, memset, strncpy, etc call is not constant. This
addresses some, but not all, of the issues in 80576.
The key here is when the size is not constant we can make conservative
decisions that still give us a chance to analyze the code for dead stores.
Remember that for dead store elimination, we're trying to prove that
given two stores, the second store overwrites (partially or fully) the
same memory locations as the first store. That makes the first store
either partially or fully dead.
When we encounter the first store, we set up a bitmap of bytes written
by that store (live_bytes). We then look at subsequent stores and clear
the appropriate entries in the bitmap.
If the first store has a nonconstant length argument we can use the
range of the length argument (max) and the size of the destination
object to make a conservative estimation of how many bytes are written.
For the second store the conservative thing to do for a non-constant
length is to use the minimum of the range of the length argument.
This doesn't come up a lot in practice. But it also happens to put some
of the infrastructure in place to handle strcpy and strcpy_chk which are
needed to fully resolve 80576.
Bootstrapped and regression tested on x86, x86_64, ppc64le, ppc64,
ppc32, aarch64, sparc, s390x and probably others. Also verified that
the tests work on the various *-elf targets in my tester.
OK for the trunk?