public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112537] New: Is there a way to disable cpymem pass for rvv
@ 2023-11-15  3:07 fanghuaqi at vip dot qq.com
  2023-11-15  3:13 ` [Bug target/112537] " pinskia at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: fanghuaqi at vip dot qq.com @ 2023-11-15  3:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

            Bug ID: 112537
           Summary: Is there a way to disable cpymem pass for rvv
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fanghuaqi at vip dot qq.com
  Target Milestone: ---

See
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/gcc.target/riscv/rvv/base/cpymem-2.c;h=7b706b6ef52544cabdce2007256c9e67b72ccd79;hb=9464e72bcc9123b619215af8cfef491772a3ebd9
this case, if I pass -march=rv64imafdcv to compile code like this, it will
generate vector related code, which I think it should only be enabled when
--param=riscv-autovec-preference=scalable is enabled, but actually it is auto
enable d even I pass  --param=riscv-autovec-preference=none, see
https://godbolt.org/z/TazWKEjzM

Is there a way to disable it, since if vector load and store for smaller
structure assign is costable and harmfull to cpu pipeline.

Thanks

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
@ 2023-11-15  3:13 ` pinskia at gcc dot gnu.org
  2023-11-15  4:45 ` juzhe.zhong at rivai dot ai
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-15  3:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>since if vector load and store for smaller structure assign is costable and harmfull to cpu pipeline.

This depends on the Pipeline. Seems like there is a missing cost model for your
cpu somewhere.

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
  2023-11-15  3:13 ` [Bug target/112537] " pinskia at gcc dot gnu.org
@ 2023-11-15  4:45 ` juzhe.zhong at rivai dot ai
  2023-11-15  5:03 ` fanghuaqi at vip dot qq.com
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-15  4:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #2 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
Currently, we don't have a compile option to disable cpymem by RVV.

I can tell how to disable it:

in riscv.md:

(define_expand "cpymem<mode>"
  [(parallel [(set (match_operand:BLK 0 "general_operand")
                   (match_operand:BLK 1 "general_operand"))
              (use (match_operand:P 2 ""))
              (use (match_operand:SI 3 "const_int_operand"))])]
  ""
{
  if (riscv_vector::expand_block_move (operands[0], operands[1], operands[2]))
    DONE;
  else if (riscv_expand_block_move (operands[0], operands[1], operands[2]))
    DONE;
  else
    FAIL;
})

remove 
if (riscv_vector::expand_block_move (operands[0], operands[1], operands[2]))
    DONE;

Then it will be disabled.

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
  2023-11-15  3:13 ` [Bug target/112537] " pinskia at gcc dot gnu.org
  2023-11-15  4:45 ` juzhe.zhong at rivai dot ai
@ 2023-11-15  5:03 ` fanghuaqi at vip dot qq.com
  2023-11-15  5:05 ` juzhe.zhong at rivai dot ai
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: fanghuaqi at vip dot qq.com @ 2023-11-15  5:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #3 from Huaqi <fanghuaqi at vip dot qq.com> ---
Hi Juzhe, thanks for the help, could it be controlled by
--param=riscv-autovec-preference= option, so if I want to enable cpymem
optimization, I can enable it by auto vectorzation.

Thanks

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (2 preceding siblings ...)
  2023-11-15  5:03 ` fanghuaqi at vip dot qq.com
@ 2023-11-15  5:05 ` juzhe.zhong at rivai dot ai
  2023-11-15  5:14 ` fanghuaqi at vip dot qq.com
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-15  5:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #4 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
You mean you want to disable it when disabling auto-vectorization ?

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (3 preceding siblings ...)
  2023-11-15  5:05 ` juzhe.zhong at rivai dot ai
