On Wed, 2 Sep 2020, Richard Biener via Gcc wrote: > > Or we could decide that the extra multiplication is not that bad if it > > saves an addition, simplifies the expression, possibly gains more insn > > parallelism, etc, in which case we could just drop the existing hard > > single_use check... > > ;) > > it's all going to be heuristics because the decision is made > locally. If you consider the other two uses might be > 5*X + 3*X then converting both to 2*X and 8*X should be > a win because we save one addition and one subtraction. > But that would require folding everything tentatively and > then applying some global costing ...
Arguably simplification on GIMPLE should fold towards what is 1) declared "canonical form" 2) cheaper in the C abstract machine ;) and let machine-specific passes "expand" the result as needed towards higher ILP or whatever the concrete machine prefers :) Alexander