Re: extended asm - memory constraint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"=&m" (res)  fails to compile with the following error:

[...] error: ‘&’ constraint used with no register class

The short code below highlights the problem. Instead of 10, the output is a
random value (I compiled it with
g++ -o tst -O3 -Wall -march=native -mtune=native tst.C). If you add "memory"
to the clobber list, you get correct output.


#include <iostream>

using namespace std;

struct int128 {

  unsigned long long int lo;
  unsigned long long int hi;

} __attribute__ ((aligned(16))) ;


int128 testFN(unsigned long long a) {
  unsigned long long alo = (unsigned int) a;
  unsigned long long ahi = (a >> 32);
  int128 res;
  asm __volatile__ (
    // compute basic products (alo * alo, ahi * ahi, 2 * alo * ahi) 
    "movq      (%0)  , %%xmm7 \n\t"   // xmm7 = (alo, 0)
    "movhpd    (%1)  , %%xmm7 \n\t"   // xmm7 = (alo, ahi)
    "movdqa  %%xmm7  , (%2)   \n\t"   // res.lo = alo, res.hi = ahi
    : //"=&m" (res)
    : "rV" (&alo), "rV" (&ahi), "rV" (&res)
    : "%xmm7" //, "memory"
  );
  return  res;
}


int main() {

  int128 res;
  res.lo = 1;
  res.hi = 2;

  cout << testFN(testFN(10).lo).lo << '\n';

  return 0;
}

-- 
View this message in context: http://old.nabble.com/extended-asm---memory-constraint-tp28725485p28749465.html
Sent from the gcc - Help mailing list archive at Nabble.com.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux