* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
@ 2022-02-05 23:25 ` pinskia at gcc dot gnu.org
2022-02-05 23:28 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-05 23:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
2022-02-05 23:25 ` [Bug target/104401] " pinskia at gcc dot gnu.org
@ 2022-02-05 23:28 ` pinskia at gcc dot gnu.org
2022-02-07 6:51 ` crazylht at gmail dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-05 23:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-02-05
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(set (reg:V16QI 93)
(unspec:V16QI [
(subreg:V16QI (reg/v:V2DI 92 [ input ]) 0)
(subreg:V16QI (reg/v:V2DI 91 [ value ]) 0)
(subreg:V16QI (gt:V4SI (subreg:V4SI (reg/v:V2DI 92 [ input ]) 0)
(subreg:V4SI (reg/v:V2DI 91 [ value ]) 0)) 0)
] UNSPEC_BLENDV))
blend uses unspec which makes this a little harder
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
2022-02-05 23:25 ` [Bug target/104401] " pinskia at gcc dot gnu.org
2022-02-05 23:28 ` pinskia at gcc dot gnu.org
@ 2022-02-07 6:51 ` crazylht at gmail dot com
2022-02-07 6:57 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: crazylht at gmail dot com @ 2022-02-07 6:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
--- Comment #2 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> (set (reg:V16QI 93)
> (unspec:V16QI [
> (subreg:V16QI (reg/v:V2DI 92 [ input ]) 0)
> (subreg:V16QI (reg/v:V2DI 91 [ value ]) 0)
> (subreg:V16QI (gt:V4SI (subreg:V4SI (reg/v:V2DI 92 [ input ]) 0)
> (subreg:V4SI (reg/v:V2DI 91 [ value ]) 0)) 0)
> ] UNSPEC_BLENDV))
>
> blend uses unspec which makes this a little harder
I think it could be done in gimple level.
18 _10 = VIEW_CONVERT_EXPR<vector(4) int>(value_2(D));
19 _11 = VIEW_CONVERT_EXPR<vector(4) int>(input_3(D));
20 _12 = _10 < _11;
21 _13 = VIEW_CONVERT_EXPR<vector(4) int>(_12);
22 _5 = VIEW_CONVERT_EXPR<vector(16) char>(_13);
23 _4 = VIEW_CONVERT_EXPR<vector(16) char>(value_2(D));
24 _6 = VIEW_CONVERT_EXPR<vector(16) char>(input_3(D));
25 _8 = .VCOND (_5, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, _4,
_6, 108);
26 _9 = VIEW_CONVERT_EXPR<__m128i>(_8);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
` (2 preceding siblings ...)
2022-02-07 6:51 ` crazylht at gmail dot com
@ 2022-02-07 6:57 ` pinskia at gcc dot gnu.org
2022-02-07 7:11 ` crazylht at gmail dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-07 6:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
On a slightly different subject, I wish VCOND would print out the tree code
symbolically rather than just a number. It would be easier to understand what
the condition exec is really.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
` (3 preceding siblings ...)
2022-02-07 6:57 ` pinskia at gcc dot gnu.org
@ 2022-02-07 7:11 ` crazylht at gmail dot com
2022-02-07 7:59 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: crazylht at gmail dot com @ 2022-02-07 7:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> On a slightly different subject, I wish VCOND would print out the tree code
> symbolically rather than just a number. It would be easier to understand
> what the condition exec is really.
Yes, not quite straightforward.
Here it means
_8 = _5 < { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ? _4 : _6;
(blendv uses sign bit as mask bit).
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
` (4 preceding siblings ...)
2022-02-07 7:11 ` crazylht at gmail dot com
@ 2022-02-07 7:59 ` rguenth at gcc dot gnu.org
2023-12-18 9:27 ` liuhongt at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-07 7:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> On a slightly different subject, I wish VCOND would print out the tree code
> symbolically rather than just a number. It would be easier to understand
> what the condition exec is really.
Feel free to add a // comment after it ;)
Btw, forwprop1 sees
<bb 2> :
_12 = VIEW_CONVERT_EXPR<vector(4) int>(value_3(D));
_13 = VIEW_CONVERT_EXPR<vector(4) int>(input_4(D));
_14 = _12 < _13;
_15 = VEC_COND_EXPR <_14, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>;
_16 = VIEW_CONVERT_EXPR<__m128i>(_15);
_6 = VIEW_CONVERT_EXPR<vector(16) char>(_15);
_5 = VIEW_CONVERT_EXPR<vector(16) char>(value_3(D));
_8 = VIEW_CONVERT_EXPR<vector(16) char>(input_4(D));
_9 = _6 < { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
_10 = VEC_COND_EXPR <_9, _5, _8>;
_11 = VIEW_CONVERT_EXPR<__m128i>(_10);
return _11;
the difficulty #1 is the v16qi mode blend vs. the v4si mode compare so
we'd have to pattern match the blend to be done on v4si based on the
_15 value range.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
` (5 preceding siblings ...)
2022-02-07 7:59 ` rguenth at gcc dot gnu.org
@ 2023-12-18 9:27 ` liuhongt at gcc dot gnu.org
2024-01-11 1:20 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2023-12-18 9:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
Hongtao Liu <liuhongt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |liuhongt at gcc dot gnu.org
--- Comment #6 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
On latest trunk, we have
19 <bb 2> [local count: 1073741824]:
20 _6 = VIEW_CONVERT_EXPR<vector(4) int>(value_2(D));
21 _7 = VIEW_CONVERT_EXPR<vector(4) int>(input_3(D));
22 _8 = _6 < _7;
23 _4 = VEC_COND_EXPR <_8, _6, _7>;
24 _5 = VIEW_CONVERT_EXPR<vector(2) long long int>(_4);
25 return _5;
26
27}
And we can match a < b ? a : b for vector modes.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
` (6 preceding siblings ...)
2023-12-18 9:27 ` liuhongt at gcc dot gnu.org
@ 2024-01-11 1:20 ` cvs-commit at gcc dot gnu.org
2024-01-11 1:21 ` liuhongt at gcc dot gnu.org
2024-01-20 17:18 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-11 1:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
--- Comment #7 from GCC 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:6686e16fda419067b91614835dd743ebb82717ea
commit r14-7124-g6686e16fda419067b91614835dd743ebb82717ea
Author: liuhongt <hongtao.liu@intel.com>
Date: Tue Dec 19 10:39:06 2023 +0800
Optimize A < B ? A : B to MIN_EXPR.
Similar for A < B ? B : A to MAX_EXPR.
There're codes in the frontend to optimize such pattern but failed to
handle testcase in the PR since it's exposed at gimple level when
folding backend builtins.
pr95906 now can be optimized to MAX_EXPR as it's commented in the
testcase.
// FIXME: this should further optimize to a MAX_EXPR
typedef signed char v16i8 __attribute__((vector_size(16)));
v16i8 f(v16i8 a, v16i8 b)
gcc/ChangeLog:
PR target/104401
* match.pd (VEC_COND_EXPR: A < B ? A : B -> MIN_EXPR): New patten
match.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr104401.c: New test.
* gcc.dg/tree-ssa/pr95906.c: Adjust testcase.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
` (7 preceding siblings ...)
2024-01-11 1:20 ` cvs-commit at gcc dot gnu.org
@ 2024-01-11 1:21 ` liuhongt at gcc dot gnu.org
2024-01-20 17:18 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-01-11 1:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
Hongtao Liu <liuhongt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #8 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
Fixed in GCC14.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/104401] [x86] Failure to recognize min/max pattern using pcmp+pblendv
2022-02-05 21:32 [Bug target/104401] New: [x86] Failure to recognize min/max pattern using pcmp+pblendv gabravier at gmail dot com
` (8 preceding siblings ...)
2024-01-11 1:21 ` liuhongt at gcc dot gnu.org
@ 2024-01-20 17:18 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-20 17:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104401
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 11+ messages in thread