This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

subreg validation, part 4


I caught cse trying to create (subreg:QI (const_int 2) 0).

We never noticed before, because the construct was only added to a
cse hash table and not inserted into the instruction stream.  Of
course, that does imply that the hash table entry was never matched,
and therefore we may have missed some cse opportunity.

The following is the best I can get for what I think was intended.


r~


        * cse.c (record_jump_cond_subreg): New.
        (record_jump_cond): Use it instead of gen_lowpart.

Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.324
diff -c -p -d -r1.324 cse.c
*** cse.c	22 Nov 2004 12:23:46 -0000	1.324
--- cse.c	23 Nov 2004 23:22:37 -0000
*************** record_jump_equiv (rtx insn, int taken)
*** 4335,4340 ****
--- 4335,4352 ----
    record_jump_cond (code, mode, op0, op1, reversed_nonequality);
  }
  
+ /* Yet another form of subreg creation.  In this case, we want something in
+    MODE, and we should assume OP has MODE iff it is naturally modeless.  */
+ 
+ static rtx
+ record_jump_cond_subreg (enum machine_mode mode, rtx op)
+ {
+   enum machine_mode op_mode = GET_MODE (op);
+   if (op_mode == mode || op_mode == VOIDmode)
+     return op;
+   return lowpart_subreg (mode, op, op_mode);
+ }
+ 
  /* We know that comparison CODE applied to OP0 and OP1 in MODE is true.
     REVERSED_NONEQUALITY is nonzero if CODE had to be swapped.
     Make any useful entries we can with that information.  Called from
*************** record_jump_cond (enum rtx_code code, en
*** 4359,4369 ****
  	  > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op0));
!       rtx tem = gen_lowpart (inner_mode, op1);
! 
!       record_jump_cond (code, mode, SUBREG_REG (op0),
! 			tem ? tem : gen_rtx_SUBREG (inner_mode, op1, 0),
! 			reversed_nonequality);
      }
  
    if (code == EQ && GET_CODE (op1) == SUBREG
--- 4371,4380 ----
  	  > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op0));
!       rtx tem = record_jump_cond_subreg (inner_mode, op1);
!       if (tem)
! 	record_jump_cond (code, mode, SUBREG_REG (op0), tem,
! 			  reversed_nonequality);
      }
  
    if (code == EQ && GET_CODE (op1) == SUBREG
*************** record_jump_cond (enum rtx_code code, en
*** 4371,4381 ****
  	  > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op1)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op1));
!       rtx tem = gen_lowpart (inner_mode, op0);
! 
!       record_jump_cond (code, mode, SUBREG_REG (op1),
! 			tem ? tem : gen_rtx_SUBREG (inner_mode, op0, 0),
! 			reversed_nonequality);
      }
  
    /* Similarly, if this is an NE comparison, and either is a SUBREG
--- 4382,4391 ----
  	  > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op1)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op1));
!       rtx tem = record_jump_cond_subreg (inner_mode, op0);
!       if (tem)
! 	record_jump_cond (code, mode, SUBREG_REG (op1), tem,
! 			  reversed_nonequality);
      }
  
    /* Similarly, if this is an NE comparison, and either is a SUBREG
*************** record_jump_cond (enum rtx_code code, en
*** 4391,4401 ****
  	  < GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op0));
!       rtx tem = gen_lowpart (inner_mode, op1);
! 
!       record_jump_cond (code, mode, SUBREG_REG (op0),
! 			tem ? tem : gen_rtx_SUBREG (inner_mode, op1, 0),
! 			reversed_nonequality);
      }
  
    if (code == NE && GET_CODE (op1) == SUBREG
--- 4401,4410 ----
  	  < GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op0));
!       rtx tem = record_jump_cond_subreg (inner_mode, op1);
!       if (tem)
! 	record_jump_cond (code, mode, SUBREG_REG (op0), tem,
! 			  reversed_nonequality);
      }
  
    if (code == NE && GET_CODE (op1) == SUBREG
*************** record_jump_cond (enum rtx_code code, en
*** 4404,4414 ****
  	  < GET_MODE_SIZE (GET_MODE (SUBREG_REG (op1)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op1));
!       rtx tem = gen_lowpart (inner_mode, op0);
! 
!       record_jump_cond (code, mode, SUBREG_REG (op1),
! 			tem ? tem : gen_rtx_SUBREG (inner_mode, op0, 0),
! 			reversed_nonequality);
      }
  
    /* Hash both operands.  */
--- 4413,4422 ----
  	  < GET_MODE_SIZE (GET_MODE (SUBREG_REG (op1)))))
      {
        enum machine_mode inner_mode = GET_MODE (SUBREG_REG (op1));
!       rtx tem = record_jump_cond_subreg (inner_mode, op0);
!       if (tem)
! 	record_jump_cond (code, mode, SUBREG_REG (op1), tem,
! 			  reversed_nonequality);
      }
  
    /* Hash both operands.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]