commit 102b86a782297c725c4796c4dd36d33fdf024ee7
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date: Thu Mar 23 10:50:32 2017 +0000
PR target/79871: Clean up lane/constant bounds checking errors for translation
@@ -12186,13 +12186,16 @@ neon_expand_vector_init (rtx target, rtx vals)
emit_move_insn (target, mem);
}
-/* Ensure OPERAND lies between LOW (inclusive) and HIGH (exclusive). Raise
- ERR if it doesn't. EXP indicates the source location, which includes the
- inlining history for intrinsics. */
+/* Bounds-check lanes.
+ Ensure OPERAND lies between LOW (inclusive) and HIGH (exclusive). Emit an
+ an error if it doesn't. EXP indicates the source location, which includes
+ the inlining history for intrinsics.
+ We don't unify this and arm_const_bounds because the error string needs to
+ explicity contain "constant" or "lane" for translation purposes. */
-static void
-bounds_check (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high,
- const_tree exp, const char *desc)
+void
+neon_lane_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high,
+ const_tree exp)
{
HOST_WIDE_INT lane;
@@ -12200,31 +12203,34 @@ bounds_check (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high,
lane = INTVAL (operand);
- if (lane < low || lane >= high)
+ if (!IN_RANGE (lane, low, high - 1))
{
if (exp)
- error ("%K%s %wd out of range %wd - %wd",
- exp, desc, lane, low, high - 1);
+ error ("%Klane %wd out of range %wd - %wd",
+ exp, lane, low, high - 1);
else
- error ("%s %wd out of range %wd - %wd", desc, lane, low, high - 1);
+ error ("lane %wd out of range %wd - %wd",
+ lane, low, high - 1);
}
}
-/* Bounds-check lanes. */
+/* Bounds-check constants.
+ Ensure OPERAND lies between LOW (inclusive) and HIGH (exclusive). Emit an
+ an error if it doesn't. See neon_lane_bounds comment for
+ translation comment. */
void
-neon_lane_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high,
- const_tree exp)
+arm_const_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high)
{
- bounds_check (operand, low, high, exp, "lane");
-}
+ HOST_WIDE_INT constant;
-/* Bounds-check constants. */
+ gcc_assert (CONST_INT_P (operand));
-void
-arm_const_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high)
-{
- bounds_check (operand, low, high, NULL_TREE, "constant");
+ constant = INTVAL (operand);
+
+ if (!IN_RANGE (constant, low, high - 1))
+ error ("constant %wd out of range %wd - %wd",
+ constant, low, high - 1);
}
HOST_WIDE_INT