This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/78529] [7 Regression] gcc.c-torture/execute/builtins/strcat-chk.c failed with lto/O2
- From: "prathamesh3492 at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 29 Nov 2016 10:00:18 +0000
- Subject: [Bug tree-optimization/78529] [7 Regression] gcc.c-torture/execute/builtins/strcat-chk.c failed with lto/O2
- Auto-submitted: auto-generated
- References: <bug-78529-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78529
--- Comment #5 from prathamesh3492 at gcc dot gnu.org ---
(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.
Thanks,
Prathamesh