Hello Jeff:

On 29/04/23 3:40 am, Jeff Law wrote:
> 
> 
> On 4/20/23 15:03, Ajit Agarwal wrote:
> 
>>
>> Currently I support AND with const1_rtx. This is what is equivalent to zero 
>> extension instruction in power instruction set. When you specify many other 
>> constants and Could you please specify what other constants needs to be 
>> supported and how to determine on the Input and output modes.
> x AND <constant> will result in a zero-extended representation for a variety 
> of constants, not just 1.  For example
> 
> For example x AND 3, x AND 7, x AND 15, etc.
> 
> If (const_int 1) is really that special here, then I've either completely 
> misunderstood the intention of your patch or there's something quite special 
> about the PPC port that I'm not aware of.
>

Here is the patch to address above.

        ree: Improve ree pass for rs6000 target

        For rs6000 target we see redundant zero and sign
        extension and done to improve ree pass to eliminate
        such redundant zero and sign extension. Support of
        AND with extension with different constants other
        than 1.

        2023-05-12  Ajit Kumar Agarwal  <aagar...@linux.ibm.com>

gcc/ChangeLog:

        * ree.cc (rtx_is_zext_p): Add AND with varying contsants as
        extensions.
---
 gcc/ree.cc | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/gcc/ree.cc b/gcc/ree.cc
index 96fda1ac658..ddda5f194bb 100644
--- a/gcc/ree.cc
+++ b/gcc/ree.cc
@@ -269,8 +269,11 @@ rtx_is_zext_p (rtx insn)
       rtx set = XEXP (insn, 0);
       if (REG_P (set))
        {
-          if (XEXP (insn, 1) == const1_rtx)
-            return true;
+         rtx src = XEXP (insn, 1);
+
+         if (CONST_INT_P (src)
+             && IN_RANGE (exact_log2 (UINTVAL (src)), 0, 7))
+           return true;
        }
       else
        return false;
@@ -297,9 +300,11 @@ rtx_is_zext_p (rtx_insn *insn)
 
      if (REG_P (set) && GET_MODE (SET_DEST (body)) == GET_MODE (set))
        {
-        if (GET_MODE_UNIT_SIZE (GET_MODE (SET_DEST (body)))
-            >= GET_MODE_UNIT_SIZE (GET_MODE (set)))
-          return true;
+         rtx src = XEXP (SET_SRC (body), 1);
+
+         if (CONST_INT_P (src)
+             && IN_RANGE (exact_log2 (UINTVAL (src)), 0, 7))
+           return true;
        }
      else
       return false;
-- 
2.31.1


 
> Jeff

Reply via email to