> It's as reasonable as other methods such as turning it into a > define_expand and emitting a conditional branch around the sequence when > the count is zero.
Thanks much. I suspect the cost of the PSW setting instructions is far less than a branch, so how about this version which emits them only when the length is unknown and skips the instruction entirely when the length is known to be zero? This replaces the previous patch because it is easier to understand; if this looks correct, I'll submit it as a patch on top of the previous one. This also passes my picolibc CI tests. diff --git a/gcc/config/rx/rx.md b/gcc/config/rx/rx.md index 89211585c9c..d2424ca395e 100644 --- a/gcc/config/rx/rx.md +++ b/gcc/config/rx/rx.md @@ -2545,6 +2545,16 @@ (define_expand "cmpstrnsi" (match_operand:SI 4 "immediate_operand")] ;; Known Align "rx_allow_string_insns" { + bool const_len = CONST_INT_P(operands[3]); + if (const_len) + { + if (INTVAL(operands[3]) == 0) + { + emit_move_insn (operands[0], operands[3]); + DONE; + } + } + rtx str1 = gen_rtx_REG (SImode, 1); rtx str2 = gen_rtx_REG (SImode, 2); rtx len = gen_rtx_REG (SImode, 3); @@ -2553,6 +2563,10 @@ (define_expand "cmpstrnsi" emit_move_insn (str2, force_operand (XEXP (operands[2], 0), NULL_RTX)); emit_move_insn (len, operands[3]); + if (!const_len) { + emit_insn (gen_setpsw (GEN_INT(0))); /* set C */ + emit_insn (gen_setpsw (GEN_INT(1))); /* set Z */ + } emit_insn (gen_rx_cmpstrn (operands[0], operands[1], operands[2])); DONE; } -- -keith
signature.asc
Description: PGP signature