public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
@ 2023-10-25  8:14 crazylht at gmail dot com
  2023-10-25  9:29 ` [Bug tree-optimization/111972] " crazylht at gmail dot com
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: crazylht at gmail dot com @ 2023-10-25  8:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111972
           Summary: [14 regression] missed vectorzation for bool a = j !=
                    1; j = (long int)a;
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

cat test.c

double
foo() {
  long n3 = 3450000, xtra = 7270;
  long i,ix;
  long j;
  double Check;

  /* Section 3, Conditional jumps */
  j = 0;
  {
    for (ix=0; ix<xtra; ix++)
      {
        for(i=0; i<n3; i++)
          {
            if(j==1)       j = 2;
            else           j = 3;
            if(j>2)        j = 0;
            else           j = 1;
            if(j<1)        j = 1;
            else           j = 0;
          }
      }
  }
  Check = Check + (double)j;
  return Check;
}

The different between gcc 13 dump and gcc14 dump is
GCC13 we have

  <bb 3> [local count: 1063004411]:
  # i_16 = PHI <i_13(8), 0(5)>
  # j_18 = PHI <_7(8), j_21(5)>
  # ivtmp_15 = PHI <ivtmp_6(8), 3450000(5)>
  _7 = j_18 ^ 1;
  i_13 = i_16 + 1;
  ivtmp_6 = ivtmp_15 - 1;
  if (ivtmp_6 != 0)
    goto <bb 8>; [99.00%]
  else
    goto <bb 4>; [1.00%]

GCC14 we have

  <bb 3> [local count: 1063004410]:
  # i_17 = PHI <i_13(8), 0(5)>
  # j_19 = PHI <_14(8), j_22(5)>
  # ivtmp_16 = PHI <ivtmp_15(8), 3450000(5)>
  _9 = j_19 != 1;
  _14 = (long int) _9;
  i_13 = i_17 + 1;
  ivtmp_15 = ivtmp_16 - 1;
  if (ivtmp_15 != 0)
    goto <bb 8>; [98.99%]
  else
    goto <bb 4>; [1.01%]

Vectorizer can handle 

  _7 = j_18 ^ 1; 

but not

  _9 = j_19 != 1;
  _14 = (long int) _9;


../test.C:11:18: note:   vect_is_simple_use: operand j_19 != 1, type of def:
internal
../test.C:11:18: note:   mark relevant 2, live 0: _9 = j_19 != 1;
../test.C:11:18: note:   worklist: examine stmt: _9 = j_19 != 1;
../test.C:11:18: note:   vect_is_simple_use: operand j_19 = PHI <_14(8),
j_22(5)>, type of def: unknown
../test.C:11:18: missed:   Unsupported pattern.
../test.C:15:6: missed:   not vectorized: unsupported use in stmt.
../test.C:11:18: missed:  unexpected pattern.


The difference comes from phiopt2.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
@ 2023-10-25  9:29 ` crazylht at gmail dot com
  2023-10-25 16:46 ` pinskia at gcc dot gnu.org
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: crazylht at gmail dot com @ 2023-10-25  9:29 UTC (permalink / raw)
  To: gcc-bugs

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

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
          Component|middle-end                  |tree-optimization

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
The phiopt change is caused by
r14-338-g1dd154f6407658d46faa4d21bfec04fc2551506a

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
  2023-10-25  9:29 ` [Bug tree-optimization/111972] " crazylht at gmail dot com
@ 2023-10-25 16:46 ` pinskia at gcc dot gnu.org
  2023-10-27  3:48 ` pinskia at gcc dot gnu.org
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-25 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-10-25
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
   Target Milestone|---                         |14.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
  2023-10-25  9:29 ` [Bug tree-optimization/111972] " crazylht at gmail dot com
  2023-10-25 16:46 ` pinskia at gcc dot gnu.org
@ 2023-10-27  3:48 ` pinskia at gcc dot gnu.org
  2023-10-27  3:59 ` pinskia at gcc dot gnu.org
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-27  3:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=112104

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
First off does this even make sense to vectorize but rather do some kind of
scalar reduction with respect to j = j^1 here  .  Filed PR 112104 for that.

Basically vectorizing this loop is a waste compared to that.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (2 preceding siblings ...)
  2023-10-27  3:48 ` pinskia at gcc dot gnu.org
@ 2023-10-27  3:59 ` pinskia at gcc dot gnu.org
  2023-10-27  4:01 ` pinskia at gcc dot gnu.org
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-27  3:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Is there a non-reduced testcase here? Or does the loop really just do j = j^1 ?

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (3 preceding siblings ...)
  2023-10-27  3:59 ` pinskia at gcc dot gnu.org
