This is the mail archive of the
mailing list for the GCC project.
Re: abs insn with QI and HI mode
Thanks very much for your email. Will gcc add the optimization support
in the future (method 1)? For method 2, if abs accept short/char, may
I give the function names as sabs and qabs? Gcc does already have cabs
as complex abs, doesn't it?
Quoting Jim Wilson <firstname.lastname@example.org>:
Ying Yi wrote:
The generated codes do the following operations: 1) extend variable
a_HI (HImode) to temp variable SImode, and do abs operation with
SImode operators. I find the gimple intermedia represention as
abs is a standard library function that takes an int as an argument.
So if you call abs(), then gcc must convert the argument to type int
before generating code for the abs.
To get your special char/short abs instructions, we need one of two things
1) Optimization support to recognize a sign-extend followed by an abs,
where the target has an abs instruction that operates on the
pre-extended value. We can then optimize away the sign extend
instruction. This optimization support apparently does not exist at
the moment, perhaps because no one has needed it before.
2) Alternative abs function calls that accept short/char. We already
have abs (int), labs (long), llabs(long long), fabs (double), fabsf
(float) and fabsl (long double).
Jim Wilson, GNU Tools Support, http://www.specifix.com