From 27d0862e62b5af5cce218a32cfcf3db27c85d1f2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 25 Nov 2016 18:12:29 +0100 Subject: [PATCH] re PR rtl-optimization/78527 (ice on valid C code at -O3 in both 32-bit and 64-bit modes on x86_64-linux-gnu (internal compiler error: in smallest_mode_for_size, at stor-layout.c:364)) PR rtl-optimization/78527 * combine.c (make_compound_operation_int): Ignore LSHIFTRT with out of bounds shift count. * gcc.c-torture/compile/pr78527.c: New test. From-SVN: r242879 --- gcc/ChangeLog | 6 ++++++ gcc/combine.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr78527.c | 21 +++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr78527.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 443dbfc77c3..947f8f6d1dd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-25 Jakub Jelinek + + PR rtl-optimization/78527 + * combine.c (make_compound_operation_int): Ignore LSHIFTRT with + out of bounds shift count. + 2016-11-25 Martin Liska PR web/71666 diff --git a/gcc/combine.c b/gcc/combine.c index ce6cfde534d..ecf674193f7 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -8091,6 +8091,8 @@ make_compound_operation_int (machine_mode mode, rtx *x_ptr, if (GET_CODE (inner) == LSHIFTRT && CONST_INT_P (XEXP (inner, 1)) && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (inner)) + && (UINTVAL (XEXP (inner, 1)) + < GET_MODE_PRECISION (GET_MODE (inner))) && subreg_lowpart_p (x)) { new_rtx = make_compound_operation (XEXP (inner, 0), next_code); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 25663cefe0a..a4f67e54d13 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-25 Jakub Jelinek + + PR rtl-optimization/78527 + * gcc.c-torture/compile/pr78527.c: New test. + 2016-11-25 Martin Liska PR gcov-profile/78086 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr78527.c b/gcc/testsuite/gcc.c-torture/compile/pr78527.c new file mode 100644 index 00000000000..d1bbdc4db07 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr78527.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/78527 */ + +unsigned a; +short b, e; +int *c; +char d; + +int +main () +{ + int f = 80; + for (;;) { + if (f > 432) + *c = a; + while (b) + if (d) + e = -(a >> f); + c = &f; + b = e; + } +} -- 2.30.2