Open eschnett opened 12 years ago
We would have to carefully add logic to make sure that the resulting program is equivalent. Isn't this something that we can rely on the compiler to do?
We can rely on the compiler in the same way as we can rely on its CSE and its vectorisation: in principle yes, but who knows.
It surely seems strange to define many variables with values such as 0, 1, or -1, and then multiply or add these later.
Indeed it is strange to do that. It is EinsteinExact which is behaving strangely, so maybe this logic should be in there? Or maybe we decide it is common to automatically generate the input to Kranc, and it is useful for Kranc to perform this sort of optimisation analysis. In any case, I don't think this is a high priority.
When code is auto-generated (e.g. in EinsteinExact), then there are often shorthands with special values, e.g. 0 or 1. Kranc should realise this and simplify expressions accordingly. For example:
a -> 0, b -> x + a
should be simplified to only
b -> x