Bug 1311497 - mesa fails to build on ppc64 with Assembler message: operand out of range (44 is not between 0 and 31)
Summary: mesa fails to build on ppc64 with Assembler message: operand out of range (44...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: ppc64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-24 11:21 UTC by Sinny Kumari
Modified: 2016-02-27 23:06 UTC (History)
10 users (show)

Fixed In Version: gcc-6.0.0-0.13.fc24
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-02-27 23:06:39 UTC
Type: Bug


Attachments (Terms of Use)
asm for file vl_idct.c (1.14 MB, text/plain)
2016-02-24 11:25 UTC, Sinny Kumari
no flags Details
Intermediate compilation results of file vl_idct.c (47.92 KB, application/x-gzip)
2016-02-24 15:28 UTC, Sinny Kumari
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 69946 0 None None None 2016-02-24 18:07:15 UTC

Description Sinny Kumari 2016-02-24 11:21:56 UTC
Compiling latest mesa-11.2.0-0.devel.11.24ea81a with gcc-6.0.0-0.12 fails while building target vl/libgalliumvl_la-vl_idct.lo from source vl/vl_idct.c with error message:
{standard input}: Assembler messages:
{standard input}:3899: Error: operand out of range (44 is not between 0 and 31)
{standard input}:3903: Error: operand out of range (44 is not between 0 and 31)
{standard input}:4309: Error: operand out of range (44 is not between 0 and 31)
{standard input}:4313: Error: operand out of range (44 is not between 0 and 31)

Complete build log is available at http://ppc.koji.fedoraproject.org/kojifiles/work/tasks/5918/3155918/build.log from koji build - http://ppc.koji.fedoraproject.org/koji/buildinfo?buildID=381622

Comment 1 Sinny Kumari 2016-02-24 11:25:19 UTC
Created attachment 1130184 [details]
asm for file vl_idct.c

Error occurs when mesa is built with gcc optimzation -O1 or -O2 enabled.
Builds fine when compiled with -O0.

After digging more, checked Assembler generated code for file vl_idct.c (available in attachement)
and it turns out that assembler code for instruction rlwinm is getting out of range value for 3rd operand
which tells how much left bit shift should be done.
3899: rlwinm 29,8,44,20,23
3903: rlwinm 30,10,44,20,23
4309: rlwinm 28,5,44,20,23
4313: rlwinm 30,12,44,20,23

At source code level, error occurs at line number 133 and 134 of file vl_idct.c
https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/vl/vl_idct.c#n133 which
is defined in function matrix_mul().
matrix_mul() is called by create_stage1_frag_shader() which is called by init_shaders().

Comment 2 Dan Horák 2016-02-24 11:51:34 UTC
Sinny, it is some inline assembler or C code translated to ppc assembler by compiler?

Comment 3 Sinny Kumari 2016-02-24 12:16:18 UTC
(In reply to Dan Horák from comment #2)
> Sinny, it is some inline assembler or C code translated to ppc assembler by
> compiler?

It is C code translated to ppc assembler by gcc.

To be precise, assembler code is generated by running gcc with following options and flags:

$ gcc -DPACKAGE_NAME=\"Mesa\" -DPACKAGE_TARNAME=\"mesa\" -DPACKAGE_VERSION=\"11.2.0-devel\" -DPACKAGE_STRING=\"Mesa\ 11.2.0-devel\" -DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi\?product=Mesa\" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesa\" -DVERSION=\"11.2.0-devel\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE___BUILTIN_BSWAP32=1 -DHAVE___BUILTIN_BSWAP64=1 -DHAVE___BUILTIN_CLZ=1 -DHAVE___BUILTIN_CLZLL=1 -DHAVE___BUILTIN_CTZ=1 -DHAVE___BUILTIN_EXPECT=1 -DHAVE___BUILTIN_FFS=1 -DHAVE___BUILTIN_FFSLL=1 -DHAVE___BUILTIN_POPCOUNT=1 -DHAVE___BUILTIN_POPCOUNTLL=1 -DHAVE___BUILTIN_UNREACHABLE=1 -DHAVE_FUNC_ATTRIBUTE_CONST=1 -DHAVE_FUNC_ATTRIBUTE_FLATTEN=1 -DHAVE_FUNC_ATTRIBUTE_FORMAT=1 -DHAVE_FUNC_ATTRIBUTE_MALLOC=1 -DHAVE_FUNC_ATTRIBUTE_PACKED=1 -DHAVE_FUNC_ATTRIBUTE_PURE=1 -DHAVE_FUNC_ATTRIBUTE_UNUSED=1 -DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT=1 -DHAVE_DLADDR=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_PTHREAD=1 -I.    -I../../../src/loader -I../../../src/gallium/auxiliary/util -I../../../include -I../../../src -I../../../src/gallium/include -I../../../src/gallium/auxiliary -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D_GNU_SOURCE -DNDEBUG -DTEXTURE_FLOAT_ENABLED -DHAVE_XLOCALE_H -DHAVE_SYS_SYSCTL_H -DHAVE_STRTOF -DHAVE_MKOSTEMP -DHAVE_DLOPEN -DHAVE_POSIX_MEMALIGN -DMESA_SELINUX -DHAVE_LIBDRM -DGLX_USE_DRM -DHAVE_LIBUDEV -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_TLS -DHAVE_ALIAS -DHAVE_DRI3 -DHAVE_MINCORE -DHAVE_LLVM=0x0308 -DMESA_LLVM_VERSION_PATCH=0 -fvisibility=hidden -Werror=pointer-arith -Werror=vla -Werror=declaration-after-statement -I/usr/include  -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS   -I/usr/include/libdrm -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -Wall -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-strict-aliasing -fno-math-errno -fno-trapping-math -fno-builtin-memcmp  -S -o vl/libgalliumvl_la-vl_idct.S `test -f 'vl/vl_idct.c' || echo './'`vl/vl_idct.c

I took all default options/flags used during build. Only modification was changing -c to -S and target filename to vl/libgalliumvl_la-vl_idct.S

Comment 4 Dan Horák 2016-02-24 12:26:57 UTC
ok, switching to gcc then

Can you reproduce the issue when removing all functions from vl_idct.c expect the matrix_mul()?

Also please attach preprocessed vl_idct.c (gcc -E), ideally reduced as much as possible, but still reproducing the issue.

Comment 5 Sinny Kumari 2016-02-24 15:28:23 UTC
Created attachment 1130245 [details]
Intermediate compilation results of file vl_idct.c

Removed all functions which doesn't participate in build error. Attachment contains modified vl_idct.c file I used along with intermediate files generated during compilation by gcc.

Comment 6 Jakub Jelinek 2016-02-24 18:07:16 UTC
Tracking this upstream in PR69946.

Comment 7 Sinny Kumari 2016-02-25 06:21:01 UTC
I forgot to mention that, failure occurs only on ppc64 BE not not ppc64 LE.
Successful scratch build of mesa-11.2.0-0.devel.11.24ea81a is available at http://ppc.koji.fedoraproject.org/koji/taskinfo?taskID=3168596

Comment 8 Peter Robinson 2016-02-27 23:06:39 UTC
Confirmed gcc-6.0.0-0.13.fc24 enables mesa to be built on Power platforms


Note You need to log in before you can comment on or make changes to this bug.