https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77877

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-10-06
          Component|tree-optimization           |rtl-optimization
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The point is that with the modulus visible VRP will remove the default case
(or rather take a random one -- here the first one -- as new default):

  <bb 2>:
  n_9 = n_8(D) % 3;
  switch (n_9) <default: <L0>, case 1: <L1>, case 2: <L2>>

<L0>:
  zero.0_1 = zero;
  _2 = zero.0_1 + 1;
  zero = _2;
  goto <bb 6>;

<L1>:
  one.1_3 = one;
  _4 = one.1_3 + 1;
  one = _4;
  goto <bb 6>;

<L2>:
  two.2_5 = two;
  _6 = two.2_5 + 1;
  two = _6;

  <bb 6>:
  return;

if we don't have the modulo then the default case will not be optimized away
(not the one with the unreachable either) before RTL expansion.  So it looks
like the four-cases variant where one case later vanishes happens to be
expanded better.

Which means we should improve expansion for the IL case above
(stmt.c:expand_case).  Or work around by choosing another value as
the "default" if that makes expand_case happy.

Reply via email to