diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-04-23 14:45:51 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-04-23 14:45:51 +0000 |
commit | 265815a249c2e0481564e204fd90270e1fbea8fd (patch) | |
tree | 1e709f40d1d9f1e69133b9aef1152e8fabd4d639 /gcc/internal-fn.c | |
parent | 936a705d6c5baca09ed207c901a1d5cdbd6bcc37 (diff) | |
download | gcc-265815a249c2e0481564e204fd90270e1fbea8fd.tar.gz |
Fix ubsan internal-fn.c handling.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@209699 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/internal-fn.c')
-rw-r--r-- | gcc/internal-fn.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index c2845f0276e..68b2b66fbe7 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -478,7 +478,7 @@ ubsan_expand_si_overflow_mul_check (gimple stmt) rtx do_overflow = gen_label_rtx (); rtx hipart_different = gen_label_rtx (); - int hprec = GET_MODE_PRECISION (hmode); + unsigned int hprec = GET_MODE_PRECISION (hmode); rtx hipart0 = expand_shift (RSHIFT_EXPR, mode, op0, hprec, NULL_RTX, 0); hipart0 = gen_lowpart (hmode, hipart0); @@ -513,12 +513,11 @@ ubsan_expand_si_overflow_mul_check (gimple stmt) wide_int arg0_min, arg0_max; if (get_range_info (arg0, &arg0_min, &arg0_max) == VR_RANGE) { - if (wi::les_p (arg0_max, wi::max_value (hprec, SIGNED)) - && wi::les_p (wi::min_value (hprec, SIGNED), arg0_min)) + unsigned int mprec0 = wi::min_precision (arg0_min, SIGNED); + unsigned int mprec1 = wi::min_precision (arg0_max, SIGNED); + if (mprec0 <= hprec && mprec1 <= hprec) op0_small_p = true; - else if (wi::les_p (arg0_max, wi::max_value (hprec, UNSIGNED)) - && wi::les_p (~wi::max_value (hprec, UNSIGNED), - arg0_min)) + else if (mprec0 <= hprec + 1 && mprec1 <= hprec + 1) op0_medium_p = true; if (!wi::neg_p (arg0_min, TYPE_SIGN (TREE_TYPE (arg0)))) op0_sign = 0; @@ -531,12 +530,11 @@ ubsan_expand_si_overflow_mul_check (gimple stmt) wide_int arg1_min, arg1_max; if (get_range_info (arg1, &arg1_min, &arg1_max) == VR_RANGE) { - if (wi::les_p (arg1_max, wi::max_value (hprec, SIGNED)) - && wi::les_p (wi::min_value (hprec, SIGNED), arg1_min)) + unsigned int mprec0 = wi::min_precision (arg1_min, SIGNED); + unsigned int mprec1 = wi::min_precision (arg1_max, SIGNED); + if (mprec0 <= hprec && mprec1 <= hprec) op1_small_p = true; - else if (wi::les_p (arg1_max, wi::max_value (hprec, UNSIGNED)) - && wi::les_p (~wi::max_value (hprec, UNSIGNED), - arg1_min)) + else if (mprec0 <= hprec + 1 && mprec1 <= hprec + 1) op1_medium_p = true; if (!wi::neg_p (arg1_min, TYPE_SIGN (TREE_TYPE (arg1)))) op1_sign = 0; |