Re: [PATCH] Support if conversion for switches

2024-08-08 Thread Andi Kleen
> > But your comment made me realize there is a major bug. > > > > if_convertible_switch_p also needs to check that that the labels don't fall > > through, so the the flow graph is diamond shape. Need some easy way to > > verify that. > > Do we verify this for if()s? That is, No we do not. Afte

Re: [PATCH] Support if conversion for switches

2024-08-08 Thread Richard Biener
On Wed, Aug 7, 2024 at 9:33 PM Andi Kleen wrote: > > > > + /* Create chain of switch tests for each case. */ > > > + tree switch_cond = NULL_TREE; > > > + tree index = gimple_switch_index (sw); > > > + for (unsigned i = 1; i < gimple_switch_num_labels (sw); i++) >

Re: [PATCH] Support if conversion for switches

2024-08-07 Thread Andi Kleen
> > + /* Create chain of switch tests for each case. */ > > + tree switch_cond = NULL_TREE; > > + tree index = gimple_switch_index (sw); > > + for (unsigned i = 1; i < gimple_switch_num_labels (sw); i++) > > + { > > + tree label = gimple_switch

Re: [PATCH] Support if conversion for switches

2024-08-07 Thread Richard Biener
On Tue, Aug 6, 2024 at 4:38 PM Andi Kleen wrote: > > The gimple-if-to-switch pass converts if statements with > multiple equal checks on the same value to a switch. This breaks > vectorization which cannot handle switches. > > Teach the tree-if-conv pass used by the vectorizer to handle > simple s