User account creation filtered due to spam.
Hi, For the following case: int f(int x, int y) { int ret; if (x == y) ret = x ^ y; else ret = 1; return ret; } x ^ y does not get folded to 0. From the discussion in: https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00385.html r233207 must have regressed this test-case. Thanks, Prathamesh
Confirmed.
I have a fix that makes this folded at -O2 by VRP. At -O1 we only have DOM which was optimizing this in GCC 5.
Author: rguenth Date: Thu Jul 21 13:00:32 2016 New Revision: 238591 URL: https://gcc.gnu.org/viewcvs?rev=238591&root=gcc&view=rev Log: 2016-07-21 Richard Biener <rguenther@suse.de> PR tree-optimization/71947 * tree-vrp.c (extract_range_from_assert): Singleton symbolic ranges have useful limit_vr information. * gcc.dg/tree-ssa/vrp102.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp102.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vrp.c
Now the testcase is optimized at -O2 by VRP but still not at -O1.
GCC 6.2 is being released, adjusting target milestone.
This ought to be fixable in DOM. Probably not worth backporting to gcc-6 though.
*** Bug 77647 has been marked as a duplicate of this bug. ***
So I don't like the pain of trying to fold at each propagation step. Specifically, the structure of the gimple statement can change, which invalidates the operand cache. And the canonicalization of operands based on their SSA_NAME_VERSIONs means it's possible to get cycles. While I've got something that appears to work, I'm not at all happy with it. So I started looking at a different approach. Just keep a record of copy propagated objects and if we've already propagated A for B, don't copy propagate B for A in the same statement. We can do this with a bitmap, but that's a lot of overhead, even when lazily initialized. I suspect this matters so rarely in practice that a single entry "this was the last thing copy propagated" is sufficient.
Author: law Date: Mon Oct 10 20:40:59 2016 New Revision: 240947 URL: https://gcc.gnu.org/viewcvs?rev=240947&root=gcc&view=rev Log: PR tree-optimization/71947 * tree-ssa-dom.c (cprop_into_stmt): Avoid replacing A with B, then B with A within a single statement. PR tree-optimization/71947 * gcc.dg/tree-ssa/pr71947-1.c: New test. * gcc.dg/tree-ssa/pr71947-2.c: New test. * gcc.dg/tree-ssa/pr71947-3.c: New test. * gcc.dg/tree-ssa/pr71947-4.c: New test. * gcc.dg/tree-ssa/pr71947-5.c: New test. * gcc.dg/tree-ssa/pr71947-6.c: New test. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-1.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-2.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-3.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-4.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-5.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-6.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-dom.c
Author: law Date: Fri Oct 21 20:41:34 2016 New Revision: 241429 URL: https://gcc.gnu.org/viewcvs?rev=241429&root=gcc&view=rev Log: * PR tree-optimization/71947 * gcc.dg/tree-ssa/pr71947-4.c: Avoid x86 opcode. * gcc.dg/tree-ssa/pr71947-5.c: Likewise. * gcc.dg/tree-ssa/pr71947-6.c: Make it opt-in rather than opt-out. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-4.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-5.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr71947-6.c
GCC 6.3 is being released, adjusting target milestone.
GCC 6.4 is being released, adjusting target milestone.