On Tue, 22 May 2018, Kugan Vivekanandarajah wrote:
Hi,
I am looking to introduce ABSU_EXPR and that would create:
unsigned short res = ABSU_EXPR (short);
Note that the argument is signed and result is unsigned. As per the
review, I have a match.pd entry to generate this as:
(simplify (abs (convert @0))
(if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)))
(convert (absu @0))))
Not sure, but we may want a few more restrictions on this transformation.
Now when gimplifying the converted tree, how do we tell that ABSU_EXPR
will take a signed arg and return unsigned. I will have other match.pd
entries so this will be generated while in gimple.passes too. Should I
add new functions in gimple.[h|c] for this.
Is there any examples I can refer to. Conversion expressions seems to
be the only place where sign can change in gimple assignment but they
are very specific.
You'll probably want to patch genmatch.c (near get_operand_type maybe?) so
it doesn't try to guess that the type of absu is the same as its argument.
You can also specify a type in transformations, look for :utype or :etype
in match.pd.
--
Marc Glisse