Richard Sandiford
f60226fd72
df: Record all definitions in DF_LR_BB_INFO->def [PR98863]
df_lr_bb_local_compute has: FOR_EACH_INSN_INFO_DEF (def, insn_info) /* If the def is to only part of the reg, it does not kill the other defs that reach here. */ if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))) However, as noted in the comment in the patch and below, almost all partial definitions have an associated use. This means that the confluence function: IN = (OUT & ~DEF) | USE is unaffected by whether partial definitions are in DEF or not. Even though the choice doesn't matter for the LR problem itself, it's IMO much more convenient for consumers if DEF contains all the definitions in the block. The only pre-RTL-SSA code that tries to consume DEF directly is shrink-wrap.c, which already has to work around the incompleteness of the information: /* DF_LR_BB_INFO (bb)->def does not comprise the DF_REF_PARTIAL and DF_REF_CONDITIONAL defs. So if DF_LIVE doesn't exist, i.e. at -O1, just give up searching NEXT_BLOCK. */ I hit the same problem when trying to fix the RTL-SSA part of PR98863. This patch treats partial definitions as both a def and a use, just like the df_ref records almost always do. To show that partial definitions almost always have uses: DF_REF_CONDITIONAL: Added by: case COND_EXEC: df_defs_record (collection_rec, COND_EXEC_CODE (x), bb, insn_info, DF_REF_CONDITIONAL); break; Later, df_get_conditional_uses creates uses for all DF_REF_CONDITIONAL definitions. DF_REF_PARTIAL: In total, there are 4 locations at which we add partial definitions. Case 1: if (GET_CODE (dst) == STRICT_LOW_PART) { flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_STRICT_LOW_PART; loc = &XEXP (dst, 0); dst = *loc; } Corresponding use: case STRICT_LOW_PART: { rtx *temp = &XEXP (dst, 0); /* A strict_low_part uses the whole REG and not just the SUBREG. */ dst = XEXP (dst, 0); df_uses_record (collection_rec, (GET_CODE (dst) == SUBREG) ? &SUBREG_REG (dst) : temp, DF_REF_REG_USE, bb, insn_info, DF_REF_READ_WRITE | DF_REF_STRICT_LOW_PART); } break; Case 2: if (GET_CODE (dst) == ZERO_EXTRACT) { flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL | DF_REF_ZERO_EXTRACT; loc = &XEXP (dst, 0); dst = *loc; } Corresponding use: case ZERO_EXTRACT: { df_uses_record (collection_rec, &XEXP (dst, 1), DF_REF_REG_USE, bb, insn_info, flags); df_uses_record (collection_rec, &XEXP (dst, 2), DF_REF_REG_USE, bb, insn_info, flags); if (GET_CODE (XEXP (dst,0)) == MEM) df_uses_record (collection_rec, &XEXP (dst, 0), DF_REF_REG_USE, bb, insn_info, flags); else df_uses_record (collection_rec, &XEXP (dst, 0), DF_REF_REG_USE, bb, insn_info, DF_REF_READ_WRITE | DF_REF_ZERO_EXTRACT); ----------------------------^^^^^^^^^^^^^^^^^ } break; Case 3: else if (GET_CODE (dst) == SUBREG && REG_P (SUBREG_REG (dst))) { if (read_modify_subreg_p (dst)) flags |= DF_REF_READ_WRITE | DF_REF_PARTIAL; flags |= DF_REF_SUBREG; df_ref_record (DF_REF_REGULAR, collection_rec, dst, loc, bb, insn_info, DF_REF_REG_DEF, flags); } Corresponding use: case SUBREG: if (read_modify_subreg_p (dst)) { df_uses_record (collection_rec, &SUBREG_REG (dst), DF_REF_REG_USE, bb, insn_info, flags | DF_REF_READ_WRITE | DF_REF_SUBREG); break; } Case 4: /* If this is a multiword hardreg, we create some extra datastructures that will enable us to easily build REG_DEAD and REG_UNUSED notes. */ if (collection_rec && (endregno != regno + 1) && insn_info) { /* Sets to a subreg of a multiword register are partial. Sets to a non-subreg of a multiword register are not. */ if (GET_CODE (reg) == SUBREG) ref_flags |= DF_REF_PARTIAL; ref_flags |= DF_REF_MW_HARDREG; Corresponding use: None. However, this case should be rare to non-existent on most targets, and the current handling seems suspect. See the comment in the patch for more details. gcc/ * df-problems.c (df_lr_bb_local_compute): Treat partial definitions as read-modify operations. gcc/testsuite/ * gcc.dg/rtl/aarch64/multi-subreg-1.c: New test.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.
Description
Languages
C
48%
Ada
18.3%
C++
14.1%
Go
7%
GCC Machine Description
4.6%
Other
7.7%