public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/97872] New: Missed optimization for less-than comparison on vectors
@ 2020-11-17 7:49 prathamesh3492 at gcc dot gnu.org
2020-11-17 15:37 ` [Bug target/97872] [ARM NEON] " rguenth at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: prathamesh3492 at gcc dot gnu.org @ 2020-11-17 7:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97872
Bug ID: 97872
Summary: Missed optimization for less-than comparison on
vectors
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: prathamesh3492 at gcc dot gnu.org
Target Milestone: ---
Hi,
For the following test-case:
#include <arm_neon.h>
uint8x8_t f1(int8x8_t a, int8x8_t b) {
return a < b;
}
uint8x8_t f2(int8x8_t a, int8x8_t b) {
return vclt_s8 (a, b);
}
Code-gen for f2 uses vcgt insn
f2:
vcgt.s8 d0, d1, d0
bx lr
However code-gen for f1 results in:
f1:
vmov.i32 d16, #0xffffffff @ v8qi
vmov.i32 d17, #0 @ v8qi
vcgt.s8 d0, d1, d0
vbsl d0, d16, d17
bx lr
which IIUC is redundant, since vcgt will set all-ones, or all-zeros in d0
depending on the comparison.
The reason this happens is because vclt_s8 uses __builtin_neon_vcgtv8qi that
emits vcgt.s8, while f1 is lowered to using VCOND in optimized dump:
f1 (int8x8_t a, int8x8_t b)
{
vector(8) signed char _2;
uint8x8_t _5;
<bb 2> [local count: 1073741824]:
_2 = .VCOND (a_3(D), b_4(D), { -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 0, 0,
0, 0, 0, 0, 0 }, 107);
_5 = VIEW_CONVERT_EXPR<uint8x8_t>(_2);
return _5;
}
and correspondingly expanded to:
;; _2 = .VCOND (a_3(D), b_4(D), { -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 0, 0,
0, 0, 0, 0, 0 }, 107);
(insn 7 6 8 (set (reg:V8QI 117)
(const_vector:V8QI [
(const_int -1 [0xffffffffffffffff]) repeated x8
])) "foo.c":4:12 -1
(nil))
(insn 8 7 9 (set (reg:V8QI 118)
(const_vector:V8QI [
(const_int 0 [0]) repeated x8
])) "foo.c":4:12 -1
(nil))
(insn 9 8 10 (set (reg:V8QI 119)
(neg:V8QI (gt:V8QI (reg/v:V8QI 116 [ b ])
(reg/v:V8QI 115 [ a ])))) "foo.c":4:12 -1
(nil))
(insn 10 9 0 (set (reg:V8QI 113 [ _2 ])
(unspec:V8QI [
(reg:V8QI 119)
(reg:V8QI 117)
(reg:V8QI 118)
] UNSPEC_VBSL)) "foo.c":4:12 -1
(nil))
Thanks,
Prathamesh
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/97872] [ARM NEON] Missed optimization for less-than comparison on vectors
2020-11-17 7:49 [Bug target/97872] New: Missed optimization for less-than comparison on vectors prathamesh3492 at gcc dot gnu.org
@ 2020-11-17 15:37 ` rguenth at gcc dot gnu.org
2020-12-08 9:01 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-17 15:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97872
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-11-17
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
So arm doesn't have a vec_cmp pattern that applies here? Before ISEL we have
vector(8) <signed-boolean:8> _1;
vector(8) signed char _2;
uint8x8_t _5;
<bb 2> [local count: 1073741824]:
_1 = a_3(D) < b_4(D);
_2 = VEC_COND_EXPR <_1, { -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 0, 0, 0, 0,
0, 0, 0 }>;
_5 = VIEW_CONVERT_EXPR<uint8x8_t>(_2);
return _5;
and ISEL should be able to directly expand a_3(D) < b_4(D) via .VEC_CMP
Alternatively the backend should optimize vcond expansion when the
operands are all ones/zeros.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/97872] [ARM NEON] Missed optimization for less-than comparison on vectors
2020-11-17 7:49 [Bug target/97872] New: Missed optimization for less-than comparison on vectors prathamesh3492 at gcc dot gnu.org
2020-11-17 15:37 ` [Bug target/97872] [ARM NEON] " rguenth at gcc dot gnu.org
@ 2020-12-08 9:01 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-08 9:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97872
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Prathamesh Kulkarni
<prathamesh3492@gcc.gnu.org>:
https://gcc.gnu.org/g:3a6e3ad38a17a03ee0139b49a0946e7b9ded1eb1
commit r11-5839-g3a6e3ad38a17a03ee0139b49a0946e7b9ded1eb1
Author: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Date: Tue Dec 8 14:30:04 2020 +0530
gimple-isel: Fold x CMP y ? -1 : 0 to x CMP y [PR97872]
gcc/
2020-12-08 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR target/97872
* gimple-isel.cc (gimple_expand_vec_cond_expr): Try to fold
x CMP y ? -1 : 0 to x CMP y.
gcc/testsuite/
2020-12-08 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR target/97872
* gcc.target/arm/pr97872.c: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/97872] [ARM NEON] Missed optimization for less-than comparison on vectors
2020-11-17 7:49 [Bug target/97872] New: Missed optimization for less-than comparison on vectors prathamesh3492 at gcc dot gnu.org
2020-11-17 15:37 ` [Bug target/97872] [ARM NEON] " rguenth at gcc dot gnu.org
2020-12-08 9:01 ` cvs-commit at gcc dot gnu.org
@ 2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-04 12:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97872
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-04 12:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 7:49 [Bug target/97872] New: Missed optimization for less-than comparison on vectors prathamesh3492 at gcc dot gnu.org
2020-11-17 15:37 ` [Bug target/97872] [ARM NEON] " rguenth at gcc dot gnu.org
2020-12-08 9:01 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:31 ` rguenth 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).