[PATCH] D138180: InstCombine: Fold negations of is_fpclass intrinsics

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 18 02:50:13 PST 2022


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

LGTM.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3715-3717
+      II->setArgOperand(
+          1, ConstantInt::get(ClassMask->getType(),
+                              ~ClassMask->getZExtValue() & fcAllFlags));
----------------
arsenm wrote:
> sepavloff wrote:
> > It must work for IEEE numbers. But for non-IEEE it is possible that a value does not belong to any of the classes known to `is_fpclass`. For example, type `x86_fp80` has so-called unsupported values. Do you think this transformation can be safely applied to such numbers also or it is better to limit it to IEEE numbers only?
> I don't know anything about x87. How is the intrinsic lowered for it?
> 
> Is it just these "pseudo-X" cases? I'd assume those are covered by the non-pseudo tests?
Yes, these are pseudo numbers. They are mapped to IEEE classes in more complex way, for example glibc recognizes pseudo-infinity as a NaN, and pseudo-denormals as normals.

Nevertheless any such number is mapped to one of IEEE classes and this optimization must work no matter how the mapping is realized.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138180/new/

https://reviews.llvm.org/D138180



More information about the llvm-commits mailing list