diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2020-05-08 13:36:32 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2020-05-17 13:46:32 +0200 |
commit | 8bfc81876f9325891a52d036a9c454d0c81b3033 (patch) | |
tree | 74a757aa0d3cd6309354971ef8455858b1f2019b /gcc/vr-values.c | |
parent | 5b461bdb48956a89dd589abb96e540c0afcc3fee (diff) | |
download | gcc-8bfc81876f9325891a52d036a9c454d0c81b3033.zip gcc-8bfc81876f9325891a52d036a9c454d0c81b3033.tar.gz gcc-8bfc81876f9325891a52d036a9c454d0c81b3033.tar.bz2 |
Move operand_less_p to vr-values.c.
Diffstat (limited to 'gcc/vr-values.c')
-rw-r--r-- | gcc/vr-values.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 2e3a078..f7cba16 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -1104,6 +1104,32 @@ vr_values::check_for_binary_op_overflow (enum tree_code subcode, tree type, return true; } +/* Return + 1 if VAL < VAL2 + 0 if !(VAL < VAL2) + -2 if those are incomparable. */ +static int +operand_less_p (tree val, tree val2) +{ + /* LT is folded faster than GE and others. Inline the common case. */ + if (TREE_CODE (val) == INTEGER_CST && TREE_CODE (val2) == INTEGER_CST) + return tree_int_cst_lt (val, val2); + else if (TREE_CODE (val) == SSA_NAME && TREE_CODE (val2) == SSA_NAME) + return val == val2 ? 0 : -2; + else + { + int cmp = compare_values (val, val2); + if (cmp == -1) + return 1; + else if (cmp == 0 || cmp == 1) + return 0; + else + return -2; + } + + return 0; +} + /* Try to derive a nonnegative or nonzero range out of STMT relying primarily on generic routines in fold in conjunction with range data. Store the result in *VR */ |