https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119114
--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
;; _302 = .VEC_EXTRACT (mask__87.22_296, 0);
(insn 198 197 199 (set (reg:DI 332)
(unspec:DI [
(const_int 16 [0x10])
] UNSPEC_VLMAX)) -1
(nil))
(insn 199 198 200 (set (reg:RVVMF2QI 331)
(if_then_else:RVVMF2QI (unspec:RVVMF16BI [
(const_vector:RVVMF16BI [
(const_int 1 [0x1]) repeated x8
])
(reg:DI 332)
(const_int 2 [0x2]) repeated x2
(const_int 1 [0x1])
(reg:SI 66 vl)
(reg:SI 67 vtype)
] UNSPEC_VPREDICATE)
(const_vector:RVVMF2QI [
(const_int 0 [0]) repeated x8
])
(unspec:RVVMF2QI [
(reg:DI 0 zero)
] UNSPEC_VUNDEF))) -1
(expr_list:REG_EQUAL (const_vector:RVVMF2QI [
(const_int 0 [0]) repeated x8
])
(nil)))
// 0/undef
(insn 200 199 201 (set (reg:DI 333)
(unspec:DI [
(const_int 16 [0x10])
] UNSPEC_VLMAX)) -1
(nil))
(insn 201 200 202 (set (reg:RVVMF2QI 331)
(if_then_else:RVVMF2QI (unspec:RVVMF16BI [
(reg:DI 333)
(const_int 2 [0x2])
(const_int 1 [0x1])
(reg:SI 66 vl)
(reg:SI 67 vtype)
] UNSPEC_VPREDICATE)
(vec_merge:RVVMF2QI (const_vector:RVVMF2QI [
(const_int 1 [0x1]) repeated x8
])
(reg:RVVMF2QI 331)
(reg:RVVMF16BI 192 [ mask__87.22D.2859 ]))
(unspec:RVVMF2QI [
(reg:DI 0 zero)
] UNSPEC_VUNDEF))) -1
(nil))
// 1/merged in from the above
But that is wrong since we need -1/0.
(insn 202 201 203 (set (reg:QI 330)
(unspec:QI [
(vec_select:QI (reg:RVVMF2QI 331)
(parallel [
(const_int 0 [0])
]))
(reg:SI 67 vtype)
] UNSPEC_VPREDICATE)) -1
(nil))
// And this is just a select.
(insn 203 202 0 (set (reg:DI 194 [ _302 ])
(sign_extend:DI (reg:QI 330))) -1
(nil))
// This sign extends from QI to DI so still 0/1.
So yes this is incorrect.
I still suspect vec_extract<mode>bi needs to extract to a sign extended to QI.
Or better yet leave it in bi mode somehow.