[LLVMdev] max/min intrinsics

Chris Lattner clattner at apple.com
Wed Dec 5 11:48:13 PST 2012


On Dec 5, 2012, at 8:26 AM, "Redmond, Paul" <paul.redmond at intel.com> wrote:

> I have been working on a patch to add support for max/min reductions in LoopVectorize. One of the comments that came up in review is that the implementation could be simplified (and less fragile) if max and min intrinsics were recognized rather than looking for compare-select sequences.
> 
> The suggestion was to change compare-selects into max and min intrinsic calls during instcombine.
> 
> The intrinsics to add are:
> declare iN llvm.{smin,smax}.iN(iN %a, iN %b)
> declare iN llvm.{umin,umax}.iN(iN %a, iN %b)
> declare fN llvm.{fmin,fmax}.fN(fN %a, fN %b)
> 
> What does the community think?

It seems inevitable.  For the floating point version, please make it very clear what the behavior of max(-0,+0) and related cases are.  This also means stuff that matches compare/select idioms (e.g. llvm/Support/PatternMatch.h) will need to be updated.

-Chris




More information about the llvm-dev mailing list