aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-04-11 19:21:51 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-04-11 19:21:51 +0200
commitdf1c878ec25af7e9405b0276e6478fd996c2d3f9 (patch)
treed1d5ca050c0a8ac57a6d99ab8e91004a3a1aeec0 /gcc
parent8585103f053ef26a5939ec7c3a08ad77f70d2c3c (diff)
downloadgcc-df1c878ec25af7e9405b0276e6478fd996c2d3f9.zip
gcc-df1c878ec25af7e9405b0276e6478fd996c2d3f9.tar.gz
gcc-df1c878ec25af7e9405b0276e6478fd996c2d3f9.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/simplify-rtx.c4
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/pr80100.c9
4 files changed, 18 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ea434f6..e5b4c75 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 4bbbe23..ce632ae 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a018288..d8597e2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/pr80100.c b/gcc/testsuite/gcc.dg/pr80100.c
new file mode 100644
index 0000000..0d462be
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr80100.c
@@ -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));
+}