On Tue, 27 Aug 2024, Kai Song via Gcc-help wrote:
I would like to add an example so as to clarify what it is that I seek help on: I have a custom implementation of a class called Number. Number has overloaded operators that write down a program of all computations that Number witnesses in an original program. For example, when the original program reads (original code): z=x-(-y); Then upon execution with type Number the following program will be produced (generated code) as caused through stream buffers in Number: tmp1 = -y; z = x-tmp1; This generated code is inferior to as if the original code had been "z=x+y;". Using expression templates or hoping for excellent compiler optimization on the "generated code", I could try to improve the performance of the generated code. But that means equal to re-inventing the wheel, because obviously the compilers have exactly these algebraic optimization capabilities already built in. So I want to use these capabilities. This is what my request is all about. Certainly the compiler has algebraic expression optimization built in, so what I now seek to find out is whether and how this can be leveraged outside the rule-scope of native c++, so as to improve the algebra of my original code. Of course I am aware that this alters the original programs result entirely (as per the above example) but this is precisely what I wish for.
The option -ffast-maths has nothing to do with this sort of optimization. -- Andrew C. Aitchison Kendal, UK andrew@xxxxxxxxxxxxxxx