https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78529
--- Comment #9 from prathamesh3492 at gcc dot gnu.org --- (In reply to Richard Biener from comment #6) > (In reply to prathamesh3492 from comment #5) > > (In reply to Jakub Jelinek from comment #4) > > > The cmp %rax, %rax is just a missed optimization, because we manage to > > > optimize it only so late that nothing cleans it up afterwards. We could > > > optimize this away already in GIMPLE, e.g. for SCCVN use the same VN for > > > return value of pass-through builtin as the corresponding argument (if we > > > don't do that already). > > > That doesn't explain the failure. > > Hmm yes, but I don't understand why should this patch cause the test to > > fail. > > The patch makes following two separate changes: > > > > a) to make gimple_stmt_nonzero_warnv_p (stmt) return true, if stmt is > > function-call, and the function returns one of it's argument and that > > argument is non-null. However this change doesn't make any difference to the > > .evrp > > (and .optimized) dumps for strcat-chk.c > > because the patch expects SSA_VAR_P (arg) to be true, and the argument is > > MEM_REF. > > > > b) The other change was to modify attribute of string builtins like STRCAT, > > STRNCAT, etc. from ATTR_NOTHROW_NONNULL_LEAF > > to ATTR_RET1_NOTHROW_NONNULL_LEAF, which resulted in above code-gen > > difference, but as you mention it's a missed optimization > > and not incorrect. > > > > I would be grateful for suggestions on how to proceed. > > > > As I said, look at the additional sources involved, like > execute/builtins/lib/chk.c, and the effect on those. Hi Richard, It seems strcat-chk.c depends on lib/chk.c and lib/main.c. For lib/chk.c, I verified that there is no difference in .optimized dump and slim .dfinish dump with and without patch on aarch64-none-elf. lib/main.c just contains definitions of main() which calls main_test() and link_error(), so didn't check that. Thanks, Prathamesh > > > Thanks, > > Prathamesh