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

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #3)
> I thought we had code to recognize a switch that represents a linear
> function, I was hoping that it would kick in with your hoisting patch...

Yep, we have the code but as mentioned the sinking needs to happen first.
Otherwise, you'll see:

g++ pr94566.C -O2 -fdump-tree-switchconv=/dev/stdout -std=gnu++2a

;; Function conv2 (_Z5conv2i, funcdef_no=90, decl_uid=8463, cgraph_uid=59,
symbol_order=88)

beginning to process the following SWITCH statement (pr94566.C:4) : ------- 
switch (i_2(D)) <default: <L3> [INV], case -1: <L0> [INV], case 0: <L1> [INV],
case 1: <L2> [INV]>

Bailing out - bad case - a non-final BB not empty
--------------------------------
struct strong_ordering conv2 (int i)
{
  struct strong_ordering D.8476;

  <bb 2> :
  switch (i_2(D)) <default: <L3> [INV], case -1: <L0> [INV], case 0: <L1>
[INV], case 1: <L2> [INV]>

  <bb 3> :
<L0>:
  D.8476._M_value = -1;
  goto <bb 7>; [INV]

  <bb 4> :
<L1>:
  D.8476._M_value = 0;
  goto <bb 7>; [INV]

  <bb 5> :
<L2>:
  D.8476._M_value = 1;
  goto <bb 7>; [INV]

  <bb 6> :
<L3>:
  __builtin_unreachable ();

  <bb 7> :
  return D.8476;

}

Reply via email to