This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/23422] Sign extension removed even when inline assembly uses variable


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-16 14:16 -------
This is not a bug.
The code you gave is equivalant to as that is what inlining does (3.4 had a bug in that it had an extra 
overhead as you noticed, which you thought was a feature):
#define BUG_ON(x) asm volatile("tdnei %0,0" : : "r" (x));
int foo;
void baz()
{
        BUG_ON(foo+1);
}

So it will pick the SImode (32bit part) for the "r" selector.  If you want the BUG_ON to take a signed 
extended (DImode) for the "r", use something like the following:
#define BUG_ON(x) asm volatile("tdnei %0,0" : : "r" ((long long)x));
static inline int bar(int val)
{
        return val + 1;
}

int foo;

void baz()
{
        BUG_ON(bar(foo));
}


That will both work on 3.4 and 4.0.0 with no asm changes in both.  

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23422


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]