[llvm] InstSimplify: support floating-point equivalences (PR #115152)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 08:32:34 PST 2024
https://github.com/nikic requested changes to this pull request.
I think this is missing tests for the non-refining code path. Try something along the lines of folding `(x == 1) ? y : (x * y)` to `x * y`.
And related to that, I think we need to be extra careful about derefinement here. For integers, the only derefinement we really have to worry about is related to undef and poison, which the existing code already does. But for FP we also have to worry about non-determinism relating to libcalls and NaN behavior.
For example, if we have something like `x == C : sin(C) : sin(x)`, then we should generally not fold that to `sin(x)`, because we cannot guarantee that `sin(x)` at runtime folds to the same `sin(C)` that the host libm produced.
We should be able to avoid this by passing the non-determinism flag to the constant folding API in simplifyWithOpReplaced, for the non-refining case.
https://github.com/llvm/llvm-project/pull/115152
More information about the llvm-commits
mailing list