FP min/max is different and more complicated due to the special NaN
handling behavior. Integer min/max is representable with only a compare
and select, so I think it would be preferable to just canonicalize to
using those two instructions
-Matt
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
I'm missing context here. Can you describe in more detail how the IR
choice affects the code generation? In case the target has special
integer min / max instructions, why is matching all three variants
difficult?
-Manuel
define i32 @max4(i32 %x, i32 %y) {
%sub = sub nsw i32 %x, %y%max = llvm.smax.i32(i32 %sub, i32 0) ; this intrinsic doesn't exist todayret i32 %max
}
FWIW, InstCombine doesn't canonicalize any of the first 3 options currently. Codegen suffers because of that (depending on the target machine and data types). Regardless of the IR choice, some backend fixes are needed.
Another possible consideration is the structure/accuracy of the cost models used by the vectorizers and other passes. I don't think they ever special-case the cmp+sel pair as a possibly unified (and therefore cheaper than the sum of the parts) operation.
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Hal> Noting that all of the above use the same number of IR instructions, I prefer this third option:
as does RecurrenceDescriptor::isMinMaxSelectCmpPattern(), which looks for “Select(ICmp(X, Y), X, Y)”.
Sanjay> Another possible consideration is the structure/accuracy of the cost models used by the vectorizers and other passes. I don't think they ever special-case the cmp+sel pair as a possibly unified (and therefore cheaper than the sum of the parts) operation.
They call the above to identify min/max reductions; and use TTI::getCmpSelInstrCost(). Special-casing may be redundant if the costs of scalar-vs-vector min/max correspond to the costs of scalar-vs-vector cmp&sel.
Ayal.
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.