diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-03-29 18:49:00 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2016-03-29 18:49:00 +0000 |
commit | c54ff1dee1234d448ff4cd4eeea3f042d7df8084 (patch) | |
tree | 403c3e385daa0141fced2cc170fd23bc95606ee5 | |
parent | 32be48091fc6a0eae502c15087b0f5c5cd4d5b27 (diff) |
PR rtl-optimization/70429
* combine.c (simplify_shift_const_1): For ASHIFTRT don't optimize
(cst1 >> count) >> cst2 into (cst1 >> cst2) >> count if
mode != result_mode.
* gcc.c-torture/execute/pr70429.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@234531 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/combine.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr70429.c | 17 |
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb6297710d5..042757895d6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-03-29 Jakub Jelinek <jakub@redhat.com> + PR rtl-optimization/70429 + * combine.c (simplify_shift_const_1): For ASHIFTRT don't optimize + (cst1 >> count) >> cst2 into (cst1 >> cst2) >> count if + mode != result_mode. + PR c++/70353 * tree-inline.c (remap_decls): Don't add_local_decl if cfun is null. diff --git a/gcc/combine.c b/gcc/combine.c index f701f289f3f..1d0e8beeb2c 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -10533,6 +10533,11 @@ simplify_shift_const_1 (enum rtx_code code, machine_mode result_mode, >> orig_count, result_mode, &complement_p)) break; + /* For ((int) (cstLL >> count)) >> cst2 just give up. Queuing + up outer sign extension (often left and right shift) is + hardly more efficient than the original. See PR70429. */ + if (code == ASHIFTRT && mode != result_mode) + break; rtx new_rtx = simplify_const_binary_operation (code, mode, XEXP (varop, 0), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 912a830e75d..2459a2aa489 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2016-03-29 Jakub Jelinek <jakub@redhat.com> + PR rtl-optimization/70429 + * gcc.c-torture/execute/pr70429.c: New test. + PR tree-optimization/70405 * gcc.dg/pr70405.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr70429.c b/gcc/testsuite/gcc.c-torture/execute/pr70429.c new file mode 100644 index 00000000000..6b08c8ead08 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr70429.c @@ -0,0 +1,17 @@ +/* PR rtl-optimization/70429 */ + +__attribute__((noinline, noclone)) int +foo (int a) +{ + return (int) (0x14ff6e2207db5d1fLL >> a) >> 4; +} + +int +main () +{ + if (sizeof (int) != 4 || sizeof (long long) != 8 || __CHAR_BIT__ != 8) + return 0; + if (foo (1) != 0x3edae8 || foo (2) != -132158092) + __builtin_abort (); + return 0; +} |