Commit Message

FWIW this is the last change I had planned. I thought it would be easier
to do once the host_integerp replacement was in mainline, but that means
it's a bit closer to the deadline than it should have been.
The branch adds two new functions, cst_fits_uhwi_p and cst_fits_shwi_p,
alongside the tree_fits_* variants. AFAICT, all cst_fits_uhwi_p tests
replace trunk tests of the form:
TREE_CODE (x) == INTEGER_CST && TREE_INT_CST_HIGH (x) == 0
But this is the same as host_integerp (x, 1), now tree_fits_uhwi_p,
so I think we should just use that instead. FWIW host_integerp was:
int
host_integerp (const_tree t, int pos)
{
if (t == NULL_TREE)
return 0;
return (TREE_CODE (t) == INTEGER_CST
&& ((TREE_INT_CST_HIGH (t) == 0
&& (HOST_WIDE_INT) TREE_INT_CST_LOW (t) >= 0)
|| (! pos && TREE_INT_CST_HIGH (t) == -1
&& (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0
&& !TYPE_UNSIGNED (TREE_TYPE (t)))
|| (pos && TREE_INT_CST_HIGH (t) == 0)));
}
which if you fold in "pos = 1" reduces to current trunk's:
bool
tree_fits_uhwi_p (const_tree t)
{
return (t != NULL_TREE
&& TREE_CODE (t) == INTEGER_CST
&& TREE_INT_CST_HIGH (t) == 0);
}
cst_fits_shwi_p replaces cst_and_fits_in_hwi, but if cst_fits_uhwi_p
goes away then I think we might as well stick with the original name.
(We're already keeping the associated extraction function, int_cst_value.)
I did a bit of wide-intification of write_integer_cst, which showed
up a missing conversion in the abs routine (my fault).
Tested on x86_64-linux-gnu. OK for wide-int?
Thanks,
Richard

Comments

On Nov 20, 2013, at 7:31 AM, Richard Sandiford <rsandifo@linux.vnet.ibm.com> wrote:
> cst_fits_shwi_p replaces cst_and_fits_in_hwi, but if cst_fits_uhwi_p> goes away then I think we might as well stick with the original name.
So the entire patch seems fine, except for one hunk I'll punt to Kenny to weigh in and those are the changes of the form:
- if (!cst_fits_shwi_p (tdiff))
+ if (!cst_and_fits_in_hwi (tiff))