Summary: | Does not propagate memory load base through useless type conversion | ||
---|---|---|---|
Product: | gcc | Reporter: | Richard Biener <rguenth> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gcc-bugs |
Priority: | P3 | Keywords: | missed-optimization |
Version: | 4.2.0 | ||
Target Milestone: | 4.3.0 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2006-04-12 01:20:10 | |
Bug Depends on: | |||
Bug Blocks: | 22501, 27181 | ||
Attachments: |
prototype patch
updated patch |
Description
Richard Biener
2006-04-08 17:04:19 UTC
Created attachment 11227 [details]
prototype patch
I have a prototype patch for forwprop that handles this, but somehow messes up virtual operands. We get a non-ssaname VUSE:
# VUSE <opD.8355>;
D.6255_561 = D.6253_558->typeD.4890
during build of libcpp.
Hm, we have from DCE to forwprop struct cpp_token * D.6254; struct cpp_token * D.6253; # temp_1334 = V_MAY_DEF <temp_330>; # unsignedp_1335 = V_MAY_DEF <unsignedp_333>; # op_1336 = V_MAY_DEF <op_351>; # SMT.698_1337 = V_MAY_DEF <SMT.698_1262>; # SMT.700_1338 = V_MAY_DEF <SMT.700_1287>; # SMT.703_1339 = V_MAY_DEF <SMT.703_1307>; D.6253_558 = cpp_get_token (pfile_475); D.6254_560 = D.6253_558; - # VUSE <op_1336>; - D.6255_561 = D.6254_560->type; + D.6255_561 = D.6253_558->type; D.6256_562 = (cpp_ttype) D.6255_561; # SFT.637_563 = V_MUST_DEF <SFT.637_360>; op.op = D.6256_562; Of course this is from tramp3d, and I hope fixing it would enable the hoisting of more invariant loads out of the inner loops. hmhm, merge_alias_info seems to fix it forwrop when propragating better be using merge_ssa_info anyways, just like copy prop and such. Here is the patch which fixes this issue for me: Index: cp-objcp-common.c =================================================================== --- cp-objcp-common.c (revision 112789) +++ cp-objcp-common.c (working copy) @@ -179,7 +179,7 @@ cxx_types_compatible_p (tree x, tree y) if (POINTER_TYPE_P (x) && POINTER_TYPE_P (y) && TYPE_MODE (x) == TYPE_MODE (y) && TYPE_REF_CAN_ALIAS_ALL (x) == TYPE_REF_CAN_ALIAS_ALL (y) - && same_type_p (TREE_TYPE (x), TREE_TYPE (y))) + && same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (x), TREE_TYPE (y))) return 1; return 0; I am testing the C++ patch right now. It is always a better idea to fix a pass to do what it should be doing instead of hacking another one to do the same. The C++ patch fixes the problem with this code and it also finished bootstrapping without any regression so please test it fully and submit it instead of your hack. PASS: g++.old-deja/g++.mike/dyncast7.C (test for excess errors) FAIL: g++.old-deja/g++.mike/dyncast7.C execution test const Foo* and Foo* are really not compatible. We can just exchange Foo* for const Foo* for loads. Created attachment 11250 [details]
updated patch
Patch I will clean and test instead. Also fixes 27090.
(In reply to comment #9) > PASS: g++.old-deja/g++.mike/dyncast7.C (test for excess errors) > FAIL: g++.old-deja/g++.mike/dyncast7.C execution test I did not get that failure. Subject: Bug number PR27084 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00750.html Subject: Bug 27084 Author: rguenth Date: Wed Jul 5 10:54:17 2006 New Revision: 115200 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115200 Log: 2006-07-05 Richard Guenther <rguenther@suse.de> Andrew Pinski <pinskia@gcc.gnu.org> PR c++/27084 * cp-objcp-common.c (cxx_types_compatible_p): Ignore top level qualifiers for pointer type comparisons. * g++.dg/tree-ssa/copyprop-1.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-objcp-common.c trunk/gcc/testsuite/ChangeLog Fixed. Subject: Bug 27084 Author: rguenth Date: Wed Aug 2 20:48:59 2006 New Revision: 115887 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115887 Log: 2006-08-02 Richard Guenther <rguenther@suse.de> PR c++/28479 Revert 2006-07-05 Richard Guenther <rguenther@suse.de> Andrew Pinski <pinskia@gcc.gnu.org> PR c++/27084 * cp-objcp-common.c (cxx_types_compatible_p): Ignore top level qualifiers for pointer type comparisons. * g++.dg/tree-ssa/copyprop-1.C: XFAIL. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-objcp-common.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C Patch was reverted. Will not be fixed in 4.2.0; retargeting at 4.2.1. Change target milestone to 4.2.3, as 4.2.2 has been released. This is fixed on the mainline by the middle-end type-system and the first forwprop pass. cxx_types_compatible_p is no longer involved for pointer types. |