------- Comment #2 from guillaume dot melquiond at ens-lyon dot fr 2006-04-28 09:03 ------- I tried setting the nonnull attribute, it indeed allowed the optimization. In particular, codes containing dynamic casts are now straight lines. This is a nice improvement. Unfortunately GCC was not able to go further and use this information in the caller in order to optimize it:
struct A { bool g() __attribute__((nonnull)); } bool f(A *a) { a->g(); return a; } Am I expecting too much from the nonnull attribute? (The documentation does not seem to cover this point.) Or would it be reasonnable for the middle-end to implement such an optimization? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27336