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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> So the problem here is iftoswitch should ignore if it is profitable to
> convert the ifs to a switch statement (unless there are only two ifs) and
> then allow the switchlower pass to lower the switch again.

This was my original intention, but Jakub wanted to make the if-to-switch
transformation
only conditionally based on the ability to make a jump table or a bit-test.
Reason is that
some optimization passes work only on series of gimple conditions.

> 
> So x86 we get:
> ;; Canonical GIMPLE case clusters: 1 2 3 4 
> For foo
> and then for bar:
> ;; Canonical GIMPLE case clusters: 1 2 3 4 
> ;; BT can be built: BT(values:4 comparisons:8 range:4 density: 200.00%):1-4 
> /app/example.cpp:10:21: optimized: Condition chain with 4 BBs transformed
> into a switch statement.

In my case, it's not transformed as we do JT at least for 5 cases:

unsigned int
default_case_values_threshold (void)
{
  return (targetm.have_casesi () ? 4 : 5);
}

That's why you see a different codegen on ARM target.

Reply via email to