@ 2023-10-27  4:01 ` pinskia at gcc dot gnu.org
  2023-10-27  5:08 ` crazylht at gmail dot com
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-27  4:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Oh this is the original code:
https://github.com/kdlucas/byte-unixbench/blob/master/UnixBench/src/whets.c


HEHEHEHEHEHEHEHEH. Basically after optimizing:

  _9 = j_19 != 1;
  _14 = (long int) _9;

Over to:
_14 = j_19 ^ 1;

We could optimize this whole loop out.

Note this is a bad benchmark.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (4 preceding siblings ...)
  2023-10-27  4:01 ` pinskia at gcc dot gnu.org
@ 2023-10-27  5:08 ` crazylht at gmail dot com
  2023-10-27  5:17 ` crazylht at gmail dot com
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: crazylht at gmail dot com @ 2023-10-27  5:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Andrew Pinski from comment #5)
> Oh this is the original code:
> https://github.com/kdlucas/byte-unixbench/blob/master/UnixBench/src/whets.c
> 
Yes, it's from unixbench.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (5 preceding siblings ...)
  2023-10-27  5:08 ` crazylht at gmail dot com
@ 2023-10-27  5:17 ` crazylht at gmail dot com
  2023-10-27  6:08 ` pinskia at gcc dot gnu.org
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: crazylht at gmail dot com @ 2023-10-27  5:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> First off does this even make sense to vectorize but rather do some kind of
> scalar reduction with respect to j = j^1 here  .  Filed PR 112104 for that.
> 
> Basically vectorizing this loop is a waste compared to that.

Yes, it's always zero, it would be nice if the middle end can optimize the
whole loop off. So for this PR, it's more related to the misoptimization of the
redundant loop(better finalize the induction variable with a simple
assignment), not vectorization.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (6 preceding siblings ...)
  2023-10-27  5:17 ` crazylht at gmail dot com
@ 2023-10-27  6:08 ` pinskia at gcc dot gnu.org
  2023-10-27  6:11 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-27  6:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
These should work:

(simplify
 (convert (eq one_zero_valued_p@1 one_zero_valued_p@2))
 (if (types_match (type, TREE_TYPE (@1)))
  (bit_xor @1 (bit_xor! @2 { build_one_cst (type); }))))

(simplify
 (convert (ne one_zero_valued_p@1 one_zero_valued_p@2))
 (if (types_match (type, TREE_TYPE (@1)))
  (bit_xor @1 @2})))


Will test tomorrow.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (7 preceding siblings ...)
  2023-10-27  6:08 ` pinskia at gcc dot gnu.org
@ 2023-10-27  6:11 ` pinskia at gcc dot gnu.org
  2023-10-27 12:38 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-27  6:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #8)
> These should work:
> 
> (simplify
>  (convert (eq one_zero_valued_p@1 one_zero_valued_p@2))
>  (if (types_match (type, TREE_TYPE (@1)))
>   (bit_xor @1 (bit_xor! @2 { build_one_cst (type); }))))
> 
> (simplify
>  (convert (ne one_zero_valued_p@1 one_zero_valued_p@2))
>  (if (types_match (type, TREE_TYPE (@1)))
>   (bit_xor @1 @2})))
> 
> 
> Will test tomorrow.

Maybe we don't need the types_match either ...
But then we need a convert. That would fix PR 110637 too.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (8 preceding siblings ...)
  2023-10-27  6:11 ` pinskia at gcc dot gnu.org
@ 2023-10-27 12:38 ` rguenth at gcc dot gnu.org
  2023-11-14  1:28 ` cvs-commit at gcc dot gnu.org
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-27 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
  # j_19 = PHI <_14(8), j_22(5)>
  _9 = j_19 != 1;
  _14 = (long int) _9;

so the vectorizer interesting thing is whether we can handle (equality)
compares the same as other associative operations (apart from the
involved cast).  Now the above isn't canonical, j_19 ^ 1 was though.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (9 preceding siblings ...)
  2023-10-27 12:38 ` rguenth at gcc dot gnu.org
@ 2023-11-14  1:28 ` cvs-commit at gcc dot gnu.org
  2023-11-21  1:00 ` liuhongt at gcc dot gnu.org
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-14  1:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

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

