public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/67979] New: dead code elimination deleted the predicated branch within the function block.
@ 2015-10-15 19:30 feqin1023 at gmail dot com
  2015-10-15 19:42 ` [Bug c/67979] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: feqin1023 at gmail dot com @ 2015-10-15 19:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67979

            Bug ID: 67979
           Summary: dead code elimination deleted the predicated branch
                    within the function block.
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: feqin1023 at gmail dot com
  Target Milestone: ---

Created attachment 36518
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36518&action=edit
the source test dead code elimination.

if i have this input:

/*--------------------test.c----------------------------*/
void bar_i(int);
void foo(int *x) {
  int y = *x; // dead code can be clean
  if (!x)
    return;   // this branch ALSO will be clean 
  bar_i(y);
}
/*------------------------------------------------------*/

we call gcc like this:

  gcc -O2 -S test.c

the the whole branch in function foo(int *) will be clean.
BUT, if foo(int *) is called like this:

  foo(NULL);

gcc has CHANGED the original semantic even sometimes which
 is error. but compiler can do this?

I also test Clang, Clang ALWAYS keep the branch in foo(int *).


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

* [Bug c/67979] dead code elimination deleted the predicated branch within the function block.
  2015-10-15 19:30 [Bug c/67979] New: dead code elimination deleted the predicated branch within the function block feqin1023 at gmail dot com
@ 2015-10-15 19:42 ` pinskia at gcc dot gnu.org
  2015-10-15 20:09 ` feqin1023 at gmail dot com
  2015-10-16  7:49 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-10-15 19:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67979

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The code is undefined if NULL is passed and that is why the branch is removed. 
If you don't want this optimization then use -fno-delete-null-pointer-checks


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

* [Bug c/67979] dead code elimination deleted the predicated branch within the function block.
  2015-10-15 19:30 [Bug c/67979] New: dead code elimination deleted the predicated branch within the function block feqin1023 at gmail dot com
  2015-10-15 19:42 ` [Bug c/67979] " pinskia at gcc dot gnu.org
@ 2015-10-15 20:09 ` feqin1023 at gmail dot com
  2015-10-16  7:49 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: feqin1023 at gmail dot com @ 2015-10-15 20:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67979

zet <feqin1023 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED
         Resolution|INVALID                     |FIXED

--- Comment #2 from zet <feqin1023 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> The code is undefined if NULL is passed and that is why the branch is
> removed.  If you don't want this optimization then use
> -fno-delete-null-pointer-checks

Well, it's a feature.
Thx.


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

* [Bug c/67979] dead code elimination deleted the predicated branch within the function block.
  2015-10-15 19:30 [Bug c/67979] New: dead code elimination deleted the predicated branch within the function block feqin1023 at gmail dot com
  2015-10-15 19:42 ` [Bug c/67979] " pinskia at gcc dot gnu.org
  2015-10-15 20:09 ` feqin1023 at gmail dot com
@ 2015-10-16  7:49 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-16  7:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67979

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 67978 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2015-10-16  7:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-15 19:30 [Bug c/67979] New: dead code elimination deleted the predicated branch within the function block feqin1023 at gmail dot com
2015-10-15 19:42 ` [Bug c/67979] " pinskia at gcc dot gnu.org
2015-10-15 20:09 ` feqin1023 at gmail dot com
2015-10-16  7:49 ` rguenth at gcc dot gnu.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).