This patch is a one line correction/clarification to GCC's current RTL documentation that explains a USE of a MEM is permissible.
PR rtl-optimization/99930 is an interesting example on x86_64 where the backend generates better code when a USE is a (const) MEM than when it is a REG. In fact the backend relies on CSE to propagate the MEM (a constant pool reference) into the USE, to enable combine to merge/simplify instructions. This change has been tested with a make bootstrap, but as it might provoke a discussion, I've decided to not consider it "obvious". Ok for mainline (to document the actual current behavior)? 2022-07-23 Roger Sayle <ro...@nextmovesoftware.com> gcc/ChangeLog * doc/rtl.texi (use): Document that the operand may be a MEM. Roger --
diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi index 43c9ee8..995c8be 100644 --- a/gcc/doc/rtl.texi +++ b/gcc/doc/rtl.texi @@ -3283,7 +3283,8 @@ Represents the use of the value of @var{x}. It indicates that the value in @var{x} at this point in the program is needed, even though it may not be apparent why this is so. Therefore, the compiler will not attempt to delete previous instructions whose only effect is to -store a value in @var{x}. @var{x} must be a @code{reg} expression. +store a value in @var{x}. @var{x} must be a @code{reg} or a @code{mem} +expression. In some situations, it may be tempting to add a @code{use} of a register in a @code{parallel} to describe a situation where the value