commit r14-5428-gfd1596f9962569afff6c9298a7c79686c6950bef
Author: liuhongt <hongtao.liu@intel.com>
Date:   Mon Oct 30 15:43:48 2023 +0800

    Handle bitop with INTEGER_CST in analyze_and_compute_bitop_with_inv_effect.

    analyze_and_compute_bitop_with_inv_effect assumes the first operand is
    loop invariant which is not the case when it's INTEGER_CST.

    gcc/ChangeLog:

            PR tree-optimization/105735
            PR tree-optimization/111972
            * tree-scalar-evolution.cc
            (analyze_and_compute_bitop_with_inv_effect): Handle bitop with
            INTEGER_CST.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr105735-3.c: New test.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (10 preceding siblings ...)
  2023-11-14  1:28 ` cvs-commit at gcc dot gnu.org
@ 2023-11-21  1:00 ` liuhongt at gcc dot gnu.org
  2023-11-21  1:12 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2023-11-21  1:00 UTC (permalink / raw)
  To: gcc-bugs

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

liuhongt at gcc dot gnu.org changed:

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

--- Comment #12 from liuhongt at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #8)
> These should work:
> 
> (simplify
>  (convert (eq one_zero_valued_p@1 one_zero_valued_p@2))
>  (if (types_match (type, TREE_TYPE (@1)))
>   (bit_xor @1 (bit_xor! @2 { build_one_cst (type); }))))
> 
> (simplify
>  (convert (ne one_zero_valued_p@1 one_zero_valued_p@2))
>  (if (types_match (type, TREE_TYPE (@1)))
>   (bit_xor @1 @2})))
> 
> 
> Will test tomorrow.

Is there any progress for this?

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (11 preceding siblings ...)
  2023-11-21  1:00 ` liuhongt at gcc dot gnu.org
@ 2023-11-21  1:12 ` pinskia at gcc dot gnu.org
  2023-11-21  2:48 ` liuhongt at gcc dot gnu.org
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-21  1:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to liuhongt from comment #12)
> 
> Is there any progress for this?

I have a patch ready to post for this but since I changed employement a few
weeks ago, I have to clear legal requirements still. It is a holiday week in
the US this week too which partly blocks that too. I should be able to submit
it the week after next.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (12 preceding siblings ...)
  2023-11-21  1:12 ` pinskia at gcc dot gnu.org
@ 2023-11-21  2:48 ` liuhongt at gcc dot gnu.org
  2023-12-02  6:38 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2023-11-21  2:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from liuhongt at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #13)
> (In reply to liuhongt from comment #12)
> > 
> > Is there any progress for this?
> 
> I have a patch ready to post for this but since I changed employement a few
> weeks ago, I have to clear legal requirements still. It is a holiday week in
> the US this week too which partly blocks that too. I should be able to
> submit it the week after next.

Thanks, Happy Thanksgiving to you.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (13 preceding siblings ...)
  2023-11-21  2:48 ` liuhongt at gcc dot gnu.org
@ 2023-12-02  6:38 ` pinskia at gcc dot gnu.org
  2023-12-04 17:31 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-02  6:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch set finally posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-December/639019.html

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (14 preceding siblings ...)
  2023-12-02  6:38 ` pinskia at gcc dot gnu.org
@ 2023-12-04 17:31 ` cvs-commit at gcc dot gnu.org
  2023-12-10 20:04 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-04 17:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:886f256ce3be4aa85f30af88558f0dfcb8003300

commit r14-6126-g886f256ce3be4aa85f30af88558f0dfcb8003300
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date:   Sat Nov 11 20:33:28 2023 -0800

    MATCH: Fix zero_one_valued_p's convert pattern

    While working on PR 111972, I was getting a regression
    due to zero_one_valued_p matching a signed 1 bit integer
    when it came to convert. This patch fixes that by checking
    the outer type too.

    Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    gcc/ChangeLog:

            * match.pd (zero_one_valued_p): For convert
            make sure type is not a signed 1-bit integer.

    Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (15 preceding siblings ...)
  2023-12-04 17:31 ` cvs-commit at gcc dot gnu.org
@ 2023-12-10 20:04 ` pinskia at gcc dot gnu.org
  2023-12-11 15:56 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-10 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2023-Decembe
                   |                            |r/640064.html

--- Comment #17 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Updated patch set:
https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640064.html

The first patch of the original patch set was applied.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (16 preceding siblings ...)
  2023-12-10 20:04 ` pinskia at gcc dot gnu.org
