[V2] DOC: Update COND_LEN document

Message ID 20231026095346.3190168-1-juzhe.zhong@rivai.ai
State Unresolved
Headers
Series [V2] DOC: Update COND_LEN document |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

juzhe.zhong@rivai.ai Oct. 26, 2023, 9:53 a.m. UTC
  gcc/ChangeLog:

	* doc/md.texi: Adapt COND_LEN pseudo code.

---
 gcc/doc/md.texi | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
  

Comments

Richard Sandiford Oct. 26, 2023, 9:56 a.m. UTC | #1
Juzhe-Zhong <juzhe.zhong@rivai.ai> writes:
> gcc/ChangeLog:
>
> 	* doc/md.texi: Adapt COND_LEN pseudo code.

OK.  Given your earlier message, I'd justed finished writing & testing
the same patch.

Richard

> ---
>  gcc/doc/md.texi | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
> index daa318ee3da..fab2513105a 100644
> --- a/gcc/doc/md.texi
> +++ b/gcc/doc/md.texi
> @@ -7341,8 +7341,10 @@ store the result in operand 0, otherwise store operand 2 in operand 0.
>  The operation only works for the operands are vectors.
>  
>  @smallexample
> -for (i = 0; i < ops[4] + ops[5]; i++)
> -  op0[i] = op1[i] ? @var{op} op2[i] : op3[i];
> +for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
> +  op0[i] = (i < ops[4] + ops[5] && op1[i]
> +            ? @var{op} op2[i]
> +            : op3[i]);
>  @end smallexample
>  
>  where, for example, @var{op} is @code{~} for @samp{cond_len_one_cmpl@var{mode}}.
> @@ -7403,8 +7405,10 @@ store the result in operand 0, otherwise store operand 4 in operand 0.
>  The operation only works for the operands are vectors.
>  
>  @smallexample
> -for (i = 0; i < ops[5] + ops[6]; i++)
> -  op0[i] = op1[i] ? op2[i] @var{op} op3[i] : op4[i];
> +for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
> +  op0[i] = (i < ops[5] + ops[6] && op1[i]
> +            ? op2[i] @var{op} op3[i]
> +            : op4[i]);
>  @end smallexample
>  
>  where, for example, @var{op} is @code{+} for @samp{cond_len_add@var{mode}}.
> @@ -7436,8 +7440,10 @@ takes 3 operands rather than two.  For example, the vector form of
>  @samp{cond_len_fma@var{mode}} is equivalent to:
>  
>  @smallexample
> -for (i = 0; i < ops[6] + ops[7]; i++)
> -  op0[i] = op1[i] ? fma (op2[i], op3[i], op4[i]) : op5[i];
> +for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
> +  op0[i] = (i < ops[6] + ops[7] && op1[i]
> +            ? fma (op2[i], op3[i], op4[i])
> +            : op5[i]);
>  @end smallexample
>  
>  @cindex @code{neg@var{mode}cc} instruction pattern
  
juzhe.zhong@rivai.ai Oct. 26, 2023, 10:01 a.m. UTC | #2
Thanks Richard. Committed.



juzhe.zhong@rivai.ai
 
From: Richard Sandiford
Date: 2023-10-26 17:56
To: Juzhe-Zhong
CC: gcc-patches; rguenther
Subject: Re: [PATCH V2] DOC: Update COND_LEN document
Juzhe-Zhong <juzhe.zhong@rivai.ai> writes:
> gcc/ChangeLog:
>
> * doc/md.texi: Adapt COND_LEN pseudo code.
 
OK.  Given your earlier message, I'd justed finished writing & testing
the same patch.
 
Richard
 
> ---
>  gcc/doc/md.texi | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
> index daa318ee3da..fab2513105a 100644
> --- a/gcc/doc/md.texi
> +++ b/gcc/doc/md.texi
> @@ -7341,8 +7341,10 @@ store the result in operand 0, otherwise store operand 2 in operand 0.
>  The operation only works for the operands are vectors.
>  
>  @smallexample
> -for (i = 0; i < ops[4] + ops[5]; i++)
> -  op0[i] = op1[i] ? @var{op} op2[i] : op3[i];
> +for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
> +  op0[i] = (i < ops[4] + ops[5] && op1[i]
> +            ? @var{op} op2[i]
> +            : op3[i]);
>  @end smallexample
>  
>  where, for example, @var{op} is @code{~} for @samp{cond_len_one_cmpl@var{mode}}.
> @@ -7403,8 +7405,10 @@ store the result in operand 0, otherwise store operand 4 in operand 0.
>  The operation only works for the operands are vectors.
>  
>  @smallexample
> -for (i = 0; i < ops[5] + ops[6]; i++)
> -  op0[i] = op1[i] ? op2[i] @var{op} op3[i] : op4[i];
> +for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
> +  op0[i] = (i < ops[5] + ops[6] && op1[i]
> +            ? op2[i] @var{op} op3[i]
> +            : op4[i]);
>  @end smallexample
>  
>  where, for example, @var{op} is @code{+} for @samp{cond_len_add@var{mode}}.
> @@ -7436,8 +7440,10 @@ takes 3 operands rather than two.  For example, the vector form of
>  @samp{cond_len_fma@var{mode}} is equivalent to:
>  
>  @smallexample
> -for (i = 0; i < ops[6] + ops[7]; i++)
> -  op0[i] = op1[i] ? fma (op2[i], op3[i], op4[i]) : op5[i];
> +for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
> +  op0[i] = (i < ops[6] + ops[7] && op1[i]
> +            ? fma (op2[i], op3[i], op4[i])
> +            : op5[i]);
>  @end smallexample
>  
>  @cindex @code{neg@var{mode}cc} instruction pattern
  

Patch

diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index daa318ee3da..fab2513105a 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -7341,8 +7341,10 @@  store the result in operand 0, otherwise store operand 2 in operand 0.
 The operation only works for the operands are vectors.
 
 @smallexample
-for (i = 0; i < ops[4] + ops[5]; i++)
-  op0[i] = op1[i] ? @var{op} op2[i] : op3[i];
+for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
+  op0[i] = (i < ops[4] + ops[5] && op1[i]
+            ? @var{op} op2[i]
+            : op3[i]);
 @end smallexample
 
 where, for example, @var{op} is @code{~} for @samp{cond_len_one_cmpl@var{mode}}.
@@ -7403,8 +7405,10 @@  store the result in operand 0, otherwise store operand 4 in operand 0.
 The operation only works for the operands are vectors.
 
 @smallexample
-for (i = 0; i < ops[5] + ops[6]; i++)
-  op0[i] = op1[i] ? op2[i] @var{op} op3[i] : op4[i];
+for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
+  op0[i] = (i < ops[5] + ops[6] && op1[i]
+            ? op2[i] @var{op} op3[i]
+            : op4[i]);
 @end smallexample
 
 where, for example, @var{op} is @code{+} for @samp{cond_len_add@var{mode}}.
@@ -7436,8 +7440,10 @@  takes 3 operands rather than two.  For example, the vector form of
 @samp{cond_len_fma@var{mode}} is equivalent to:
 
 @smallexample
-for (i = 0; i < ops[6] + ops[7]; i++)
-  op0[i] = op1[i] ? fma (op2[i], op3[i], op4[i]) : op5[i];
+for (i = 0; i < GET_MODE_NUNITS (@var{m}); i++)
+  op0[i] = (i < ops[6] + ops[7] && op1[i]
+            ? fma (op2[i], op3[i], op4[i])
+            : op5[i]);
 @end smallexample
 
 @cindex @code{neg@var{mode}cc} instruction pattern