Bug 271438 - sse4-64.c does not compile on at least 2 distrib (debian 4.3.2 and rh 5.2)
Summary: sse4-64.c does not compile on at least 2 distrib (debian 4.3.2 and rh 5.2)
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.7 SVN
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 17:54 UTC by Philippe Waroquiers
Modified: 2012-01-17 13:22 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Waroquiers 2011-04-21 17:54:59 UTC
Compilation problem of sse4-64.c
(note : this is not very recent, I have seen this 
at least some weeks ago but forgot to report it).

gcc version 4.3.2 (Debian 4.3.2-1.1) 
GNU assembler (GNU Binutils for Debian) 2.18.0.20080103

It also happens on a red-hat 5.2 (gcc 4.1.2,
as 2.17.50.0.6-9.el5 20061020)


gcc -DHAVE_CONFIG_H -I. -I../../..  -I../../.. -I../../../include -I../../../coregrind -I../../../include -I../../../VEX/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1  -Winline -Wall -Wshadow -g -m64 -Wno-long-long  -Wno-pointer-sign -fno-stack-protector -MT sse4-64.o -MD -MP -MF .deps/sse4-64.Tpo -c -o sse4-64.o sse4-64.c
sse4-64.c: Assembler messages:
sse4-64.c:3582: Error: suffix or operands invalid for `pblendvb'
sse4-64.c:3593: Error: suffix or operands invalid for `pblendvb'
sse4-64.c:3649: Error: suffix or operands invalid for `blendvpd'
sse4-64.c:3660: Error: suffix or operands invalid for `blendvpd'
sse4-64.c:3716: Error: suffix or operands invalid for `blendvps'
sse4-64.c:3727: Error: suffix or operands invalid for `blendvps'
make[5]: *** [sse4-64.o] Error 1
Comment 1 Julian Seward 2011-10-12 10:14:54 UTC
Hmm, isn't there a check in configure.in for whether the assembler
can handle these instructions?  If not, there should be.
Comment 2 Philippe Waroquiers 2011-10-12 20:45:07 UTC
(In reply to comment #1)
> Hmm, isn't there a check in configure.in for whether the assembler
> can handle these instructions?  If not, there should be.
I have a close to zero knowledge of all this but from what I understood:

sse4-64 is conditionalized in Makefile.am by BUILD_SSE42_TESTS,
which is true if the below compiles:
   __asm__ __volatile__(
      "crc32q %%r15,%%r15" : : : "r15" );

It looks like the assembler understands the sse4.2 (checked with the above)
but still the assembler cannot assemble all sse4.2 instructions.

Adding more instructions in the above test might be sufficient.

If this is the correct approach, I can work on a patch, and validate it
on a "working" and "non-working" amd64 distribution.
Comment 3 Julian Seward 2011-10-12 22:34:01 UTC
> If this is the correct approach, I can work on a patch, and validate it
> on a "working" and "non-working" amd64 distribution.

Hmm, looking at this more closely ..

> sse4-64.c:3593: Error: suffix or operands invalid for `pblendvb'

It doesn't say "I don't know what a plendvb instruction is".  It sounds
more as if it has a problem with the operands or suffix (whatever that means).

Can you figure out what exact instruction (+ operands) it is
complaining about?  Maybe we can guess what the problem is once
we know that.
Comment 4 Florian Krohm 2012-01-08 18:12:10 UTC
(In reply to comment #3)
> > If this is the correct approach, I can work on a patch, and validate it
> > on a "working" and "non-working" amd64 distribution.
> 
> Hmm, looking at this more closely ..
> 
> > sse4-64.c:3593: Error: suffix or operands invalid for `pblendvb'
> 
> It doesn't say "I don't know what a plendvb instruction is".  It sounds
> more as if it has a problem with the operands or suffix (whatever that means).
> 
> Can you figure out what exact instruction (+ operands) it is
> complaining about?  Maybe we can guess what the problem is once
> we know that.

gcc -c -m64 sse4-64.c
/tmp/ccL6nisD.s: Assembler messages:
/tmp/ccL6nisD.s:100068: Error: suffix or operands invalid for `pblendvb'
/tmp/ccL6nisD.s:100081: Error: suffix or operands invalid for `pblendvb'
/tmp/ccL6nisD.s:100231: Error: suffix or operands invalid for `blendvpd'
/tmp/ccL6nisD.s:100244: Error: suffix or operands invalid for `blendvpd'
/tmp/ccL6nisD.s:100392: Error: suffix or operands invalid for `blendvps'
/tmp/ccL6nisD.s:100405: Error: suffix or operands invalid for `blendvps'

grepping for the insns shows:

	pblendvb (%rcx), %xmm11
	pblendvb %xmm2, %xmm11
	blendvpd (%rcx), %xmm11
	blendvpd %xmm2, %xmm11
	blendvps (%rcx), %xmm11
	blendvps %xmm2, %xmm11

Does that look correct?

gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)
GNU assembler 2.17.50.0.6-6.el5 20061020
Comment 5 philippe.waroquiers 2012-01-13 07:06:25 UTC
(In reply to comment #4)
> (In reply to comment #3)
> grepping for the insns shows:
> 
>     pblendvb (%rcx), %xmm11
>     pblendvb %xmm2, %xmm11
>     blendvpd (%rcx), %xmm11
>     blendvpd %xmm2, %xmm11
>     blendvps (%rcx), %xmm11
>     blendvps %xmm2, %xmm11
> 
> Does that look correct?
> 
> gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)
> GNU assembler 2.17.50.0.6-6.el5 20061020

Some months ago, I spend some (little) time to find the syntax of pblendvb and similar
but could not find an authoritative answer.
As it compiles on some distributions and not on others, I suppose we are encountering
a bug in some old versions of gcc and/or gas.

Philippe
Comment 6 Florian Krohm 2012-01-14 17:02:41 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > grepping for the insns shows:
> > 
> >     pblendvb (%rcx), %xmm11
> >     pblendvb %xmm2, %xmm11
> >     blendvpd (%rcx), %xmm11
> >     blendvpd %xmm2, %xmm11
> >     blendvps (%rcx), %xmm11
> >     blendvps %xmm2, %xmm11
> > 
> > Does that look correct?
> > 
> > gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)
> > GNU assembler 2.17.50.0.6-6.el5 20061020
> 
> Some months ago, I spend some (little) time to find the syntax of pblendvb and
> similar
> but could not find an authoritative answer.
> As it compiles on some distributions and not on others, I suppose we are
> encountering
> a bug in some old versions of gcc and/or gas.
> 

