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

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