public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/33028]  New: Missed optimizations in peephole2 pass
@ 2007-08-08 21:58 aesok at gcc dot gnu dot org
  2007-08-25 10:02 ` [Bug rtl-optimization/33028] " aesok at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: aesok at gcc dot gnu dot org @ 2007-08-08 21:58 UTC (permalink / raw)
  To: gcc-bugs

Hi,

AVR backend have peephole2 for optimizing two register move instructions (mov)
in one register pair move instruction (movw):

(define_peephole2 ; movw
  [(set (match_operand:QI 0 "even_register_operand" "")
        (match_operand:QI 1 "even_register_operand" ""))
   (set (match_operand:QI 2 "odd_register_operand" "")
        (match_operand:QI 3 "odd_register_operand" ""))]
  "(AVR_HAVE_MOVW
    && REGNO (operands[0]) == REGNO (operands[2]) - 1
    && REGNO (operands[1]) == REGNO (operands[3]) - 1)"
  [(set (match_dup 4) (match_dup 5))]
  {
    operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
    operands[5] = gen_rtx_REG (HImode, REGNO (operands[1]));
  })

Testcase:

unsigned char ADCH;
unsigned char ADCL;

unsigned int foo(void) {

  unsigned int temp = 0;  

  temp = ((ADCH<<8)|ADCL); 

  return temp;
}

# avr-gcc -Os  -mmcu=atmega16  -save-temps  -dP  -c -o demo.o demo.c

Compiled in:

.LM3:
 ; (insn 32 10 33 demo.c:34 (set (reg:QI 24 r24 [ <result> ])
 ;         (reg:QI 18 r18 [42])) 4 {*movqi} (expr_list:REG_DEAD (reg:QI 18 r18
[42])
 ;         (nil)))
        mov r24,r18      ;  32  *movqi/1        [length = 1]
 ; (insn 33 32 21 demo.c:34 (set (reg:QI 25 r25 [+1 ])
 ;         (reg:QI 19 r19 [+1 ])) 4 {*movqi} (expr_list:REG_DEAD (reg:QI 19 r19
[+1 ])
 ;         (nil)))
        mov r25,r19      ;  33  *movqi/1        [length = 1]
/* epilogue start */
 ; (jump_insn/f 40 39 41 demo.c:34 (return) 128 {return} (nil))
        ret      ;  40  return  [length = 1]

insns 32 ana 33 full match peephole, but do not optimize. If in avr.md file add
new peephole2 with three insn patterns (now avr backend use peephole2 with max
two insn patterns):


(define_peephole2 
  [(set (match_operand:QI 0 "register_operand" "")
        (match_dup 0))
   (set (match_dup 0)
        (match_dup 0))
   (set (match_dup 0)
        (match_dup 0))]
  ""
  [(set (match_dup 0) (match_dup 0))]
  {})

then two 'mov' instruction is optimized in 'movw':

.LM3:
 ; (insn 42 10 21 demo.c:34 (set (reg:HI 24 r24)
 ;         (reg:HI 18 r18)) 8 {*movhi} (nil))
        movw r24,r18     ;  42  *movhi/1        [length = 1]
/* epilogue start */
 ; (jump_insn/f 40 39 41 demo.c:34 (return) 128 {return} (nil))
        ret      ;  40  return  [length = 1]
.LFE2:


This behaviour is caused by the patch:
[patch RFA] Keep the correct peep2_current_count:
http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01368.html


Anatoly.


-- 
           Summary: Missed optimizations in peephole2 pass
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aesok at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33028


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/33028] Missed optimizations in peephole2 pass
  2007-08-08 21:58 [Bug rtl-optimization/33028] New: Missed optimizations in peephole2 pass aesok at gcc dot gnu dot org
@ 2007-08-25 10:02 ` aesok at gcc dot gnu dot org
  2007-08-28 23:30 ` eweddington at cso dot atmel dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: aesok at gcc dot gnu dot org @ 2007-08-25 10:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from aesok at gcc dot gnu dot org  2007-08-25 10:02 -------
Created an attachment (id=14112)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14112&action=view)
Patch.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33028


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/33028] Missed optimizations in peephole2 pass
  2007-08-08 21:58 [Bug rtl-optimization/33028] New: Missed optimizations in peephole2 pass aesok at gcc dot gnu dot org
  2007-08-25 10:02 ` [Bug rtl-optimization/33028] " aesok at gcc dot gnu dot org
@ 2007-08-28 23:30 ` eweddington at cso dot atmel dot com
  2007-08-28 23:31 ` eweddington at cso dot atmel dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: eweddington at cso dot atmel dot com @ 2007-08-28 23:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from eweddington at cso dot atmel dot com  2007-08-28 23:30 -------
Confirmed bug, and verified patch fixes bug.


-- 

eweddington at cso dot atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-08-28 23:30:12
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33028


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/33028] Missed optimizations in peephole2 pass
  2007-08-08 21:58 [Bug rtl-optimization/33028] New: Missed optimizations in peephole2 pass aesok at gcc dot gnu dot org
  2007-08-25 10:02 ` [Bug rtl-optimization/33028] " aesok at gcc dot gnu dot org
  2007-08-28 23:30 ` eweddington at cso dot atmel dot com
@ 2007-08-28 23:31 ` eweddington at cso dot atmel dot com
  2007-10-04 21:21 ` aesok at gcc dot gnu dot org
  2007-10-04 21:22 ` aesok at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: eweddington at cso dot atmel dot com @ 2007-08-28 23:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from eweddington at cso dot atmel dot com  2007-08-28 23:31 -------
(In reply to comment #2)
> Confirmed bug, and verified patch fixes bug.
> 
... For the AVR port only.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33028


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/33028] Missed optimizations in peephole2 pass
  2007-08-08 21:58 [Bug rtl-optimization/33028] New: Missed optimizations in peephole2 pass aesok at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-08-28 23:31 ` eweddington at cso dot atmel dot com
@ 2007-10-04 21:21 ` aesok at gcc dot gnu dot org
  2007-10-04 21:22 ` aesok at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: aesok at gcc dot gnu dot org @ 2007-10-04 21:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from aesok at gcc dot gnu dot org  2007-10-04 21:21 -------
Patch <http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00270.html> fix this bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33028


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug rtl-optimization/33028] Missed optimizations in peephole2 pass
  2007-08-08 21:58 [Bug rtl-optimization/33028] New: Missed optimizations in peephole2 pass aesok at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-10-04 21:21 ` aesok at gcc dot gnu dot org
@ 2007-10-04 21:22 ` aesok at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: aesok at gcc dot gnu dot org @ 2007-10-04 21:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from aesok at gcc dot gnu dot org  2007-10-04 21:22 -------
Fixed in trunk.


-- 

aesok at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
 GCC target triplet|                            |avr
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33028


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-04 21:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-08 21:58 [Bug rtl-optimization/33028] New: Missed optimizations in peephole2 pass aesok at gcc dot gnu dot org
2007-08-25 10:02 ` [Bug rtl-optimization/33028] " aesok at gcc dot gnu dot org
2007-08-28 23:30 ` eweddington at cso dot atmel dot com
2007-08-28 23:31 ` eweddington at cso dot atmel dot com
2007-10-04 21:21 ` aesok at gcc dot gnu dot org
2007-10-04 21:22 ` aesok at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).