1. Choice of Operations in atomic_rmw
I have a question regarding the choice of operations in this section of the code. Why are we not using arith.maximumf
and arith.minimumf
here instead of the cmpf
+ select
combination? Is there a specific reason for this choice? It seems more consistent to use these specific operations, especially given the future introduction of arith.maxnumf
and arith.minnumf
operations, along with atomic_rmw.maxnumf
and atomic_rmw.minnumf
. If we keep the cmpf
+ select
pattern, the code generation is going to be the same for pairs of min/max operations, which seems not quite correct.
2. Folding Patterns
I also noticed that there are relatively few folding patterns for arith.maximumf
and arith.minimumf
in the codebase. For instance, here, there are only three patterns implemented:
a) maxf(x,x) -> x
b) maxf(x, -inf) -> x
c) Constant folding
However, I can think of several additional patterns that could be useful:
d) maxf(-inf, x) -> x
e) maxf(+inf, x) -> +inf
g) maxf(x, +inf) -> +inf
There may be even more possibilities, but these examples come to mind right away. Why haven’t these patterns been implemented? It’s particularly puzzling that pattern (b) is folded but not pattern (d). Is it possible that the FoldAdaptor
recognizes the commutative nature of these operations and attempts both cases when only one is explicitly written? If so, that would be a helpful trick.
The situation is similar for arith.minimumf
.