[Bug rtl-optimization/82356] auto-vectorizing pack of 16->8 has a redundant AND after a shift

2021-08-24 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82356

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed|2021-08-14 00:00:00 |2021-8-24

--- Comment #2 from Andrew Pinski  ---
With -O3 -fno-move-loop-invariants  -fno-gcse 
We get
Trying 38, 34 -> 39:
   38: r160:V8HI=[`*.LC0']
  REG_EQUAL const_vector
   34: r154:V8HI=r153:V8HI 0>>0x8
  REG_DEAD r153:V8HI
   39: r158:V8HI=r160:V8HI:V8HI
  REG_DEAD r154:V8HI
Failed to match this instruction:
(parallel [
(set (reg:V8HI 158)
(and:V8HI (lshiftrt:V8HI (reg:V8HI 153 [ vect__1.12 ])
(const_int 8 [0x8]))
(const_vector:V8HI [
(const_int 255 [0xff]) repeated x8
])))
(set (reg:V8HI 160)
(mem/u/c:V8HI (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0  S16
A128]))
])
Failed to match this instruction:
(parallel [
(set (reg:V8HI 158)
(and:V8HI (lshiftrt:V8HI (reg:V8HI 153 [ vect__1.12 ])
(const_int 8 [0x8]))
(const_vector:V8HI [
(const_int 255 [0xff]) repeated x8
])))
(set (reg:V8HI 160)
(mem/u/c:V8HI (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0  S16
A128]))
])
Successfully matched this instruction:
(set (reg:V8HI 160)
(mem/u/c:V8HI (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0  S16 A128]))
Failed to match this instruction:
(set (reg:V8HI 158)
(and:V8HI (lshiftrt:V8HI (reg:V8HI 153 [ vect__1.12 ])
(const_int 8 [0x8]))
(const_vector:V8HI [
(const_int 255 [0xff]) repeated x8
])))

Which we don't recongize the and part is not needed.

Also since we don't emit REG_EQUAL when using vector_csts, we needed to use
"-fno-move-loop-invariants  -fno-gcse ".

[Bug rtl-optimization/82356] auto-vectorizing pack of 16->8 has a redundant AND after a shift

2021-08-14 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82356

Andrew Pinski  changed:

   What|Removed |Added

  Component|tree-optimization   |rtl-optimization
   Severity|normal  |enhancement
   Last reconfirmed|2017-09-29 00:00:00 |2021-8-14

[Bug rtl-optimization/82356] auto-vectorizing pack of 16->8 has a redundant AND after a shift

2017-09-29 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82356

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-09-29
  Component|tree-optimization   |rtl-optimization
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
The vectorizer itself just emits

   [81.00%]:
  # ivtmp.30_143 = PHI <0(12), ivtmp.30_144(13)>
  # ivtmp.35_145 = PHI <0(12), ivtmp.35_146(13)>
  vect__1.15_75 = MEM[base: vectp_src.14_71, index: ivtmp.35_145, step: 2,
offset: 0B];
  vect__1.16_77 = MEM[base: vectp_src.14_71, index: ivtmp.35_145, step: 2,
offset: 16B];
  vect__2.17_78 = vect__1.15_75 >> 8;
  vect__2.17_79 = vect__1.16_77 >> 8;
  vect__3.18_80 = VEC_PACK_TRUNC_EXPR ;
  MEM[base: vectp_dst.20_81, index: ivtmp.35_145, offset: 0B] = vect__3.18_80;
  ivtmp.30_144 = ivtmp.30_143 + 1;
  ivtmp.35_146 = ivtmp.35_145 + 16;
  if (bnd.9_65 > ivtmp.30_144)
goto ; [83.34%]

it seems the ands come from VEC_PAC_TRUNC_EXPR expansion somehow.

(insn 150 149 151 (set (reg:V8HI 219)
(and:V8HI (reg:V8HI 221)
(reg:V8HI 214 [ vect__2.17 ]))) "t.c":5 -1
 (nil))

(insn 151 150 152 (set (reg:V8HI 220)
(and:V8HI (reg:V8HI 221)
(reg:V8HI 216 [ vect__2.17 ]))) "t.c":5 -1
 (nil))

(insn 152 151 153 (set (reg:V16QI 218 [ vect__3.18 ])
(vec_concat:V16QI (us_truncate:V8QI (reg:V8HI 219))
(us_truncate:V8QI (reg:V8HI 220 "t.c":5 -1
 (nil))

and combine / simplify-rtx are not able to remove them again (no wonders,
simplify-rtx is notoriously unaware of vectors).