public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xinliangli at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/50182] Performance degradation from gcc 4.1 (x86_64)
Date: Mon, 24 Oct 2011 23:00:00 -0000 [thread overview]
Message-ID: <bug-50182-4-qGHy8nJSYG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50182-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50182
--- Comment #24 from davidxl <xinliangli at gmail dot com> 2011-10-24 23:00:22 UTC ---
(In reply to comment #23)
> Here is the source preprocessed for gcc47. The test exhibits the
> slowdown mentioned in comment 11.
The problem can be reproduced with a simplified test case -- basically
depending on how the result value from the inner loop is used in the outer loop
(related to casting), the inner loop code is quite different - in the slow
case, there are two redundant sign extension and a move instructions generated.
# the fast version
gcc -O3 -DFAST_VER bug.cpp
./a.out
rv=4282167296
test description absolute operations ratio with
number time per second test0
0 "int8_t constant add" 1.05 sec 1523.81 M 1.00
Total absolute time for int8_t constant folding: 1.05 sec
# the slow version:
gcc -O3 bug.cpp
./a.out
rv=4282167296
test description absolute operations ratio with
number time per second test0
0 "int8_t constant add" 1.57 sec 1019.11 M 1.00
Total absolute time for int8_t constant folding: 1.57 sec
# however, when disabling inlining of check_shifted_sum_1 in the slow case, the
runtime is recovered:
gcc -O3 -DNOINLINE bug.cpp
./a.out
rv=4282167296
test description absolute operations ratio with
number time per second test0
0 "int8_t constant add" 1.05 sec 1523.81 M 1.00
Total absolute time for int8_t constant folding: 1.05 sec
The inner loop body in faster case:
.L60:
movzbl 0(%rbp,%rcx), %r9d
addq $1, %rcx
cmpl %ecx, %ebx
leal 10(%r8,%r9), %r8d
# SUCC: 4 [91.0%] (dfs_back,can_fallthru) 5 [9.0%]
(fallthru,can_fallthru,loop_exit)
jg .L60
while for the slow case:
.L60:
movzbl (%r12,%rcx), %eax
movsbl %r8b, %r8d
addq $1, %rcx
leal 10(%rax), %r9d
movsbl %r9b, %r9d
addl %r8d, %r9d
cmpl %ecx, %ebp
movl %r9d, %r8d
# SUCC: 4 [91.0%] (dfs_back,can_fallthru) 5 [9.0%]
(fallthru,can_fallthru,loop_exit)
jg .L60
The relevant source change:
#ifdef NOINLINE
#define INL __attribute__((noinline))
#else
#define INL inline
#endif
template <typename T, typename T2, typename Shifter>
INL void check_shifted_sum_1(T2 result) {
T temp = (T)SIZE * Shifter::do_shift((T)init_value);
if (!tolerance_equal<T>((T&)result,temp))
printf("test %i failed\n", current_test);
}
#ifdef FAST_VER
#define TYPE u_int32_t
#else
#define TYPE int8_t
#endif
template <typename T, typename Shifter>
__attribute__((noinline)) u_int32_t test_constant(T* first, int count, const
char *label)
{
int i;
u_int32_t rv = 0;
start_timer();
for (i = 0; i < iterations; ++i) {
T result = 0;
for (int n = 0; n < count; ++n) {
result += Shifter::do_shift( first[n] );
}
rv += result;
check_shifted_sum_1<T, TYPE, Shifter>(result);
}
record_result( timer(), label );
return rv;
}
next prev parent reply other threads:[~2011-10-24 23:00 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-24 21:27 [Bug c++/50182] New: " oleg.smolsky at gmail dot com
2011-08-24 22:30 ` [Bug target/50182] " oleg.smolsky at gmail dot com
2011-08-25 0:14 ` xinliangli at gmail dot com
2011-08-25 0:52 ` xinliangli at gmail dot com
2011-08-25 9:00 ` jakub at gcc dot gnu.org
2011-08-25 15:21 ` oleg.smolsky at gmail dot com
2011-08-25 15:29 ` oleg.smolsky at gmail dot com
2011-08-25 16:18 ` hjl.tools at gmail dot com
2011-08-25 16:26 ` xinliangli at gmail dot com
2011-08-25 16:49 ` oleg.smolsky at gmail dot com
2011-08-25 22:48 ` oleg.smolsky at gmail dot com
2011-08-26 7:12 ` oleg.smolsky at gmail dot com
2011-08-30 20:37 ` matt at use dot net
2011-09-15 16:57 ` oleg at smolsky dot net
2011-09-15 17:39 ` xinliangli at gmail dot com
2011-10-21 23:02 ` xinliangli at gmail dot com
2011-10-24 18:28 ` oleg at smolsky dot net
2011-10-24 18:28 ` oleg at smolsky dot net
2011-10-24 18:33 ` oleg at smolsky dot net
2011-10-24 19:34 ` xinliangli at gmail dot com
2011-10-24 19:50 ` oleg at smolsky dot net
2011-10-24 19:59 ` xinliangli at gmail dot com
2011-10-24 21:12 ` oleg at smolsky dot net
2011-10-24 23:00 ` xinliangli at gmail dot com [this message]
2011-10-24 23:03 ` xinliangli at gmail dot com
2012-01-10 18:07 ` oleg at smolsky dot net
2012-01-11 9:43 ` rguenth at gcc dot gnu.org
2012-01-11 17:27 ` xinliangli at gmail dot com
2012-03-02 0:56 ` oleg at smolsky dot net
2012-03-02 8:08 ` jakub at gcc dot gnu.org
2012-03-02 8:23 ` oleg at smolsky dot net
2012-03-02 8:29 ` jakub at gcc dot gnu.org
2012-03-02 9:14 ` jakub at gcc dot gnu.org
2012-03-03 2:20 ` oleg at smolsky dot net
2012-03-03 2:47 ` oleg at smolsky dot net
2012-03-03 3:00 ` oleg at smolsky dot net
2012-03-06 16:34 ` oleg at smolsky dot net
2012-03-06 17:27 ` jakub at gcc dot gnu.org
2012-03-06 19:40 ` oleg at smolsky dot net
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-50182-4-qGHy8nJSYG@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).