Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:21:15+00:00 2026-06-14T07:21:15+00:00

My colleague showed me the following macro from the LLVM source code : #define

  • 0

My colleague showed me the following macro from the LLVM source code:

#define IMPLEMENT_UNORDERED(TY, X,Y)                                         \
    if (TY->isFloatTy()) {                                                   \
        if (X.FloatVal != X.FloatVal || Y.FloatVal != Y.FloatVal) {          \
            return Dest;                                                     \
        }                                                                    \
    } else if (X.DoubleVal != X.DoubleVal || Y.DoubleVal != Y.DoubleVal) {   \
            Dest.IntVal = APInt(1,true);                                     \
            return Dest;                                                     \
}

Here’s how they use this macro:

static GenericValue executeFCMP_UEQ(GenericValue Src1, GenericValue Src2,
                                    Type *Ty) {
    GenericValue Dest;
    IMPLEMENT_UNORDERED(Ty, Src1, Src2)
    return executeFCMP_OEQ(Src1, Src2, Ty);
}

Below you can see the definition of GenericValue:

struct GenericValue {
    union {
        double          DoubleVal;
        float           FloatVal;
        PointerTy       PointerVal;
        struct { unsigned int first; unsigned int second; } UIntPairVal;
        unsigned char   Untyped[8];
    };
    APInt IntVal;   // also used for long doubles

    GenericValue() : DoubleVal(0.0), IntVal(1,0) {}
    explicit GenericValue(void *V) : PointerVal(V), IntVal(1,0) { }
};

My question is why there’s the following inequality test inside the macro:

X.FloatVal != X.FloatVal
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:21:16+00:00Added an answer on June 14, 2026 at 7:21 am

    I’d guess they test for NaN (not a number): if x has a NaN value, x != x yields true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yesterday a colleague showed me the following postgres query. We were both surprised that
A colleague has passed me an interesting code sample that crashes with an InvalidProgramException
My colleague's code looked like this: void copy(std::string const& s, char *d) { for(int
A colleague committed (C1) a bunch of new code to github, and I made
A colleague just told me that this code: std::ifstream stream(filename.c_str()); if (!stream) { throw
A colleague just showed me this and I was surprised that it compiled at
A colleague of mine wrote quite questionable piece of code some time ago, and
My colleague insists on explicitly specifying the namespace in code as opposed to using
A colleague of mine wants to use my python 2 code on his OS
A colleague of mine has a problem with a sql query:- Take the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.