Hi Vijay, Please add a testcase. -Surya
On 04/12/25 3:43 pm, Vijay Shankar wrote: > Hello, > > Changes from v2: > * Some formatting. > Changes from v1: > * Added more info to commit message fixed indentation. > > This patch removes redundant vector compare instructions and logic > from the vec_first_mismatch_or_eos_index intrinsic. > Currently, GCC generates extra vcmpneb instructions and additional > masking logic (xxland, xxlorc) to handle EOS and mismatch comparisons. > However, a single vcmpnezb instruction already suffices, as it covers > both By eliminating the redundant comparisons (vcmpneb) and the > associated logic (xxland/xxlorc) we produce shorter, > more efficient code. > > Bootstrapped and tested on powerpc64le-linux-gnu with no regressions. > > Im not sure why formatting was messed up last time but it should be > fixed now also added more info about insns and builtins > requiring ISA 3.0 > >> Why was it ever written this way, any clue? > Im not sure actually I tried contacting Carl love but no updates from him yet > > 2025-10-22 Vijay Shankar <[email protected]> > > gcc/ChangeLog: > > PR target/116004 > * config/rs6000/vsx.md (first_mismatch_or_eos_index): Remove redundant > emit_insns. > --- > gcc/config/rs6000/vsx.md | 22 +++------------------- > 1 file changed, 3 insertions(+), 19 deletions(-) > > diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md > index dd3573b80..cac1e6080 100644 > --- a/gcc/config/rs6000/vsx.md > +++ b/gcc/config/rs6000/vsx.md > @@ -5668,29 +5668,13 @@ > "TARGET_P9_VECTOR" > { > int sh; > - rtx cmpz1_result = gen_reg_rtx (<MODE>mode); > - rtx cmpz2_result = gen_reg_rtx (<MODE>mode); > - rtx cmpz_result = gen_reg_rtx (<MODE>mode); > - rtx not_cmpz_result = gen_reg_rtx (<MODE>mode); > - rtx and_result = gen_reg_rtx (<MODE>mode); > rtx result = gen_reg_rtx (<MODE>mode); > - rtx vzero = gen_reg_rtx (<MODE>mode); > - > - /* Vector with zeros in elements that correspond to zeros in operands. */ > - emit_move_insn (vzero, CONST0_RTX (<MODE>mode)); > > - emit_insn (gen_vcmpne<VSX_EXTRACT_WIDTH> (cmpz1_result, operands[1], > vzero)); > - emit_insn (gen_vcmpne<VSX_EXTRACT_WIDTH> (cmpz2_result, operands[2], > vzero)); > - emit_insn (gen_and<mode>3 (and_result, cmpz1_result, cmpz2_result)); > + /* Vector with ones in elements that match or elements corresponding to > zeros > + in operands. */ > > - /* Vector with ones in elments that match. */ > - emit_insn (gen_vcmpnez<VSX_EXTRACT_WIDTH> (cmpz_result, operands[1], > + emit_insn (gen_vcmpnez<VSX_EXTRACT_WIDTH> (result, operands[1], > operands[2])); > - emit_insn (gen_one_cmpl<mode>2 (not_cmpz_result, cmpz_result)); > - > - /* Create vector with ones in elements where there was a zero in one of > - the source elements or the elements did not match. */ > - emit_insn (gen_nand<mode>3 (result, and_result, not_cmpz_result)); > sh = GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) / 2; > > if (<MODE>mode == V16QImode)
