On Sat, Jun 22, 2019 at 09:46:52AM -0600, Jeff Law wrote: > On 6/22/19 7:55 AM, Jason Duerstock wrote: > > More generally, we can rewrite > > > > if ( x > ((1 << z) -1)) { ...} > > > > as > > > > if ( x >> z ) { ... } > > > > This does not appear to currently be a gcc optimization. What is > > involved in adding it? > So first, when discussing this kind of stuff it's usually best to > actually have a compilable example. Fragments usually are insufficient. > > Adding it to the RTL optimizers would be painful because of the need for > type information (this is only valid when X is unsigned, right?) > > Adding it to the gimple optimizers is painful because the optimized form > is actually de-optimized on some targets (say embedded targets with weak > shifters) and querying the target costs/capabilities is generally > frowned upon in the gimple optimizers. > > I think the combination of those two factors would tend to argue for an > implementation in the gimple->rtl expanders. You've still got type > information and you can query the backend for costing and capabilities. > > cfgexpand::expand_gimple_cond might be a good place to start. > > Another place to poke around would be expr:expand_expr_real_2, case > COND_EXPR.
This is target-specific, so should just be done in the machine description? Segher