Some minor vvp runtime performance tweaks.

This commit is contained in:
Stephen Williams 2015-10-01 12:43:56 -07:00
parent 4338d43cea
commit 466b6464bc
1 changed files with 16 additions and 10 deletions

View File

@ -127,15 +127,16 @@ struct vthread_s {
} }
inline const vvp_vector4_t& peek_vec4(unsigned depth) inline const vvp_vector4_t& peek_vec4(unsigned depth)
{ {
assert(depth < stack_vec4_.size()); unsigned size = stack_vec4_.size();
unsigned use_index = stack_vec4_.size()-1-depth; assert(depth < size);
unsigned use_index = size-1-depth;
return stack_vec4_[use_index]; return stack_vec4_[use_index];
} }
inline vvp_vector4_t& peek_vec4(void) inline vvp_vector4_t& peek_vec4(void)
{ {
assert(! stack_vec4_.empty()); unsigned use_index = stack_vec4_.size();
unsigned use_index = stack_vec4_.size()-1; assert(use_index >= 1);
return stack_vec4_[use_index]; return stack_vec4_[use_index-1];
} }
inline void pop_vec4(unsigned cnt) inline void pop_vec4(unsigned cnt)
{ {
@ -5398,14 +5399,17 @@ bool of_STORE_VEC4(vthread_t thr, vvp_code_t cp)
const int sig_value_size = sig->value_size(); const int sig_value_size = sig->value_size();
vvp_vector4_t&val = thr->peek_vec4(); vvp_vector4_t&val = thr->peek_vec4();
unsigned val_size = val.size();
if (val.size() < (unsigned)wid) { if ((int)val_size < wid) {
cerr << "XXXX Internal error: val.size()=" << val.size() cerr << "XXXX Internal error: val.size()=" << val_size
<< ", expecting >= " << wid << endl; << ", expecting >= " << wid << endl;
} }
assert(val.size() >= (unsigned)wid); assert((int)val_size >= wid);
if (val.size() > (unsigned)wid) if ((int)val_size > wid) {
val.resize(wid); val.resize(wid);
val_size = wid;
}
// If there is a problem loading the index register, flags-4 // If there is a problem loading the index register, flags-4
// will be set to 1, and we know here to skip the actual assignment. // will be set to 1, and we know here to skip the actual assignment.
@ -5429,6 +5433,7 @@ bool of_STORE_VEC4(vthread_t thr, vvp_code_t cp)
int use_off = -off; int use_off = -off;
wid -= use_off; wid -= use_off;
val = val.subvalue(use_off, wid); val = val.subvalue(use_off, wid);
val_size = wid;
off = 0; off = 0;
} }
@ -5438,10 +5443,11 @@ bool of_STORE_VEC4(vthread_t thr, vvp_code_t cp)
wid = sig_value_size - off; wid = sig_value_size - off;
val = val.subvalue(0, wid); val = val.subvalue(0, wid);
val.resize(wid); val.resize(wid);
val_size = wid;
} }
if (off==0 && val.size()==(unsigned)sig_value_size) if (off==0 && val_size==(unsigned)sig_value_size)
vvp_send_vec4(ptr, val, thr->wt_context); vvp_send_vec4(ptr, val, thr->wt_context);
else else
vvp_send_vec4_pv(ptr, val, off, wid, sig_value_size, thr->wt_context); vvp_send_vec4_pv(ptr, val, off, wid, sig_value_size, thr->wt_context);