]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/range.cc
RISC-V: Add testcase for pr114734
[thirdparty/gcc.git] / gcc / range.cc
CommitLineData
38a73435 1/* Misc range functions.
a945c346 2 Copyright (C) 2017-2024 Free Software Foundation, Inc.
38a73435
AH
3 Contributed by Aldy Hernandez <aldyh@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#include "config.h"
22#include "system.h"
23#include "coretypes.h"
24#include "backend.h"
25#include "tree.h"
26#include "gimple.h"
27#include "gimple-pretty-print.h"
28#include "fold-const.h"
29#include "ssa.h"
30#include "range.h"
31
028d81b1 32value_range
38a73435
AH
33range_positives (tree type)
34{
35 unsigned prec = TYPE_PRECISION (type);
36 signop sign = TYPE_SIGN (type);
028d81b1 37 return value_range (type, wi::zero (prec), wi::max_value (prec, sign));
38a73435
AH
38}
39
028d81b1 40value_range
38a73435
AH
41range_negatives (tree type)
42{
43 unsigned prec = TYPE_PRECISION (type);
44 signop sign = TYPE_SIGN (type);
028d81b1 45 value_range r;
38a73435
AH
46 if (sign == UNSIGNED)
47 r.set_undefined ();
48 else
028d81b1 49 r = value_range (type, wi::min_value (prec, sign), wi::minus_one (prec));
38a73435
AH
50 return r;
51}