[Bug rtl-optimization/27761] combine miscompiles
--- Comment #7 from jakub at gcc dot gnu dot org 2006-12-12 15:03 --- Subject: Bug 27761 Author: jakub Date: Tue Dec 12 15:03:39 2006 New Revision: 119785 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=119785 Log: PR rtl-optimization/27761 * combine.c (try_combine): Don't create a useless garbage SET if PATTERN (i2) is a PARALLEL. If added_sets_1, save PATTERN (i1) resp. SET from i1src to i1dest in i1pat and use it to prevent accidental modification of i1src. Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #8 from jakub at gcc dot gnu dot org 2006-12-12 15:05 --- Subject: Bug 27761 Author: jakub Date: Tue Dec 12 15:05:08 2006 New Revision: 119786 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=119786 Log: PR rtl-optimization/27761 * combine.c (try_combine): Don't create a useless garbage SET if PATTERN (i2) is a PARALLEL. If added_sets_1, save PATTERN (i1) resp. SET from i1src to i1dest in i1pat and use it to prevent accidental modification of i1src. Modified: branches/gcc-4_2-branch/gcc/ChangeLog branches/gcc-4_2-branch/gcc/combine.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #9 from jakub at gcc dot gnu dot org 2006-12-12 15:07 --- Subject: Bug 27761 Author: jakub Date: Tue Dec 12 15:07:23 2006 New Revision: 119787 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=119787 Log: PR rtl-optimization/27761 * combine.c (try_combine): Don't create a useless garbage SET if PATTERN (i2) is a PARALLEL. If added_sets_1, save PATTERN (i1) resp. SET from i1src to i1dest in i1pat and use it to prevent accidental modification of i1src. Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/combine.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #10 from pinskia at gcc dot gnu dot org 2006-12-13 07:06 --- Fixed. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED Target Milestone|--- |4.1.2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #6 from ebotcazou at gcc dot gnu dot org 2006-09-13 08:44 --- Please indicate the version(s) of the compiler, whether it's a regression, etc. -- ebotcazou at gcc dot gnu dot org changed: What|Removed |Added CC||ebotcazou at gcc dot gnu dot ||org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #5 from wilson at gcc dot gnu dot org 2006-06-10 02:49 --- If a combination is successful, we will delete i1 and i2, so it doesn't matter if they changed accidentally. If a combination fails, then we go through undobuf and revert all changes, so it doesn't matter if i1 or i2 changed accidentally. They will be restored to their original values when we are done. The only case where it matters is if added_sets_2 or added_sets_1 is true. In this case, we will re-add the patterns from i1 and/or i2 after the combination. So in this case, we need to make sure we still have the original patterns. We already make a copy of the i2 pattern for this purpose. i2pat is a copy, and is only used if added_sets_2 is true. So we just need to do the same for i1pat. I agree the comment before the i2pat is a bit confusing. It looks like the copy was originally added to fix an obscure problem, but it also happens to fix this one too. It looks like there is an unnecessary gen_rtx_SET call, as i2pat will only be used if added_sets_2 is true. So the code setting i2pat should be moved inside the added_sets_2 if statement. The new i1pat code should work the same way. The actual modification of the if_then_else rtl happens inside force_to_mode, as called from simplify_and_const_int. See the uses of SUBST in the if_then_else case in force_to_mode. This problem could be fixed if we generated new rtl here instead of using SUBST, but I don't think that is helpful, as there are other places that also call SUBST. It is safer to make the i1pat copy. -- wilson at gcc dot gnu dot org changed: What|Removed |Added CC||wilson at gcc dot gnu dot ||org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2006-06-10 02:49:49 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #1 from pinskia at gcc dot gnu dot org 2006-05-24 18:17 --- (intptr_t)struct A*)0x0)-mem1) ); That is undefined. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #2 from pinskia at gcc dot gnu dot org 2006-05-24 18:19 --- For the same reason __builtin_offsetof also hides the bug. Because it gets lowered correctly to a constant while (intptr_t)struct A*)0x0)-mem1) ) is not a constant. Why is someone using that method of offsetof? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #3 from matz at gcc dot gnu dot org 2006-05-24 18:22 --- Created an attachment (id=11508) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11508action=view) possible patch I was wrong about simplify_if_then_else, it uses pc_rtx in all subst calls. But that leaves three others which use their TO argument unprotected. The patch here solves the miscompilation for me. As of yet, untested otherwise. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761
[Bug rtl-optimization/27761] combine miscompiles
--- Comment #4 from matz at gcc dot gnu dot org 2006-05-24 18:26 --- Andrew, I know that this is undefined. Let us ignore this issue for this bug. I tried some time to come up with two nicer functions which still get inlined but are not optimized too early to hide the bug, but failed. Probably the testcase can be made using __builtin_offset, and then switching off certain tree-optimizer passes, but I didn't try. Debugging combine was painful enough :-) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27761