aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-09-23 21:53:09 -0700
committerAndrew Pinski <pinskia@gmail.com>2023-09-25 00:07:49 -0700
commit2bbac12ea7bd8a3eef5382e1b13f6019df4ec03f (patch)
tree665c32f705286e9898c7e7d63210aa8c952ae11e
parent9d5f20fc4a6b3254d2d379309193da4be2747987 (diff)
downloadgcc-2bbac12ea7bd8a3eef5382e1b13f6019df4ec03f.zip
gcc-2bbac12ea7bd8a3eef5382e1b13f6019df4ec03f.tar.gz
gcc-2bbac12ea7bd8a3eef5382e1b13f6019df4ec03f.tar.bz2
Fix PR 110386: backprop vs ABSU_EXPR
The issue here is that when backprop tries to go and strip sign ops, it skips over ABSU_EXPR but ABSU_EXPR not only does an ABS, it also changes the type to unsigned. Since strip_sign_op_1 is only supposed to strip off sign changing operands and not ones that change types, removing ABSU_EXPR here is correct. We don't handle nop conversions so this does cause any missed optimizations either. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/110386 gcc/ChangeLog: * gimple-ssa-backprop.cc (strip_sign_op_1): Remove ABSU_EXPR. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr110386-1.c: New test. * gcc.c-torture/compile/pr110386-2.c: New test.
-rw-r--r--gcc/gimple-ssa-backprop.cc1
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr110386-1.c9
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr110386-2.c11
3 files changed, 20 insertions, 1 deletions
diff --git a/gcc/gimple-ssa-backprop.cc b/gcc/gimple-ssa-backprop.cc
index 65a6559..dcb15ed 100644
--- a/gcc/gimple-ssa-backprop.cc
+++ b/gcc/gimple-ssa-backprop.cc
@@ -694,7 +694,6 @@ strip_sign_op_1 (tree rhs)
switch (gimple_assign_rhs_code (assign))
{
case ABS_EXPR:
- case ABSU_EXPR:
case NEGATE_EXPR:
return gimple_assign_rhs1 (assign);
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr110386-1.c b/gcc/testsuite/gcc.c-torture/compile/pr110386-1.c
new file mode 100644
index 0000000..4fcc977
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr110386-1.c
@@ -0,0 +1,9 @@
+
+int f(int a)
+{
+ int c = c < 0 ? c : -c;
+ c = -c;
+ unsigned b = c;
+ unsigned t = b*a;
+ return t*t;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr110386-2.c b/gcc/testsuite/gcc.c-torture/compile/pr110386-2.c
new file mode 100644
index 0000000..c60e1b6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr110386-2.c
@@ -0,0 +1,11 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-mavx" } */
+
+#include <immintrin.h>
+
+__m128i do_stuff(__m128i XMM0) {
+ __m128i ABS0 = _mm_abs_epi32(XMM0);
+ __m128i MUL0 = _mm_mullo_epi32(ABS0, XMM0);
+ __m128i MUL1 = _mm_mullo_epi32(MUL0, MUL0);
+ return MUL1;
+}