[qfcc] Improve offset_cast's zero detection

I'd caught 0 single components, but I'd missed 0 vector components. This
shaves 4 instructions off the motor-point test.
This commit is contained in:
Bill Currie 2023-09-18 21:43:23 +09:00
parent 068f685fde
commit ca01ab2a27

View file

@ -167,7 +167,13 @@ offset_cast (type_t *type, expr_t *expr, int offset)
if (type_width (get_type (ext.src)) == type_width (type)) {
return alias_expr (type, ext.src, 0);
}
if (offset >= type_width (get_type (ext.src))) {
bool rev = ext.reverse;
int cwidth = type_width (type);
int dwidth = type_width (ext.type);
int swidth = type_width (get_type (ext.src));
if ((!rev && offset >= swidth)
|| (rev && offset + cwidth <= dwidth - swidth)) {
return 0;
}
}