public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/33136] [4.1/4.2/4.3 Regression] wrong code due to alias with allocation in loop Date: Thu, 23 Aug 2007 12:13:00 -0000 [thread overview] Message-ID: <20070823121313.25886.qmail@sourceware.org> (raw) In-Reply-To: <bug-33136-12956@http.gcc.gnu.org/bugzilla/> ------- Comment #16 from jakub at gcc dot gnu dot org 2007-08-23 12:13 ------- But doesn't ipa_type_escape_field_does_not_clobber_p do what is documented? At least for the uses in nonoverlapping_memrefs_p where ipa_type_escape_field_does_not_clobber_p is always called on some field, first argument is a DECL_FIELD_CONTEXT of some field ans second argument is its type. Then IMHO ipa_type_escape_field_does_not_clobber_p does the right thing. If you take address of the whole struct rather than some specific field and that address doesn't escape the CU, then that still doesn't explain how could a pointer var with first field's type point to the struct. Say for struct A { int i; float f; } you still need (int *) ptrA where ptrA is struct A *, or &ptrA->i. Optimizations before ipa-type-escape will transform the former to the latter and if they don't, I believe check_cast will handle it anyway. The only problem in alias.c might be if exprx is COMPONENT_REF of the first field and expry is a var pointer to the whole struct A (or vice versa), then any taking of address of the whole struct anywhere would mean the MEMs could overlap. But in that case both MEMs will have different alias sets, don't they? The ipa_type_escape_field_does_not_clobber_p call in may_alias_p is very different though. Here we don't necessarily call it with some record (or union) type and a type of one of its fields, but rather with some record type (or pointer to it, pointer to pointer etc.) and some possibly completely unrelated other pointer type. Well, because of previous if (!alias_sets_conflict_p (mem_alias_set, var_alias_set)) return false; it shouldn't be completely unrelated. In most cases it will actually be the same type and that's something ipa_type_escape_field_does_not_clobber_p wasn't meant to answer. I have instrumented may_alias_p, so that if ipa_type_escape_field_does_not_clobber_p returned false for reasons other than !initialized or !ipa_type_escape_type_contained_p, it would abort. The only testcase in the whole make check-{gcc,g++,gfortran} testsuite triggering this was gcc.c-torture/execute/builtins/pr22237.c, where var had a union type which contained ptr's type as one of its subfields. The whole use of ipa_type_escape_field_does_not_clobber_p in may_alias_p is very much unclear to me. E.g.: else if (ptr_star_count == 0) { /* If PTR_TYPE was not really a pointer to type, it cannot alias. */ alias_stats.structnoaddress_queries++; alias_stats.structnoaddress_resolved++; alias_stats.alias_noalias++; return false; } Isn't ptr guaranteed to be have POINTER_TYPE or REFERENCE_TYPE? Both from the way how is ->pointers array populated and e.g. that PTR_IS_REF_ALL is used before may_alias_p on the p_map->var resp. p_map1->var? That implies ptr_star_count > 0, so the above listed chunk is never executed. Also, as we don't care in the code whether ptr_star_count is 37 or just 1, I don't see the point in computing ptr_star_count at all, nor the existence of ptr_type variable. If ipa_type_escape_star_count_of_interesting_type (var_type) > 0 (i.e. var is a pointer to struct/union rather than struct/union itself, how is the fact that something took address of fields within the struct itself relevant to whether some pointer may point to the pointer var or not? If ipa_type_escape_star_count_of_interesting_type (var_type) == 0, then ipa_type_escape_field_does_not_clobber_p call would make sense if ptr was a pointer to some field (field of field etc.), but then it needs to be called with TREE_TYPE (TREE_TYPE (ptr)) as second argument, otherwise it is asking a wrong question. But if ptr's type is the struct/union itself, all we care is if that record/union's address has been taken, which is not something ipa-type-escape won't answer. Isn't that what TREE_ADDRESSABLE can be used for? Please explain. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33136
next prev parent reply other threads:[~2007-08-23 12:13 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-08-21 12:23 [Bug regression/33136] New: -Os generated code grew almost twice 4.2.1 versus 4.1.1 vda dot linux at googlemail dot com 2007-08-21 12:24 ` [Bug regression/33136] " vda dot linux at googlemail dot com 2007-08-21 12:26 ` vda dot linux at googlemail dot com 2007-08-21 12:27 ` vda dot linux at googlemail dot com 2007-08-21 13:11 ` rguenth at gcc dot gnu dot org 2007-08-21 13:12 ` [Bug tree-optimization/33136] [4.2/4.3 Regression] " rguenth at gcc dot gnu dot org 2007-08-21 16:20 ` pinskia at gcc dot gnu dot org 2007-08-22 13:27 ` jakub at gcc dot gnu dot org 2007-08-22 13:55 ` jakub at gcc dot gnu dot org 2007-08-22 13:57 ` jakub at gcc dot gnu dot org 2007-08-22 14:20 ` rguenth at gcc dot gnu dot org 2007-08-22 14:29 ` jakub at gcc dot gnu dot org 2007-08-22 15:15 ` [Bug tree-optimization/33136] [4.1/4.2/4.3 " rguenth at gcc dot gnu dot org 2007-08-22 15:53 ` [Bug tree-optimization/33136] [4.1/4.2/4.3 Regression] wrong code due to alias with allocation in loop dberlin at gcc dot gnu dot org 2007-08-22 17:24 ` jakub at gcc dot gnu dot org 2007-08-22 20:10 ` dberlin at gcc dot gnu dot org 2007-08-23 12:13 ` jakub at gcc dot gnu dot org [this message] 2007-08-23 13:45 ` dberlin at dberlin dot org 2007-08-23 14:49 ` jakub at redhat dot com 2007-08-23 17:09 ` dberlin at dberlin dot org 2007-08-24 15:39 ` jakub at gcc dot gnu dot org 2007-08-24 15:42 ` dberlin at dberlin dot org 2007-08-24 16:17 ` jakub at gcc dot gnu dot org 2007-08-24 16:21 ` dberlin at dberlin dot org 2007-08-24 16:37 ` jakub at gcc dot gnu dot org 2007-09-05 1:09 ` mmitchel at gcc dot gnu dot org 2007-09-05 5:47 ` jakub at gcc dot gnu dot org 2007-09-11 17:21 ` jakub at gcc dot gnu dot org 2007-09-11 19:26 ` jakub at gcc dot gnu dot org 2007-09-11 19:52 ` jakub at gcc dot gnu dot org 2007-09-28 4:02 ` mmitchel at gcc dot gnu dot org 2007-10-15 18:30 ` jakub at gcc dot gnu dot org 2007-10-15 18:52 ` [Bug tree-optimization/33136] [4.1/4.2 " jakub at gcc dot gnu dot org 2008-07-04 22:16 ` [Bug tree-optimization/33136] [4.2 " jsm28 at gcc dot gnu dot org 2009-03-30 22:17 ` jsm28 at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20070823121313.25886.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).