[PATCH] D74263: [ValueTracking] Improve isKnownNonNaN() to recognize zero splats.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 7 16:05:32 PST 2020


jonpa created this revision.
jonpa added reviewers: jmolloy, tlively.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Hi,

I noticed that this function:

  define <2 x double> @f1(<2 x double> %val) {
    %cmp = fcmp ogt <2 x double> %val,  zeroinitializer
    %ret = select <2 x i1> %cmp, <2 x double> %val, <2 x double> zeroinitializer
    ret <2 x double> %ret
  }

, which I expected to be implemented with a systemZ vfmaxdb (vector fp maximum), was not represented on the DAG with an fmaxnum node, and therefore not in the assembly output either.

I found this to be due to the fact that ValueTracking.cpp:isKnownNonNaN() is not recognizing the zero splat. This is because it is a ConstantAggregateZero which is a ConstantData and not a ConstantDataVector that the function is handling.

I wonder if my patch here is the right approach, or if it might be even better to make a utility function for this type of query to make this mistake less likely in other places? It is surprising to me to have a zero splat not recognized as a ConstantDataVector...


https://reviews.llvm.org/D74263

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/CodeGen/SystemZ/vec-max-min-zerosplat.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74263.243308.patch
Type: text/x-patch
Size: 3239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200208/754931d3/attachment.bin>


More information about the llvm-commits mailing list