@ 2023-11-15  5:14 ` fanghuaqi at vip dot qq.com
  2023-11-15  5:17 ` juzhe.zhong at rivai dot ai
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: fanghuaqi at vip dot qq.com @ 2023-11-15  5:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #5 from Huaqi <fanghuaqi at vip dot qq.com> ---
(In reply to JuzheZhong from comment #4)
> You mean you want to disable it when disabling auto-vectorization ?

Yes, I think this could be better, so we can control whether vector instruction
should be generated, and if auto generated rvv instruction is not good, we can
enable it via gcc pragma control for selected code block.

Thanks

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (4 preceding siblings ...)
  2023-11-15  5:14 ` fanghuaqi at vip dot qq.com
@ 2023-11-15  5:17 ` juzhe.zhong at rivai dot ai
  2023-11-15  5:53 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-15  5:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #6 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
We can add 

  if (!flag_tree_vectorize)
    return false;

in riscv_vector::expand_block_move

But I am not sure whether other RISC-V folks is happy with that.

CCing other folks to see whether they allow it.

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (5 preceding siblings ...)
  2023-11-15  5:17 ` juzhe.zhong at rivai dot ai
@ 2023-11-15  5:53 ` pinskia at gcc dot gnu.org
  2023-11-15  6:42 ` kito at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-15  5:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mumuxi_ll at outlook dot com

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 112538 has been marked as a duplicate of this bug. ***

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (6 preceding siblings ...)
  2023-11-15  5:53 ` pinskia at gcc dot gnu.org
@ 2023-11-15  6:42 ` kito at gcc dot gnu.org
  2023-11-15  6:44 ` juzhe.zhong at rivai dot ai
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: kito at gcc dot gnu.org @ 2023-11-15  6:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #8 from Kito Cheng <kito at gcc dot gnu.org> ---
That remind me we may need one option like something -mgeneral-regs-only in
aarch64 and also for target attribute.

BTW, clang has an generic option called -mno-implicit-float can did similar
thing

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (7 preceding siblings ...)
  2023-11-15  6:42 ` kito at gcc dot gnu.org
@ 2023-11-15  6:44 ` juzhe.zhong at rivai dot ai
  2023-11-15  7:12 ` juzhe.zhong at rivai dot ai
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-15  6:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #9 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
I think we can use -fno-tree-vectorize or --param=riscv-autovec-preference=none
to
disable it.

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (8 preceding siblings ...)
  2023-11-15  6:44 ` juzhe.zhong at rivai dot ai
@ 2023-11-15  7:12 ` juzhe.zhong at rivai dot ai
  2023-11-15  7:34 ` kito at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-11-15  7:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #10 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
This following patch:

diff --git a/gcc/config/riscv/riscv-string.cc
b/gcc/config/riscv/riscv-string.cc
index 57e8ad698d7..c135d4efdb2 100644
--- a/gcc/config/riscv/riscv-string.cc
+++ b/gcc/config/riscv/riscv-string.cc
@@ -773,7 +773,7 @@ expand_block_move (rtx dst_in, rtx src_in, rtx length_in)
        bnez a2, loop                   # Any more?
        ret                             # Return
   */
-  if (!TARGET_VECTOR)
+  if (!TARGET_VECTOR || riscv_autovec_preference == NO_AUTOVEC ||
!flag_tree_vectorize)
     return false;
   HOST_WIDE_INT potential_ew
     = (MIN (MIN (MEM_ALIGN (src_in), MEM_ALIGN (dst_in)), BITS_PER_WORD)


Can fix this issue. Is it OK ?

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (9 preceding siblings ...)
  2023-11-15  7:12 ` juzhe.zhong at rivai dot ai
@ 2023-11-15  7:34 ` kito at gcc dot gnu.org
  2023-11-17 13:23 ` amylaar at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: kito at gcc dot gnu.org @ 2023-11-15  7:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #11 from Kito Cheng <kito at gcc dot gnu.org> ---
It's not scope of auto vectorization, so I would suggest add something like
`-mstringop-strategy=*` or `-mmemcpy-strategy=*` (from x86) or
`-param=riscv-mops-memcpy-size-threshold=` (from aarch64).

Personally I prefer x86 approach.

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (10 preceding siblings ...)
  2023-11-15  7:34 ` kito at gcc dot gnu.org
@ 2023-11-17 13:23 ` amylaar at gcc dot gnu.org
  2023-11-17 13:27 ` amylaar at gcc dot gnu.org
  2023-11-20  2:50 ` cvs-commit at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: amylaar at gcc dot gnu.org @ 2023-11-17 13:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

Jorn Wolfgang Rennecke <amylaar at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amylaar at gcc dot gnu.org

--- Comment #12 from Jorn Wolfgang Rennecke <amylaar at gcc dot gnu.org> ---
(In reply to JuzheZhong from comment #2)
> Currently, we don't have a compile option to disable cpymem by RVV.

If you don't want any vector instructions to be emitted, why do you tell the
compiler to enable the 'v' extsnsion of the architecture?

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (11 preceding siblings ...)
  2023-11-17 13:23 ` amylaar at gcc dot gnu.org
@ 2023-11-17 13:27 ` amylaar at gcc dot gnu.org
  2023-11-20  2:50 ` cvs-commit at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: amylaar at gcc dot gnu.org @ 2023-11-17 13:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #13 from Jorn Wolfgang Rennecke <amylaar at gcc dot gnu.org> ---
Before we can consider any costs, we first have to know what they are.  Is
there any manual for a hardware implementation that specifies costs?

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

* [Bug target/112537] Is there a way to disable cpymem pass for rvv
  2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
                   ` (12 preceding siblings ...)
  2023-11-17 13:27 ` amylaar at gcc dot gnu.org
@ 2023-11-20  2:50 ` cvs-commit at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-20  2:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Li Xu <xuli@gcc.gnu.org>:

https://gcc.gnu.org/g:e6269bb69c0734a5af716bfbded3621de6ca351d

commit r14-5602-ge6269bb69c0734a5af716bfbded3621de6ca351d
Author: xuli <xuli1@eswincomputing.com>
Date:   Fri Nov 17 04:48:47 2023 +0000

    RISC-V: Implement -mmemcpy-strategy= options[PR112537]

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112537

    -mmemcpy-strategy=[auto|libcall|scalar|vector]

    auto: Current status, use scalar or vector instructions.
    libcall: Always use a library call.
    scalar: Only use scalar instructions.
    vector: Only use vector instructions.

            PR target/112537

    gcc/ChangeLog:

            * config/riscv/riscv-opts.h (enum riscv_stringop_strategy_enum):
Strategy enum.
            * config/riscv/riscv-string.cc (riscv_expand_block_move): Disabled
based on options.
            (expand_block_move): Ditto.
            * config/riscv/riscv.opt: Add -mmemcpy-strategy=.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/base/cpymem-strategy-1.c: New test.
            * gcc.target/riscv/rvv/base/cpymem-strategy-2.c: New test.
            * gcc.target/riscv/rvv/base/cpymem-strategy-3.c: New test.
            * gcc.target/riscv/rvv/base/cpymem-strategy-4.c: New test.
            * gcc.target/riscv/rvv/base/cpymem-strategy-5.c: New test.
            * gcc.target/riscv/rvv/base/cpymem-strategy.h: New test.

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

end of thread, other threads:[~2023-11-20  2:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15  3:07 [Bug c/112537] New: Is there a way to disable cpymem pass for rvv fanghuaqi at vip dot qq.com
2023-11-15  3:13 ` [Bug target/112537] " pinskia at gcc dot gnu.org
2023-11-15  4:45 ` juzhe.zhong at rivai dot ai
2023-11-15  5:03 ` fanghuaqi at vip dot qq.com
2023-11-15  5:05 ` juzhe.zhong at rivai dot ai
2023-11-15  5:14 ` fanghuaqi at vip dot qq.com
2023-11-15  5:17 ` juzhe.zhong at rivai dot ai
2023-11-15  5:53 ` pinskia at gcc dot gnu.org
2023-11-15  6:42 ` kito at gcc dot gnu.org
2023-11-15  6:44 ` juzhe.zhong at rivai dot ai
2023-11-15  7:12 ` juzhe.zhong at rivai dot ai
2023-11-15  7:34 ` kito at gcc dot gnu.org
2023-11-17 13:23 ` amylaar at gcc dot gnu.org
2023-11-17 13:27 ` amylaar at gcc dot gnu.org
2023-11-20  2:50 ` cvs-commit at gcc dot gnu.org

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).