Summary: | [4.7/4.8 Regression] compilation failure with undefined reference to `__builtin_iround' | ||
---|---|---|---|
Product: | gcc | Reporter: | ojab <ojab> |
Component: | middle-end | Assignee: | Jakub Jelinek <jakub> |
Status: | RESOLVED FIXED | ||
Severity: | critical | Keywords: | link-failure, wrong-code |
Priority: | P3 | ||
Version: | 4.7.0 | ||
Target Milestone: | 4.7.0 | ||
Host: | Target: | x86_64-*-linux-gnu | |
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2012-03-15 00:00:00 | |
Attachments: |
Preprocessed source
Patch which fixes the problem gcc47-pr52592.patch |
Description
ojab
2012-03-15 05:36:11 UTC
What target is this on? Can you attach the preprocessed source for ffv1.c ? Also can you give the exact command is used to compile ffv1.c ? $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.7.0-RC-20120314/configure --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-system-zlib Thread model: posix gcc version 4.7.0 20120314 (prerelease) (GCC) Compilation string: gcc -I. -I./ -DHAVE_AV_CONFIG_H -Wundef -Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -Wdisabled-optimization -Wno-pointer-sign -Wdeclaration-after-statement -std=gnu99 -Werror-implicit-function-declaration -O4 -march=native -mtune=native -pipe -ffast-math -fomit-frame-pointer -fno-tree-vectorize -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -Ilibdvdread4 -I. -Iffmpeg -D_REENTRANT -I/usr/include/freetype2 -MD -MP -c -o libavcodec/ffv1.o libavcodec/ffv1.c Created attachment 26896 [details]
Preprocessed source
Reducing a testcase. Note a simple testcase works correctly. Reduced testcase: int best_state[256][256]; __attribute__((cold)) int encode_init(double p) { return best_state[(int)round(p)][0]; } --- CUT --- (define_expand "lround<X87MODEF:mode><SWI248x:mode>2" [(match_operand:SWI248x 0 "nonimmediate_operand" "") (match_operand:X87MODEF 1 "register_operand" "")] "(TARGET_USE_FANCY_MATH_387 && (!(SSE_FLOAT_MODE_P (<X87MODEF:MODE>mode) && TARGET_SSE_MATH) || TARGET_MIX_SSE_I387) && flag_unsafe_math_optimizations) || (SSE_FLOAT_MODE_P (<X87MODEF:MODE>mode) && TARGET_SSE_MATH && <SWI248x:MODE>mode != HImode && ((<SWI248x:MODE>mode != DImode) || TARGET_64BIT) && !flag_trapping_math && !flag_rounding_math)" { if (optimize_insn_for_size_p ()) FAIL; --- CUT --- Looks like there is a disconnect about when choosing iround over lround. I bet the code that handles the expanding of __builtin_iround (expand_builtin_int_roundingfn_2) should do exactly what the expanding of iceil does (expand_builtin_int_roundingfn). Here is the smallest testcase: __attribute__((cold)) int encode_init(double p) { return (int)__builtin_round(p); } ---- CUT ---- I think I have a patch, just testing it a little bit. Created attachment 26897 [details]
Patch which fixes the problem
I don't have enough time to regress test this patch though.
But here is the ChangeLog for it:
* builtins.c (expand_builtin_int_roundingfn_2): If the expanding of iround optab fails, then expand using lround call.
Created attachment 26898 [details] gcc47-pr52592.patch Fixed up and simplified patch, untested so far. I guess expand_builtin_int_roundingfn (for 4.8 only) could be simplified too, by using mathfn_built_in_1 (, , 0); and dropping the whole if (fallback_fndecl == NULL_TREE) { ... }. Author: jakub Date: Thu Mar 15 13:30:04 2012 New Revision: 185431 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185431 Log: PR middle-end/52592 * builtins.c (expand_builtin_int_roundingfn_2): If expanding BUILT_IN_IR{INT,OUND}* using optab fails, emit lr{int,ound}* calls instead of __builtin_ir{int,ound}*. * gcc.dg/pr52592.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr52592.c Modified: trunk/gcc/ChangeLog trunk/gcc/builtins.c trunk/gcc/testsuite/ChangeLog Author: jakub Date: Thu Mar 15 13:40:13 2012 New Revision: 185432 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185432 Log: PR middle-end/52592 * builtins.c (expand_builtin_int_roundingfn_2): If expanding BUILT_IN_IR{INT,OUND}* using optab fails, emit lr{int,ound}* calls instead of __builtin_ir{int,ound}*. * gcc.dg/pr52592.c: New test. Added: branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/pr52592.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/builtins.c branches/gcc-4_7-branch/gcc/testsuite/ChangeLog Fixed. |