re PR middle-end/80100 (simplify-rtx.c sanitizer detects undefined behaviour with optimization)

PR middle-end/80100
	* simplify-rtx.c (simplify_binary_operation_1) <case IOR>: Perform
	left shift in unsigned HOST_WIDE_INT type.

	* gcc.dg/pr80100.c: New test.

From-SVN: r246851
This commit is contained in:
Jakub Jelinek 2017-04-11 19:21:51 +02:00 committed by Jakub Jelinek
parent 8585103f05
commit df1c878ec2
4 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,9 @@
2017-04-11 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80100
* simplify-rtx.c (simplify_binary_operation_1) <case IOR>: Perform
left shift in unsigned HOST_WIDE_INT type.
PR rtl-optimization/80385
* simplify-rtx.c (simplify_unary_operation_1): Don't transform
(not (neg X)) into (plus X -1) for complex or non-integral modes.

View File

@ -2741,8 +2741,8 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode,
&& CONST_INT_P (XEXP (op0, 1))
&& INTVAL (XEXP (op0, 1)) < HOST_BITS_PER_WIDE_INT)
{
int count = INTVAL (XEXP (op0, 1));
HOST_WIDE_INT mask = INTVAL (trueop1) << count;
int count = INTVAL (XEXP (op0, 1));
HOST_WIDE_INT mask = UINTVAL (trueop1) << count;
if (mask >> count == INTVAL (trueop1)
&& trunc_int_for_mode (mask, mode) == mask

View File

@ -1,5 +1,8 @@
2017-04-11 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80100
* gcc.dg/pr80100.c: New test.
PR rtl-optimization/80385
* g++.dg/opt/pr80385.C: New test.

View File

@ -0,0 +1,9 @@
/* PR middle-end/80100 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
long int
foo (long int x)
{
return 2L | ((x - 1L) >> (__SIZEOF_LONG__ * __CHAR_BIT__ - 1));
}