public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC]: Remove Mem/address type assumption in combiner
@ 2015-04-29  9:29 Kumar, Venkataramanan
  2015-04-29 17:38 ` Segher Boessenkool
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Kumar, Venkataramanan @ 2015-04-29  9:29 UTC (permalink / raw)
  To: Jeff Law (law@redhat.com), segher, gcc-patches; +Cc: maxim.kuvyrkov

Hi Jeff/Segher, 

Restarting the discussion on the GCC combiner assumption about Memory/address type.
Ref: https://gcc.gnu.org/ml/gcc-patches/2015-01/msg01298.html
https://gcc.gnu.org/ml/gcc/2015-04/msg00028.html

While working on the test case in PR 63949,  I came across the below code in combine.c: make_compound_operation.

--snip---
  /* Select the code to be used in recursive calls.  Once we are inside an
     address, we stay there.  If we have a comparison, set to COMPARE,
     but once inside, go back to our default of SET.  */

  next_code = (code == MEM ? MEM
               : ((code == PLUS || code == MINUS)
                  && SCALAR_INT_MODE_P (mode)) ? MEM
               : ((code == COMPARE || COMPARISON_P (x))
                  && XEXP (x, 1) == const0_rtx) ? COMPARE
               : in_code == COMPARE ? SET : in_code);
---snip--

When we see an  RTX code with PLUS or MINUS then it is treated as  MEM/address type (we are inside address RTX). 
Is there any significance on that assumption?  I removed this assumption and the test case in the PR 63949 passed.

diff --git a/gcc/combine.c b/gcc/combine.c
index 5c763b4..945abdb 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -7703,8 +7703,6 @@ make_compound_operation (rtx x, enum rtx_code in_code)
      but once inside, go back to our default of SET.  */

   next_code = (code == MEM ? MEM
-              : ((code == PLUS || code == MINUS)
-                 && SCALAR_INT_MODE_P (mode)) ? MEM
               : ((code == COMPARE || COMPARISON_P (x))
                  && XEXP (x, 1) == const0_rtx) ? COMPARE
               : in_code == COMPARE ? SET : in_code);


On X86_64, it passes bootstrap and regression tests.
But on Aarch64 the test in PR passed, but I got a few test case failures.

Tests that now fail, but worked before:

gcc.target/aarch64/adds1.c scan-assembler adds\tw[0-9]+, w[0-9]+, w[0-9]+, lsl 3
gcc.target/aarch64/adds1.c scan-assembler adds\tx[0-9]+, x[0-9]+, x[0-9]+, lsl 3
gcc.target/aarch64/adds3.c scan-assembler-times adds\tx[0-9]+, x[0-9]+, x[0-9]+,
 sxtw 2
gcc.target/aarch64/extend.c scan-assembler add\tw[0-9]+,.*uxth #?1
gcc.target/aarch64/extend.c scan-assembler add\tx[0-9]+,.*uxtw #?3
gcc.target/aarch64/extend.c scan-assembler sub\tw[0-9]+,.*uxth #?1
gcc.target/aarch64/extend.c scan-assembler sub\tx[0-9]+,.*uxth #?1
gcc.target/aarch64/extend.c scan-assembler sub\tx[0-9]+,.*uxtw #?3
gcc.target/aarch64/subs1.c scan-assembler subs\tw[0-9]+, w[0-9]+, w[0-9]+, lsl 3
gcc.target/aarch64/subs1.c scan-assembler subs\tx[0-9]+, x[0-9]+, x[0-9]+, lsl 3
gcc.target/aarch64/subs3.c scan-assembler-times subs\tx[0-9]+, x[0-9]+, x[0-9]+,
 sxtw 2

Based on  in_code , If it is of "MEM"  type combiner converts shifts to multiply operations.

--snip--
  switch (code)
    {
    case ASHIFT:
      /* Convert shifts by constants into multiplications if inside
         an address.  */
      if (in_code == MEM && CONST_INT_P (XEXP (x, 1))
          && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT
          && INTVAL (XEXP (x, 1)) >= 0
          && SCALAR_INT_MODE_P (mode))
 ---snip----

There are few patterns based on multiplication operations in Aarch64 backend which are used to match with the pattern combiner generated.
Now those patterns have to be fixed to use SHIFTS.  Also need to see any impact on other targets.

But  before that  I wanted to check if the assumption in combiner,  can simply be removed ?

Regards,
Venkat.

PS:  I am starting a new thread since I no more have access to Linaro ID from where I sent the earlier mail.

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2015-05-19 17:28 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29  9:29 [RFC]: Remove Mem/address type assumption in combiner Kumar, Venkataramanan
2015-04-29 17:38 ` Segher Boessenkool
2015-04-29 19:23   ` Jeff Law
2015-05-01 15:18   ` Segher Boessenkool
2015-05-05 16:14     ` Kumar, Venkataramanan
2015-05-05 17:15       ` Segher Boessenkool
2015-05-07 11:01         ` Kumar, Venkataramanan
2015-05-11 17:50           ` Steve Ellcey
2015-05-11 18:27             ` Segher Boessenkool
2015-05-11 19:44               ` Steve Ellcey
2015-05-11 19:46                 ` Jeff Law
2015-05-11 19:46                   ` Jeff Law
2015-05-11 20:17                     ` Matthew Fortune
2015-05-11 20:30                       ` Segher Boessenkool
2015-05-11 20:54                         ` Matthew Fortune
2015-05-12  6:43             ` Kumar, Venkataramanan
2015-05-12 16:57               ` Steve Ellcey
2015-05-12 22:02                 ` Moore, Catherine
2015-05-16  6:09     ` Hans-Peter Nilsson
2015-05-16 14:36       ` Segher Boessenkool
2015-05-16 16:43         ` Hans-Peter Nilsson
2015-05-16 17:40           ` Segher Boessenkool
2015-05-17  8:53             ` Hans-Peter Nilsson
2015-05-17 13:32               ` Segher Boessenkool
2015-05-17 13:48                 ` Hans-Peter Nilsson
2015-05-19 17:30               ` Jeff Law
2015-04-29 19:22 ` Jeff Law
2015-04-29 19:31 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).