re PR target/66112 (__builtin_mul_overflow for int16_t emits poor code)

PR target/66112
	* internal-fn.c (get_min_precision): Use UNSIGNED instead of
	SIGNED to get precision of non-negative value.

	* gcc.target/i386/pr66112-1.c: New test.

From-SVN: r223115
This commit is contained in:
Jakub Jelinek 2015-05-13 10:07:58 +02:00 committed by Jakub Jelinek
parent e9ae68afa0
commit c1ee2e626e
4 changed files with 28 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2015-05-13 Jakub Jelinek <jakub@redhat.com>
PR target/66112
* internal-fn.c (get_min_precision): Use UNSIGNED instead of
SIGNED to get precision of non-negative value.
2015-05-13 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/66048

View File

@ -399,7 +399,7 @@ get_min_precision (tree arg, signop sign)
}
else if (sign == UNSIGNED && !wi::neg_p (arg_min, SIGNED))
{
int p = wi::min_precision (arg_max, SIGNED);
int p = wi::min_precision (arg_max, UNSIGNED);
prec = MIN (prec, p);
}
return prec + (orig_sign != sign);

View File

@ -1,3 +1,8 @@
2015-05-13 Jakub Jelinek <jakub@redhat.com>
PR target/66112
* gcc.target/i386/pr66112-1.c: New test.
2015-05-13 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/66048

View File

@ -0,0 +1,16 @@
/* PR target/66112 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
unsigned int
foo (long long a, long long b)
{
unsigned int res;
a &= ~0U;
b &= ~0U;
if (__builtin_mul_overflow (a, b, &res))
res = 0x123U;
return res;
}
/* { dg-final { scan-assembler "jn?o\[ \t\]" } } */