aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-07-07 21:50:41 +0000
committerJakub Jelinek <jakub@redhat.com>2016-07-07 21:50:41 +0000
commit416999907ca65cfdfbfade81f0d2ea8fc6d9bfe6 (patch)
tree999adb1f82fc4f0389b011a8227b34e8c815a02c
parent432497ce8c7204a1d9c917b61acee1eb7ab0ddf9 (diff)
Backported from mainline
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. * gcc.c-torture/execute/pr70429.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@238141 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/combine.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr70429.c17
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 52b69c8f3ea..1dbd3df3062 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,13 @@
2016-07-07 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 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.
+
2016-03-15 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70222
diff --git a/gcc/combine.c b/gcc/combine.c
index c48d9b11e47..d2f00d1b7e7 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -10182,6 +10182,11 @@ simplify_shift_const_1 (enum rtx_code code, enum 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 dac1b34b1b3..888311c89cf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,11 @@
2016-07-07 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2016-03-29 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/70429
+ * gcc.c-torture/execute/pr70429.c: New test.
+
2016-03-15 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70222
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;
+}