Yes, must be. This patch can be used to distinguish:

Index: configure.in
===================================================================
--- configure.in	(revision 12325)
+++ configure.in	(working copy)
@@ -1551,7 +1551,9 @@
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
   do { long long int x; 
    __asm__ __volatile__(
-      "crc32q %%r15,%%r15" : : : "r15" ); }
+      "crc32q %%r15,%%r15" : : : "r15" );
+   __asm__ __volatile__(
+      "pblendvb (%rcx), %xmm11"); }
   while (0)
 ]])], [
 ac_have_as_sse42=yes

Without the patch, we would try to compile sse4-64.c on a system with
  gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)
  GNU assembler 2.17.50.0.6-6.el5 20061020
which will fail with the error as shown in comment #4.
With the patch SSE4.2 is detected as not supported by gcc/as.

I've also tested the patch on a box with these tools
  gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
  GNU assembler (GNU Binutils for Ubuntu) 2.21.0.20110327
which compile sse4-64.c. With and without the patch SSE4.2 is detected as "supported".

Anybody has objections to applying the patch?
Comment 7 Philippe Waroquiers 2012-01-16 20:46:39 UTC
(In reply to comment #6)
> Anybody has objections to applying the patch?
Without your patch, regtest fail to compile on debian5.
With your patch, it is ok.

So, looks ok to me.

Thanks
Comment 8 Florian Krohm 2012-01-17 13:22:07 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > Anybody has objections to applying the patch?
> Without your patch, regtest fail to compile on debian5.
> With your patch, it is ok.
> 
> So, looks ok to me.
> 

Thanks for testing. Patch applied in r12340.