From 6340159160dfbbc0ff7b82cf76a4a0f31be94af8 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Wed, 29 Apr 2015 11:12:17 +0000 Subject: [PATCH] gcc/ * loop-iv.c (canon_condition): Generalize to all types of integer constant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222571 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/loop-iv.c | 41 ++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad13f84e2dc..baa558ba317 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-04-29 Richard Sandiford + + * loop-iv.c (canon_condition): Generalize to all types of integer + constant. + 2015-04-29 Bernhard Reuther-Fischer * gimple-walk.c: Prune duplicate or unneeded includes. diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index 36a9a9f616e..d2cd66e1928 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -1729,39 +1729,42 @@ canon_condition (rtx cond) mode = GET_MODE (op1); gcc_assert (mode != VOIDmode); - if (CONST_INT_P (op1) - && GET_MODE_CLASS (mode) != MODE_CC - && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) + if (CONST_SCALAR_INT_P (op1) && GET_MODE_CLASS (mode) != MODE_CC) { - HOST_WIDE_INT const_val = INTVAL (op1); - unsigned HOST_WIDE_INT uconst_val = const_val; - unsigned HOST_WIDE_INT max_val - = (unsigned HOST_WIDE_INT) GET_MODE_MASK (mode); + rtx_mode_t const_val (op1, mode); switch (code) { case LE: - if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1) - code = LT, op1 = gen_int_mode (const_val + 1, GET_MODE (op0)); + if (wi::ne_p (const_val, wi::max_value (mode, SIGNED))) + { + code = LT; + op1 = immed_wide_int_const (wi::add (const_val, 1), mode); + } break; - /* When cross-compiling, const_val might be sign-extended from - BITS_PER_WORD to HOST_BITS_PER_WIDE_INT */ case GE: - if ((HOST_WIDE_INT) (const_val & max_val) - != (((HOST_WIDE_INT) 1 - << (GET_MODE_BITSIZE (GET_MODE (op0)) - 1)))) - code = GT, op1 = gen_int_mode (const_val - 1, mode); + if (wi::ne_p (const_val, wi::min_value (mode, SIGNED))) + { + code = GT; + op1 = immed_wide_int_const (wi::sub (const_val, 1), mode); + } break; case LEU: - if (uconst_val < max_val) - code = LTU, op1 = gen_int_mode (uconst_val + 1, mode); + if (wi::ne_p (const_val, -1)) + { + code = LTU; + op1 = immed_wide_int_const (wi::add (const_val, 1), mode); + } break; case GEU: - if (uconst_val != 0) - code = GTU, op1 = gen_int_mode (uconst_val - 1, mode); + if (wi::ne_p (const_val, 0)) + { + code = GTU; + op1 = immed_wide_int_const (wi::sub (const_val, 1), mode); + } break; default: -- 2.11.4.GIT