public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3..
       [not found] <bug-43088-4@http.gcc.gnu.org/bugzilla/>
@ 2011-06-10 20:01 ` gjl at gcc dot gnu.org
  2011-07-02 21:08 ` gjl at gcc dot gnu.org
  2011-07-04 13:31 ` [Bug rtl-optimization/43088] " gjl at gcc dot gnu.org
  2 siblings, 0 replies; 7+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-06-10 20:01 UTC (permalink / raw)
  To: gcc-bugs

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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
                 CC|                            |gjl at gcc dot gnu.org
      Known to fail|                            |

--- Comment #5 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-06-10 19:59:47 UTC ---
Funnc artifact. It occurs only if all low-bits are set, i.e. wich constants
0x3f, 0x1f, 0xf, ... So persumably a middle and pass makes some strange
assumption.

(In reply to comment #1)
> This bug is confirmed. andhi3/andsi3 causing this problem. conditional checks
> in andhi3 and andsi3 need to compare with zero instead of 0xff [etc]. 
> i.e. in andhi3 we need to replace
> (mask & 0x00ff) != 0xff by (mask & 0x00ff) != 0.
> 
> Similarly other checks in andhi3 and andsi3 need to be replaced.

Can you explain?

ANDding on a 8-bit part can only be omitted if the mask is 0xff. Otherwise, the
AND has to be performed, even if the result is known to be always zero.


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

* [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3..
       [not found] <bug-43088-4@http.gcc.gnu.org/bugzilla/>
  2011-06-10 20:01 ` [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3 gjl at gcc dot gnu.org
@ 2011-07-02 21:08 ` gjl at gcc dot gnu.org
  2011-07-04 13:31 ` [Bug rtl-optimization/43088] " gjl at gcc dot gnu.org
  2 siblings, 0 replies; 7+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-02 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-02 21:07:50 UTC ---
Created attachment 24659
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24659
C source file

Compile with -mmcu=atmega168 -Os.

This file shows the flaw in function foo_3f that compares against 0x3f in
comparison to foo_3e that compares against 0x3e.

If the comparison is against 0x3e the code is fine.

The difference happens in pass combine. For 0x3f, combine tryes ZERO_EXTRACT:

Trying 8, 9 -> 10:
Failed to match this instruction:
(parallel [
        (set (cc0)
            (compare (zero_extract:HI (reg:QI 43 [ count.3 ])
                    (const_int 6 [0x6])
                    (const_int 0 [0]))
                (const_int 0 [0])))
        (clobber (scratch:QI))
    ])
Failed to match this instruction:
(set (cc0)
    (compare (zero_extract:HI (reg:QI 43 [ count.3 ])
            (const_int 6 [0x6])
            (const_int 0 [0]))
        (const_int 0 [0])))
Failed to match this instruction:
(set (reg:HI 52)
    (zero_extract:HI (reg:QI 43 [ count.3 ])
        (const_int 6 [0x6])
        (const_int 0 [0])))

.............................................


But for 0x3e it tryes AND, which matches (presumably combine-split):

Trying 8, 9 -> 10:
Failed to match this instruction:
(parallel [
        (set (cc0)
            (compare (and:QI (reg:QI 43 [ count.1 ])
                    (const_int 62 [0x3e]))
                (const_int 0 [0])))
        (clobber (scratch:QI))
    ])
Failed to match this instruction:
(set (cc0)
    (compare (and:QI (reg:QI 43 [ count.1 ])
            (const_int 62 [0x3e]))
        (const_int 0 [0])))
Successfully matched this instruction:
(set (reg:QI 52)
    (and:QI (reg:QI 43 [ count.1 ])
        (const_int 62 [0x3e])))
Successfully matched this instruction:
(set (cc0)
    (compare (reg:QI 52)
        (const_int 0 [0])))
deferring deletion of insn with uid = 8.
...


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

* [Bug rtl-optimization/43088] [avr] Suspect optimizer missed code in gcc 4.4.3..
       [not found] <bug-43088-4@http.gcc.gnu.org/bugzilla/>
  2011-06-10 20:01 ` [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3 gjl at gcc dot gnu.org
  2011-07-02 21:08 ` gjl at gcc dot gnu.org
@ 2011-07-04 13:31 ` gjl at gcc dot gnu.org
  2 siblings, 0 replies; 7+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-04 13:31 UTC (permalink / raw)
  To: gcc-bugs

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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
          Component|target                      |rtl-optimization
      Known to work|                            |4.7.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #7 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-04 13:30:03 UTC ---
Closed in 4.7.0

This was a flaw in insn combine as explained above.

In 4.7.0 trunk (SVN 175811) the problem is solved and the two versions, one
with 0x3f and one with 0x3e, yield the same, optimal assembler:

foo_3f:
    lds r24,count.1210     ;  5    *movqi/4    [length = 2]
    subi r24,lo8(-(1))     ;  6    addqi3/2    [length = 1]
    sts count.1210,r24     ;  7    *movqi/3    [length = 2]
    andi r24,lo8(63)     ;  8    andqi3/2    [length = 1]
    breq .L2     ;  10    branch    [length = 1]
    cbi 40-0x20,0     ;  16    *cbi    [length = 1]
    ret     ;  36    return    [length = 1]
.L2:
    sbi 40-0x20,0     ;  25    *sbi    [length = 1]
    ret     ;  38    return    [length = 1]
    .size    foo_3f, .-foo_3f

foo_3e:
    lds r24,count.1214     ;  5    *movqi/4    [length = 2]
    subi r24,lo8(-(1))     ;  6    addqi3/2    [length = 1]
    sts count.1214,r24     ;  7    *movqi/3    [length = 2]
    andi r24,lo8(62)     ;  8    andqi3/2    [length = 1]
    breq .L5     ;  10    branch    [length = 1]
    cbi 40-0x20,0     ;  16    *cbi    [length = 1]
    ret     ;  34    return    [length = 1]
.L5:
    sbi 40-0x20,0     ;  25    *sbi    [length = 1]
    ret     ;  36    return    [length = 1]


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

* [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3..
  2010-02-16  6:03 [Bug c/43088] New: " uhmgawa at third-harmonic dot com
                   ` (2 preceding siblings ...)
  2010-09-20  4:24 ` abnikant dot singh at atmel dot com
@ 2010-09-20 12:59 ` eric dot weddington at atmel dot com
  3 siblings, 0 replies; 7+ messages in thread
From: eric dot weddington at atmel dot com @ 2010-09-20 12:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from eric dot weddington at atmel dot com  2010-09-20 12:58 -------
(In reply to comment #3)
> 
> It exits for the reported version (4.4.3) and as well as for trunk/4.6.
> 

Abnikant, could you also post the patch that fixes this problem? Thanks.


-- 

eric dot weddington at atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.4.3 4.6.0


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


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

* [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3..
  2010-02-16  6:03 [Bug c/43088] New: " uhmgawa at third-harmonic dot com
  2010-09-13  5:58 ` [Bug target/43088] " abnikant dot singh at atmel dot com
  2010-09-20  2:30 ` eric dot weddington at atmel dot com
@ 2010-09-20  4:24 ` abnikant dot singh at atmel dot com
  2010-09-20 12:59 ` eric dot weddington at atmel dot com
  3 siblings, 0 replies; 7+ messages in thread
From: abnikant dot singh at atmel dot com @ 2010-09-20  4:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from abnikant dot singh at atmel dot com  2010-09-20 04:24 -------
(In reply to comment #2)
> (In reply to comment #1)
> > This bug is confirmed. andhi3/andsi3 causing this problem. conditional checks
> > in andhi3 and andsi3 need to compare with zero instead of 0xff [etc]. 
> > i.e. in andhi3 we need to replace
> > (mask & 0x00ff) != 0xff by (mask & 0x00ff) != 0.
> > 
> > Similarly other checks in andhi3 and andsi3 need to be replaced.
> > 
> 
> Abnikant,
> 
> Is this bug confirmed for the reported version (4.4.3), or for trunk/4.6?
> 

It exits for the reported version (4.4.3) and as well as for trunk/4.6.


-- 


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


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

* [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3..
  2010-02-16  6:03 [Bug c/43088] New: " uhmgawa at third-harmonic dot com
  2010-09-13  5:58 ` [Bug target/43088] " abnikant dot singh at atmel dot com
@ 2010-09-20  2:30 ` eric dot weddington at atmel dot com
  2010-09-20  4:24 ` abnikant dot singh at atmel dot com
  2010-09-20 12:59 ` eric dot weddington at atmel dot com
  3 siblings, 0 replies; 7+ messages in thread
From: eric dot weddington at atmel dot com @ 2010-09-20  2:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from eric dot weddington at atmel dot com  2010-09-20 02:30 -------
(In reply to comment #1)
> This bug is confirmed. andhi3/andsi3 causing this problem. conditional checks
> in andhi3 and andsi3 need to compare with zero instead of 0xff [etc]. 
> i.e. in andhi3 we need to replace
> (mask & 0x00ff) != 0xff by (mask & 0x00ff) != 0.
> 
> Similarly other checks in andhi3 and andsi3 need to be replaced.
> 

Abnikant,

Is this bug confirmed for the reported version (4.4.3), or for trunk/4.6?


-- 

eric dot weddington at atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-09-20 02:30:21
               date|                            |


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


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

* [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3..
  2010-02-16  6:03 [Bug c/43088] New: " uhmgawa at third-harmonic dot com
@ 2010-09-13  5:58 ` abnikant dot singh at atmel dot com
  2010-09-20  2:30 ` eric dot weddington at atmel dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: abnikant dot singh at atmel dot com @ 2010-09-13  5:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from abnikant dot singh at atmel dot com  2010-09-13 05:58 -------
This bug is confirmed. andhi3/andsi3 causing this problem. conditional checks
in andhi3 and andsi3 need to compare with zero instead of 0xff [etc]. 
i.e. in andhi3 we need to replace
(mask & 0x00ff) != 0xff by (mask & 0x00ff) != 0.

Similarly other checks in andhi3 and andsi3 need to be replaced.


-- 

abnikant dot singh at atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |abnikant dot singh at atmel
                   |                            |dot com


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


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

end of thread, other threads:[~2011-07-04 13:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-43088-4@http.gcc.gnu.org/bugzilla/>
2011-06-10 20:01 ` [Bug target/43088] [avr] Suspect optimizer missed code in gcc 4.4.3 gjl at gcc dot gnu.org
2011-07-02 21:08 ` gjl at gcc dot gnu.org
2011-07-04 13:31 ` [Bug rtl-optimization/43088] " gjl at gcc dot gnu.org
2010-02-16  6:03 [Bug c/43088] New: " uhmgawa at third-harmonic dot com
2010-09-13  5:58 ` [Bug target/43088] " abnikant dot singh at atmel dot com
2010-09-20  2:30 ` eric dot weddington at atmel dot com
2010-09-20  4:24 ` abnikant dot singh at atmel dot com
2010-09-20 12:59 ` eric dot weddington at atmel dot com

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).