https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104987
Bug ID: 104987 Summary: [12 Regression] Recent change causing vrp13.c regressions on several targets Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: law at gcc dot gnu.org Target Milestone: --- This change: commit 8db155ddf8cec9e31f0a4b8d80cc67db2c7a26f9 (refs/bisect/bad) Author: Andrew MacLeod <amacl...@redhat.com> Date: Thu Mar 17 10:52:10 2022 -0400 Always use dominators in the cache when available. This patch adjusts range_from_dom to follow the dominator tree through the cache until value is found, then apply any outgoing ranges encountered along the way. This reduces the amount of cache storage required. PR tree-optimization/102943 * gimple-range-cache.cc (ranger_cache::range_from_dom): Find range via dominators and apply intermediary outgoing edge ranges. Is causing gcc.dg/tree-ssa/vrp13.c to fail on a couple targets (iq2000-elf, v850e-elf). It looks like we're mis-compiling foo_mult. Here's the reduced testcase: /* { dg-do run } */ /* { dg-options -O2 } */ extern void abort (void); extern void link_error (void); int foo_mult (int i, int j) { int k; /* [-20, -10] * [2, 10] should give [-200, -20]. */ if (i >= -20) if (i <= -10) if (j >= 2) if (j <= 10) { k = i * j; if (k < -200) link_error (); if (k > -20) link_error (); return k; } /* [-20, -10] * [-10, -2] should give [20, 200]. */ if (i >= -20) if (i <= -10) if (j >= -10) if (j <= -2) { k = i * j; if (k < 20) link_error (); if (k > 200) link_error (); return k; } /* [-20, 10] * [2, 10] should give [-200, 100]. */ if (i >= -20) if (i <= 10) if (j >= 2) if (j <= 10) { k = i * j; if (k < -200) link_error (); if (k > 100) link_error (); return k; } /* [-20, 10] * [-10, -2] should give [-100, 200]. */ if (i >= -20) if (i <= 10) if (j >= -10) if (j <= -2) { k = i * j; if (k < -100) link_error (); if (k > 200) link_error (); return k; } /* [10, 20] * [2, 10] should give [20, 200]. */ if (i >= 10) if (i <= 20) if (j >= 2) if (j <= 10) { k = i * j; if (k < 20) link_error (); if (k > 200) link_error (); return k; } /* [10, 20] * [-10, -2] should give [-200, -20]. */ if (i >= 10) if (i <= 20) if (j >= -10) if (j <= -2) { k = i * j; if (k < -200) link_error (); if (k > -20) link_error (); return k; } abort (); } int main() { if (foo_mult (10, -2) != -20) abort (); return 0; } The symptom on the v850 is we get the sign wrong on the multiplication. I haven't looked into what goes wrong on iq2000-elf.