[PATCH] D29338: AMDGPU: Basic folds for fmed3 intrinsic

Artem Tamazov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 12:46:46 PST 2017


artem.tamazov accepted this revision.
artem.tamazov added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D29338#687608, @arsenm wrote:

> As far as this intrinsic is concerned, as long as it preserves general NaN behavior ignoring quieting etc. that should OK


All right. I just would like to make the case clear. When shader is in IEEE mode, this intrinsic does not preserve NAN behavior for some cases, e.g. if (x == sNAN), then (fmed3(0,1,x) == qNAN), but (fmed3(x,0,1) == 1). This is OK until we do not try to fold OpenCL constructs like

  if (fmax(fmax(a, b), c) == a)
    d = fmax(b, c);
  else if (fmax(fmax(a, b), c) == b)
    d = fmax(a, c);
  else
    d = fmax(a, b);

to

  d = llvm.amdgcn.fmed3(a, b , c);




https://reviews.llvm.org/D29338





More information about the llvm-commits mailing list