<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61206>61206</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Bitwise operation on 64 bit is wrong output when Optimization is ON
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vigbalu
      </td>
    </tr>
</table>

<pre>
    This is similar to https://github.com/llvm/llvm-project/issues/61205

Testcase:
#include <iostream>
 typedef unsigned long pint_t;
template<typename P, typename M> inline M
uSysMaskGet(P* ptr, M mask) {
  return (pint_t)ptr & (pint_t)mask;
}
 class A {
public:
         int a = 0;
 enum maskFlags {
    hasAssFlag = 0x1,
    hasOutFlag = 0x2
 };
        A () { }
        A* getthis ();
        void chkthis ();
                bool          hasOut()          const {
 return thisMsk() & hasOutFlag;}
                int thisMsk()         const {return uSysMaskGet(this, 0x3);}
};
 template<typename P, typename M> inline P*
add (P* ptr, M mask) {
 return (P*)((pint_t)ptr | (pint_t)mask);
}
 A* A::getthis ()
{
 return add (this, 0x2);
}
 void A::chkthis ()
{
        int x = (0x3);
                std::cout <<  hasOut() << std::endl;
 return ;
}
 int main ()
{
        A a;
        A* p = a.getthis();
        p->chkthis();
         return 0;
}

LLVM (output is 0):
https://clang.godbolt.org/z/9Yaeovcz6

GCC (output is 1):
https://clang.godbolt.org/z/ocq6Ydvad
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVUuP2zgM_jXKhWigSPHr4IMnM-ml2SmwxQI9LWRL42hHlryWnHn8-oVkJc6jLXZQH5zYJD9-JD-LzFrZaiFKlNyh5H7BRrc3Q3mQbc3UuKgNfyu_7aUFacHKTio2gDOwd663iFaIbBHZttLtx3rZmA6RrVKH48-nfjD_iMYhspXWjsIisk1XBCcI3yNcTfdvwrqGWeHRpteESt2okQtAdCONdYNgHaIPkxncWy-4eIJRB-oclNEt9FK7vx2id5OXE12vmBOIbry_Zp2Ar4hs4PS0Q_QBpFZS-_8haPzzze6Yff4sHCL5V0Qq6N3go3bQMfuMSAEoixkABuHGQQMieUxOit4NgEh68S5EHnmh7D6GN4pZC9UM2I-1ks2pDXC8pHbAANF7wCcYEHrsAqetYq09ZwWwZ7ay1humqNcVIpsL8-Pozswk2jw3eneZvfKlxLphJn-0-ha1wjmvkMnxBuFgJIdm__wrn-NVG6Pmp4lozH-6GqOtOys4TsHD7_yIJrYkPavT57umft7dy9ibRDHDpTp8jFcGfqWxomOGizZ-TIdeclMg4xz-hwZnCYZQUoQarvSYbW71eDaEuTVhnJVXIK2upho9r_JGlnMvyI-BgwYi8JUUroDPpvIa5IlIPrf4hxO0jkdkMzp_ZCC6uRJPfHnyFJqrGe_YxFvenkbHpP412QrY7XcTBhcqYMvYy5-Iv_-E6EPsys--j0gR33Kc7l--_LXzJM3o-tH5wxoHnGi-PK4bxXS7bA2vjXJLM7SIbN8R2RbfmTCH5j09R_682VwCrz4ObJp_0-_8wPiCl5QXtGALUa7SLMdFkuXrxb7k7CkpcJ7VrGYcJwnP1wnFeZMXucAJSxayJJhQTHGKizXF6yVLG0FXq0IkqyzNnjK0xqJjUi394vG5F2HllH7fpAvFaqFsWHKEaPECwYgI8TtvKMOyqsfWojVW0jo7ozjplCjvpHuRVoDpxcCcNBqMhnQNtQw9eRn8Coo9etkLDY-9k518n3ylhcc_FuOgyt_bm-l_AQAA__-wqSQS">