Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ppci-cc: x86 backend fails when converting float/double <=> char/short #84

Open
tstreiff opened this issue Jun 11, 2020 · 1 comment
Open

Comments

@tstreiff
Copy link
Contributor

double d;
short s;
char c;
d = c;
d = s;
c = d;
s = d;
The x86 backend fails to generate any of the 4 above expressions.

It also fails with "unsigned char" and "unsigned short" (but it works for int, unsigned int, long, unsigned long)
It also fails if "double" is replaced by "float"

All these expressions request the backend to implement templates such as:
I8TOF64, I16TOF64, F64TOI8, F64TOI16 which do not exist in current version.

For expressions converting char/short to double, it could be handy to do an implicit integer promotion and then rely to the existing I32TOF64 or U32TOF64 templates.
Same for "float" which could be promoted to double before being converted.

@windelbouwman
Copy link
Owner

This is a fair point. I have given this some thought, and requiring the backend to implement all combinations, might be practical. An idea would be to create extra patterns in the instruction selector to use existing conversions like you suggested. If a backend implements a direct conversion, this would take precedence when it has a lower cost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants