This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add new built-in: __builtin_unreachable()


Paul Brook wrote:
The new __builtin_unreachable() is meant to be placed directly after
an asm that never returns.  I cannot think of any other valid uses for
it

gcc_unreachable and gcc_assert are obvious candidates.

For gcc_unreachable I agree. For gcc_assert the problem is that sometimes turning


gcc_assert (*f);

into

  if (*f)
    __builtin_unreachable ();

is not a no-op, and it may introduce additional dereferences or additional register pressure that offset any optimization possibilities stemming from knowledge that "f && *f".

Besides, even in the second version there are two problems. First, the builtin only works on RTL. Until RTL, it does not act as it should---there is no optimization done on trees on

  if (*f)
    __builtin_unreachable ();
  return f != NULL;

(should optimize to return 1). Second, once in RTL I'm not sure how it behaves in cfglayout mode.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]