@ 2023-12-11 15:56 ` cvs-commit at gcc dot gnu.org
  2023-12-11 15:57 ` pinskia at gcc dot gnu.org
  2023-12-12  2:58 ` liuhongt at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-11 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:85c5efcffed19ca6160eeecc2d4faebd9fee63aa

commit r14-6420-g85c5efcffed19ca6160eeecc2d4faebd9fee63aa
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date:   Sat Nov 11 15:54:10 2023 -0800

    MATCH: (convert)(zero_one !=/== 0/1) for outer type and zero_one type are
the same

    When I moved two_value to match.pd, I removed the check for the {0,+-1}
    as I had placed it after the {0,+-1} case for cond in match.pd.
    In the case of {0,+-1} and non boolean, before we would optmize those
    case to just `(convert)a` but after we would get `(convert)(a != 0)`
    which was not handled anyways to just `(convert)a`.
    So this adds a pattern to match `(convert)(zeroone != 0)` and simplify
    to `(convert)zeroone`.

    Also this optimizes (convert)(zeroone == 0) into (zeroone^1) if the
    type match. Removing the opposite transformation from fold.
    The opposite transformation was added with
    https://gcc.gnu.org/pipermail/gcc-patches/2006-February/190514.html
    It is no longer considered the canonicalization either, even VRP will
    transform it back into `(~a) & 1` so removing it is a good idea.

    Note the testcase pr69270.c needed a slight update due to not matching
    exactly a scan pattern, this update makes it more robust and will match
    before and afterwards and if there are other changes in this area too.

    Note the testcase gcc.target/i386/pr110790-2.c needs a slight update
    for better code generation in LP64 bit mode.

    Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    gcc/ChangeLog:

            PR tree-optimization/111972
            PR tree-optimization/110637
            * match.pd (`(convert)(zeroone !=/== CST)`): Match
            and simplify to ((convert)zeroone){,^1}.
            * fold-const.cc (fold_binary_loc): Remove
            transformation of `(~a) & 1` and `(a ^ 1) & 1`
            into `(convert)(a == 0)`.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr110637-1.c: New test.
            * gcc.dg/tree-ssa/pr110637-2.c: New test.
            * gcc.dg/tree-ssa/pr110637-3.c: New test.
            * gcc.dg/tree-ssa/pr111972-1.c: New test.
            * gcc.dg/tree-ssa/pr69270.c: Update testcase.
            * gcc.target/i386/pr110790-2.c: Update testcase.
            * gcc.dg/fold-even-1.c: Removed.

    Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (17 preceding siblings ...)
  2023-12-11 15:56 ` cvs-commit at gcc dot gnu.org
@ 2023-12-11 15:57 ` pinskia at gcc dot gnu.org
  2023-12-12  2:58 ` liuhongt at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-11 15:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #19 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

* [Bug tree-optimization/111972] [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a;
  2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
                   ` (18 preceding siblings ...)
  2023-12-11 15:57 ` pinskia at gcc dot gnu.org
@ 2023-12-12  2:58 ` liuhongt at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2023-12-12  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #19)
> Fixed.

Thanks.

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

end of thread, other threads:[~2023-12-12  2:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25  8:14 [Bug middle-end/111972] New: [14 regression] missed vectorzation for bool a = j != 1; j = (long int)a; crazylht at gmail dot com
2023-10-25  9:29 ` [Bug tree-optimization/111972] " crazylht at gmail dot com
2023-10-25 16:46 ` pinskia at gcc dot gnu.org
2023-10-27  3:48 ` pinskia at gcc dot gnu.org
2023-10-27  3:59 ` pinskia at gcc dot gnu.org
2023-10-27  4:01 ` pinskia at gcc dot gnu.org
2023-10-27  5:08 ` crazylht at gmail dot com
2023-10-27  5:17 ` crazylht at gmail dot com
2023-10-27  6:08 ` pinskia at gcc dot gnu.org
2023-10-27  6:11 ` pinskia at gcc dot gnu.org
2023-10-27 12:38 ` rguenth at gcc dot gnu.org
2023-11-14  1:28 ` cvs-commit at gcc dot gnu.org
2023-11-21  1:00 ` liuhongt at gcc dot gnu.org
2023-11-21  1:12 ` pinskia at gcc dot gnu.org
2023-11-21  2:48 ` liuhongt at gcc dot gnu.org
2023-12-02  6:38 ` pinskia at gcc dot gnu.org
2023-12-04 17:31 ` cvs-commit at gcc dot gnu.org
2023-12-10 20:04 ` pinskia at gcc dot gnu.org
2023-12-11 15:56 ` cvs-commit at gcc dot gnu.org
2023-12-11 15:57 ` pinskia at gcc dot gnu.org
2023-12-12  2:58 ` liuhongt 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).