First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 23422
Product:  
Component:  
Status: RESOLVED
Resolution: INVALID
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Anton Blanchard <anton@samba.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 23422 depends on: Show dependency tree
Show dependency graph
Bug 23422 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2005-08-16 14:03
When using the recent debian 4.0 build (gcc version 4.0.2 20050806 (prerelease)
(Debian 4.0.1-4)) I had some problems with a 64bit kernel.

A cut down test case is:

#define BUG_ON(x) asm volatile("tdnei %0,0" : : "r" (x));

static inline int bar(int val)
{
        return val + 1;
}

int foo;

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

gcc 3.4 sign extends before passing it to the inline assembly:

.baz:
        ld 11,.LC0@toc(2)
        lwa 9,0(11)
        addi 9,9,1
        extsw 9,9
        tdnei 9,0

But gcc 4.0 has removed the sign extension:

.baz:
        ld 11,.LC0@toc(2)
        lwz 9,0(11)
        addi 9,9,1
        tdnei 9,0

gcc 4.0 does get it right with -fno-inline.

------- Comment #1 From Andrew Pinski 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.  

------- Comment #2 From Anton Blanchard 2005-08-17 01:04 -------
Thanks, after applying the suggested fix the kernel works.

First Last Prev Next    No search results available      Search page      Enter new bug