Skip to content
Snippets Groups Projects
Commit a2a956cf authored by Jeff Law's avatar Jeff Law
Browse files

[RISC-V] Add splitters to restore condops generation after recent phiopt changes

V2:
  Fix typo in ChangeLog.
  Remove now extraneous comment in cset-sext.c.
  Throttle back branch cost to 1 in various tests

--

Andrew P's recent improvements to phiopt regressed on the riscv testsuite.

Essentially the new code presented to the RTL optimizers is straightline code rather than branchy for the CE pass to analyze and optimize.  In the absence of conditional move support or sfb, the new code would be better.

Unfortunately the presented form isn't a great fit for xventanacondops, zicond or xtheadcondmov.  The net is the resulting code is actually slightly worse than before.  Essentially sne+czero turned into sne+sne+and.

Thankfully, combine is presented with

(and (ne (op1) (const_int 0))
     (ne (op2) (const_int 0)))

As the RHS of a set.  We can use a 3->2 splitter to guide combine on how to profitably rewrite the sequence in a form suitable for condops.  Just splitting that would be enough to fix the regression, but I'm fairly confident that other cases need to be handled and would have regressed had the testsuite been more thorough.

One arm of the AND is going to turn into an sCC instruction.  We have a variety of those that we support.  The codes vary as do the allowed operands of the sCC.  That produces a set of new splitters to handle those cases.

The other arm is going to turn into a czero (or similar) instruction. That one can be generalized to eq/ne.  So another set for that generalization.

We can remove a couple of XFAILs in the rv32 space as it's behaving much more like rv64 at this point.

For SFB targets it's unclear if the new code is better or worse.  In both cases it's a 3 instruction sequence.   So I just adjusted the test.  If the new code is worse for SFB, someone with an understanding of the tradeoffs for an SFB target will need to make adjustments.

Tested in my tester on rv64gcv and rv32gc.  Will wait for the pre-commit testers to render their verdict before moving forward.

gcc/

	* config/riscv/iterators.md (scc_0): New code iterator.
	* config/riscv/zicond.md: New splitters to improve code generated for
	cases like (and (scc) (scc)) for zicond, xventanacondops, xtheadcondmov.

gcc/testsuite/

	* gcc.target/riscv/cset-sext-sfb.c: Turn off ssa-phiopt.
	* gcc.target/riscv/cset-sext-thead.c: Do not check CE output anymore.
	* gcc.target/riscv/cset-sext-ventana.c: Similarly.  Adjust branch cost.
	* gcc.target/riscv/cset-sext-zicond.c: Similarly.
	* gcc.target/riscv/cset-sext.c: Similarly.  No longer allow
	"neg" in asm output.
parent 9a17e6d0
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment