public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/41477]  New: gcc does not optimize a case that it should to make __builtin_object_size() more useful
@ 2009-09-26 18:02 arjan at linux dot intel dot com
  2009-09-26 18:02 ` [Bug c/41477] " arjan at linux dot intel dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: arjan at linux dot intel dot com @ 2009-09-26 18:02 UTC (permalink / raw)
  To: gcc-bugs

(see attached testcases; testcase.c shows the problem, testcase2.c shows that
reorging the code works around it)

it appears that gcc does not realize that after

if (variable < 1 || variable > 10)
     return -1;

the "variable" is in the range [1..10], likely because the execution of the
second check is optional due to the ||.

in a typical __builtin_object_size() scenario, like

if (__builtin_object_size(foo) < variable)
    some_error();

where foo is 10 bytes in size, this means the check does not get optimized out.


-- 
           Summary: gcc does not optimize a case that it should to make
                    __builtin_object_size() more useful
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: arjan at linux dot intel dot com


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


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

* [Bug c/41477] gcc does not optimize a case that it should to make __builtin_object_size() more useful
  2009-09-26 18:02 [Bug c/41477] New: gcc does not optimize a case that it should to make __builtin_object_size() more useful arjan at linux dot intel dot com
@ 2009-09-26 18:02 ` arjan at linux dot intel dot com
  2009-09-26 18:02 ` arjan at linux dot intel dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: arjan at linux dot intel dot com @ 2009-09-26 18:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from arjan at linux dot intel dot com  2009-09-26 18:02 -------
Created an attachment (id=18658)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18658&action=view)
testcase showing the missed optimization


-- 


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


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

* [Bug c/41477] gcc does not optimize a case that it should to make __builtin_object_size() more useful
  2009-09-26 18:02 [Bug c/41477] New: gcc does not optimize a case that it should to make __builtin_object_size() more useful arjan at linux dot intel dot com
  2009-09-26 18:02 ` [Bug c/41477] " arjan at linux dot intel dot com
@ 2009-09-26 18:02 ` arjan at linux dot intel dot com
  2009-09-26 18:20 ` [Bug tree-optimization/41477] " pinskia at gcc dot gnu dot org
  2009-09-26 18:22 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: arjan at linux dot intel dot com @ 2009-09-26 18:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from arjan at linux dot intel dot com  2009-09-26 18:02 -------
Created an attachment (id=18659)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18659&action=view)
testcase that shows a slight reorder of the code works around the issue


-- 


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


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

* [Bug tree-optimization/41477] gcc does not optimize a case that it should to make __builtin_object_size() more useful
  2009-09-26 18:02 [Bug c/41477] New: gcc does not optimize a case that it should to make __builtin_object_size() more useful arjan at linux dot intel dot com
  2009-09-26 18:02 ` [Bug c/41477] " arjan at linux dot intel dot com
  2009-09-26 18:02 ` arjan at linux dot intel dot com
@ 2009-09-26 18:20 ` pinskia at gcc dot gnu dot org
  2009-09-26 18:22 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-26 18:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2009-09-26 18:20 -------
This has been fixed since 4.4.0.


-- 


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


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

* [Bug tree-optimization/41477] gcc does not optimize a case that it should to make __builtin_object_size() more useful
  2009-09-26 18:02 [Bug c/41477] New: gcc does not optimize a case that it should to make __builtin_object_size() more useful arjan at linux dot intel dot com
                   ` (2 preceding siblings ...)
  2009-09-26 18:20 ` [Bug tree-optimization/41477] " pinskia at gcc dot gnu dot org
@ 2009-09-26 18:22 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-26 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2009-09-26 18:22 -------


*** This bug has been marked as a duplicate of 30317 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2009-09-26 18:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-26 18:02 [Bug c/41477] New: gcc does not optimize a case that it should to make __builtin_object_size() more useful arjan at linux dot intel dot com
2009-09-26 18:02 ` [Bug c/41477] " arjan at linux dot intel dot com
2009-09-26 18:02 ` arjan at linux dot intel dot com
2009-09-26 18:20 ` [Bug tree-optimization/41477] " pinskia at gcc dot gnu dot org
2009-09-26 18:22 ` pinskia 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).