[Bug target/56866] [4.7/4.8/4.9 Regression] with '-O3 -march=bdver2' misscompiles glibc-2.17/crypt/sha512.c

winfried.magerl@t-online.de gcc-bugzilla@gcc.gnu.org
Mon Apr 29 16:08:00 GMT 2013


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

--- Comment #17 from Winfried Magerl <winfried.magerl@t-online.de> 2013-04-29 16:08:09 UTC ---
Hi Jakub,

On Fri, Apr 26, 2013 at 09:00:42AM +0000, jakub at gcc dot gnu.org wrote:
>  
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56866 
>  
> --- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-26 09:00:42 UTC --- 
> Created attachment 29944 
>   --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29944 
> gcc49-pr56866.patch 
>  
> The fix for gcc.c-torture/execute/pr51581* and pr53645.c etc. is quite obvious, 
> we obviously can't use xop_pmacsdqh with unsigned highpart odd multiplication, 
> say for the pr51581-1.c unsigned division by 3U, which is high part 
> multiplication by 0xaaaaaaabU, with the result shifted right by 1 at the end. 
> If we compute say 3ULL * 0xaaaaaaabULL, we can't use xop_pmacsdqh which 
> computes 
> 3LL * 0xffffffffaaaaaaabLL instead. 
>  
> That said, there are no vpmacsdqh insns in the sha512 code for -O3 
> -march=bdver2, so it must be something else. 

I've verified that the problem with the sha512 code build with
'-O3 -mxop' is also fixed. I've attached sha512.s.diff with the
diff of the generated assembler-code (gcc-4_8-branch revision 198317
compared with gcc-4_8-branch revision 198422).

Most lines looks like this:

-       vprotq  $-45, %xmm0, %xmm4
-       vprotq  $-3, %xmm0, %xmm3
+       vprotq  $3, %xmm0, %xmm4
+       vprotq  $45, %xmm0, %xmm3

Many thanks for looking at this issue! I will run the complete
gcc-test-suite to see the difference and later on I will check
glibc-testsuite too.

It might be a good idea to look at the other open bugs tagged
with bdver or xop.

regards

    winfried



More information about the Gcc-bugs mailing list