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

    <tr>
        <th>Summary</th>
        <td>
            Bitwise operation on 64 bit is giving  wrong value  when optimization (instCombine) 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>
    

Testcase:
#include <iostream>
class A {
public:
       int a = 0;
      A () { }
 A* getthis ();
        void chkthis ();
};
 typedef unsigned long pint_t;
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, 0x1);
}
 void A::chkthis ()
{
        std::cout << this << std::endl;
        unsigned long x = ~(0x1);
        std::cout <<  std::hex  << ((unsigned long)this & x) << std::endl;
        return ;
}
 int main ()
{
        A a;
 A* p = a.getthis();
       p->chkthis();         return 0;
}


LLVM : LSB is not reversed.
https://clang.godbolt.org/z/csnE5xn3x

GCC: LSB is reversed.
https://clang.godbolt.org/z/8MYn9x4zv
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVEFv8zYM_TX0hWigSoljH3xw0maXdhuwYcBOg2yztvbJkmHJab4e9tsH2WqapsGHYTk4Cfn4-PhIWDqnWkNUwGYHm4dETr6zY3FUbSX1lFS2-V4AewBWLs_fyflaOgIRA8CFMrWeGkIQe2WdH0n2IB6XdK2lc1gibHdLYJgqrepzOS4fZTxKBPGADMTuMlUi8Ax4HhgQtg8xVwIvsSXvO-Ui4qoQ8WhVg3X37RYmMJ3x_vtADb3gZGYzGtTWtDgo4__yZ5SnftDSE4h9wBvZE_4KfI_nf88gHlEZrcyciRPKpgnNQwAHP4aKZ-yl-xaHetc8kp9G8w4NWoPiLKrg-eBHhO0eL2OR5tNUF_6UwWZRXtkUkVdmxfZRbcAHpex0f5t_9jbyX1l8m9_5JqLt5MOpgNjjUrb8PgPINPrLLj-v5jSfyj_AsyuBP-z2Ee3ohO_RxeZP_MDzOFCKp3lN_0Xi-wK_mhWuu5fK_NihEuUH57y_YR5TruICb5_5cAfiMa7gjMArUeyrqsvn09MfzwiixKffdqgcGutxpCONjprVAum8H1yYnh-AH2otTbtqbVNZ7Vd2bIEf3kLcmcfNyYjTJftP-_0F9__izZ7_NPlp_XZMmkI0uchlQsV9us1YvkkZT7qCKN-KbSrr9EU0db5u7ustsa3Mai5rIpaogjMumGApy9eM8VX-ktZV88Ko4llGtYA1o14qvdL62IfeiXJuoiK952yTaFmRdvNrknNDrzgngfPw1hyLUHNXTa2DNdPKeffB4pXXVOyUf1WO0A40Sq-sQWswXWOlfHClVUdlWsTXMdz3UeqJEF87MmgHr3r1ttQAz5Rxfm_7ShkKp6kc_vJzMo26-Oxkq3w3Vava9sAPQUv8uhtG-zfVHvhhnsABP8wT_hsAAP__bvWw5Q">