[20/23] rtlanal: Add simple_regno_set

Richard Sandiford richard.sandiford@arm.com
Thu Dec 17 00:47:29 GMT 2020


Jeff Law <law@redhat.com> writes:
> On 11/13/20 1:21 AM, Richard Sandiford via Gcc-patches wrote:
>> This patch adds a routine for finding a “simple” SET for a register
>> definition.  See the comment in the patch for details.
>>
>> gcc/
>> 	* rtl.h (simple_regno_set): Declare.
>> 	* rtlanal.c (simple_regno_set): New function.
> So I was a bit confused that this is supposed to reject read-write, but
> what it's really rejecting is a narrow subset of read-write.  In
> particular it rejects things that are potentially RMW via subregs. It
> doesn't prevent the destination from appearing as a source operand.  You
> might consider clarifying the comment.

Yeah, in hindsight it was a mistake to spell out the RMW point
separately when it was really just an extra condition on the subreg.

I'd tweaked this comment and the mux-utils.h one (in response
to Martin's feedback) while doing the cross-target testing,
but forgot to include the changes to the committed version.
(The tested versions were otherwise identical, honest.)

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
	* mux-utils.h (pointer_mux::m_ptr): Tweak description of contents.
	* rtlanal.c (simple_regno_set): Tweak description to clarify the
	RMW condition.
---
 gcc/mux-utils.h | 8 ++++----
 gcc/rtlanal.c   | 8 +++++---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/gcc/mux-utils.h b/gcc/mux-utils.h
index b026a9fa4c1..6ec0669256d 100644
--- a/gcc/mux-utils.h
+++ b/gcc/mux-utils.h
@@ -139,10 +139,10 @@ public:
 private:
   pointer_mux (char *ptr) : m_ptr (ptr) {}
 
-  // The pointer value for A pointers, or the pointer value + 1 for B pointers.
-  // Using a pointer rather than a uintptr_t tells the compiler that second ()
-  // can never return null, and that second_or_null () is only null if
-  // is_first ().
+  // Points to the first byte of an object for A pointers or the second
+  // byte of an object for B pointers.  Using a pointer rather than a
+  // uintptr_t tells the compiler that second () can never return null,
+  // and that second_or_null () is only null if is_first ().
   char *m_ptr;
 };
 
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 80e72d6049d..f0e66a7b26b 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -1458,11 +1458,13 @@ set_of (const_rtx pat, const_rtx insn)
 /* Check whether instruction pattern PAT contains a SET with the following
    properties:
 
-   - the SET is executed unconditionally;
-   - the destination of the SET is write-only rather than read-write; and
+   - the SET is executed unconditionally; and
    - either:
      - the destination of the SET is a REG that contains REGNO; or
-     - the destination of the SET is a SUBREG of such a REG.
+     - both:
+       - the destination of the SET is a SUBREG of such a REG; and
+       - writing to the subreg clobbers all of the SUBREG_REG
+	 (in other words, read_modify_subreg_p is false).
 
    If PAT does have a SET like that, return the set, otherwise return null.
 


More information about the Gcc-patches mailing list