[Bug target/93183] SVE does not use neg as conditional
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93183 rsandifo at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #6 from rsandifo at gcc dot gnu.org --- Fixed.
[Bug target/93183] SVE does not use neg as conditional
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93183 --- Comment #5 from CVS Commits --- The master branch has been updated by Prathamesh Kulkarni : https://gcc.gnu.org/g:6b4c18b98127087d7f14062b81bc678f0589cd36 commit r12-4493-g6b4c18b98127087d7f14062b81bc678f0589cd36 Author: prathamesh.kulkarni Date: Tue Oct 19 13:51:51 2021 +0530 [sve] PR93183 - Add support for conditional neg. gcc/testsuite/ChangeLog: PR target/93183 * gcc.target/aarch64/sve/pr93183.c: Remove -mcpu=generic+sve from dg-options.
[Bug target/93183] SVE does not use neg as conditional
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93183 --- Comment #4 from CVS Commits --- The master branch has been updated by Prathamesh Kulkarni : https://gcc.gnu.org/g:20dcda98ed376cb61c74b2c71656f99c671ec9ce commit r12-4470-g20dcda98ed376cb61c74b2c71656f99c671ec9ce Author: prathamesh.kulkarni Date: Mon Oct 18 15:44:06 2021 +0530 [sve] PR93183 - Add support for conditional neg. gcc/ChangeLog: PR target/93183 * gimple-match-head.c (try_conditional_simplification): Add case for single operand. * internal-fn.def: Add entry for COND_NEG internal function. * internal-fn.c (FOR_EACH_CODE_MAPPING): Add entry for NEGATE_EXPR, COND_NEG mapping. * optabs.def: Add entry for cond_neg_optab. * match.pd (UNCOND_UNARY, COND_UNARY): New operator lists. (vec_cond COND (foo A) B) -> (IFN_COND_FOO COND A B): New pattern. (vec_cond COND B (foo A)) -> (IFN_COND_FOO ~COND A B): Likewise. gcc/testsuite/ChangeLog: PR target/93183 * gcc.target/aarch64/sve/cond_unary_4.c: Adjust. * gcc.target/aarch64/sve/pr93183.c: New test.
[Bug target/93183] SVE does not use neg as conditional
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93183 --- Comment #3 from prathamesh3492 at gcc dot gnu.org --- (In reply to rsand...@gcc.gnu.org from comment #2) > (In reply to Andrew Pinski from comment #1) > > We get: > > .L3: > > ld1bz0.b, p0/z, [x1, x3] > > movprfx z2, z0 > > and z2.b, z2.b, #0xc0 > > neg z1.b, p1/m, z0.b ;;; THIS > > cmpeq p2.b, p1/z, z2.b, #0 > > sel z0.b, p2, z0.b, z1.b AND THIS > > st1bz0.b, p0, [x0, x3] > > incbx3 > > whilelo p0.b, w3, w2 > > b.any .L3 > > > > The two instructions marked should be combined. > > The problem is that it isn't a straight combination of the > NEG and SEL, because the condition is the inverse of the one > that we want for predication. IIUC, sel is redundant and we could generate following code instead for the inner loop ? ld1bz0.b, p0/z, [x1, x2] movprfx z2, z0 and z2.b, z2.b, #0xc0 cmpne p2.b, p1/z, z2.b, #0 neg z0.b, p2/m, z0.b st1bz0.b, p0, [x0, x3] incbx3 whilelo p0.b, w3, w2 b.any .L3 > > This is one of the things that the IFN_COND_* functions were > designed to fix. We should probably add unary versions of those. The input to isel pass is: vect__3.11_39 = .MASK_LOAD (_22, 8B, loop_mask_38); vect_t1_15.12_41 = vect__3.11_39 & { 192, ... }; vect_t_12.13_42 = -vect__3.11_39; _44 = vect_t1_15.12_41 == { 0, ... }; vect_iftmp.14_45 = VEC_COND_EXPR <_44, vect__3.11_39, vect_t_12.13_42>; where vect__3.11_39 and vect_t_12.13_42 are negatives of each other. I suppose in isel pass if we come across vec_cond_expr of the form: op2 = vec_cond_expr then we could lower it to a new internal function say IFN_COND_NEG. IFN_COND_NEG could use a new optab say cond_neg_optab to expand it to: movprfx op2, op1 set predicate according to inverted cond op2 = predicate/m neg op2 Does this look reasonable ? Thanks, Prathamesh
[Bug target/93183] SVE does not use neg as conditional
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93183 Richard Biener changed: What|Removed |Added Status|NEW |ASSIGNED
[Bug target/93183] SVE does not use neg as conditional
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93183 rsandifo at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2020-01-07 CC||rsandifo at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from rsandifo at gcc dot gnu.org --- (In reply to Andrew Pinski from comment #1) > We get: > .L3: > ld1bz0.b, p0/z, [x1, x3] > movprfx z2, z0 > and z2.b, z2.b, #0xc0 > neg z1.b, p1/m, z0.b ;;; THIS > cmpeq p2.b, p1/z, z2.b, #0 > sel z0.b, p2, z0.b, z1.b AND THIS > st1bz0.b, p0, [x0, x3] > incbx3 > whilelo p0.b, w3, w2 > b.any .L3 > > The two instructions marked should be combined. The problem is that it isn't a straight combination of the NEG and SEL, because the condition is the inverse of the one that we want for predication. This is one of the things that the IFN_COND_* functions were designed to fix. We should probably add unary versions of those.
[Bug target/93183] SVE does not use neg as conditional
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93183 Andrew Pinski changed: What|Removed |Added Blocks||26163, 53947 Summary|SVE only makes the last |SVE does not use neg as |thing conditional with |conditional |ifconversion| --- Comment #1 from Andrew Pinski --- Actually it looks more like conditional neg does not work. Take: typedef unsigned char uint8_t; static inline uint8_t x264_clip_uint8( uint8_t x ) { uint8_t t = -x; uint8_t t1 = x&(~63); return t1 ? t : x; } void mc_weight( uint8_t *__restrict dst, uint8_t *__restrict src, int n) { for( int x = 0; x < n*16; x++ ) dst[x] = x264_clip_uint8(src[x]); } --- CUT --- We get: .L3: ld1bz0.b, p0/z, [x1, x3] movprfx z2, z0 and z2.b, z2.b, #0xc0 neg z1.b, p1/m, z0.b ;;; THIS cmpeq p2.b, p1/z, z2.b, #0 sel z0.b, p2, z0.b, z1.b AND THIS st1bz0.b, p0, [x0, x3] incbx3 whilelo p0.b, w3, w2 b.any .L3 The two instructions marked should be combined. NOTE this does show up in real code in SPEC CPU, see PR 92492. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26163 [Bug 26163] [meta-bug] missed optimization in SPEC (2k17, 2k and 2k6 and 95) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations