On Mon, Nov 30, 2020 at 09:11:10PM +0800, Hongtao Liu wrote: > +;; PR96906 - optimize vpsubusw compared to 0 into vpcmpleuw or vpcmpnltuw. > +(define_split > + [(set (match_operand:<avx512fmaskmode> 0 "register_operand") > + (unspec:<avx512fmaskmode> > + [(us_minus:VI12_AVX512VL > + (match_operand:VI12_AVX512VL 1 "vector_operand") > + (match_operand:VI12_AVX512VL 2 "vector_operand")) > + (match_operand:VI12_AVX512VL 3 "const0_operand") > + (match_operand:SI 4 "const0_operand")] > + UNSPEC_PCMP))] > + "TARGET_AVX512BW && ix86_binary_operator_ok (US_MINUS, <MODE>mode, > operands)"
Too long line, please wrap it. Also, INTVAL (operands[4]) == 0 is EQ comparison, can't we handle also NE (i.e. INTVAL (operands[4]) == 4? I.e. replace the "const0_operand" in there with "const_0_to_7_operand" and check in conditions that (INTVAL (operands[4]) & 3) == 0. > + [(const_int 0)] > + { > + /* LE: 2, NLT: 5. */ > + rtx cmp_predicate = GEN_INT (2); > + if (MEM_P (operands[1])) > + { > + std::swap (operands[1], operands[2]); > + cmp_predicate = GEN_INT (5); For INTVAL (operands[4]) == 4 it would then be cmp_predictate NLE: 4 resp. LT: 3 I think. Also, this handles only UNSPEC_PCMP, can't we handle UNSPEC_UNSIGNED_PCMP too? I mean, for equality comparisons it doesn't really matter if we have signed or unsigned == or !=. And for unsigned x == 0U is equivalent to x <= 0U, and x != 0U equivalent to x > 0U. Jakub