RISC-V: Also handle sign extension in branch costing
Complement commit c1e8cb3d ("RISC-V: Rework branch costing model for if-conversion") and also handle extraneous sign extend operations that are sometimes produced by `noce_try_cmove_arith' instead of zero extend operations, making branch costing consistent. It is unclear what the condition is for the middle end to choose between the zero extend and sign extend operation, but the test case included uses sign extension with 64-bit targets, preventing if-conversion from triggering across all the architectural variants. There are further anomalies revealed by the test case, specifically the exceedingly high branch cost of 6 required for the `-mmovcc' variant despite that the final branchless sequence only uses 4 instructions, the missed conversion at -O1 for 32-bit targets even though code is machine word size agnostic, and the missed conversion at -Os and -Oz for 32-bit Zicond targets even though the branchless sequence would be shorter than the branched one. These will have to be handled separately. gcc/ * config/riscv/riscv.cc (riscv_noce_conversion_profitable_p): Also handle sign extension. gcc/testsuite/ * gcc.target/riscv/cset-sext-sfb.c: New test. * gcc.target/riscv/cset-sext-thead.c: New test. * gcc.target/riscv/cset-sext-ventana.c: New test. * gcc.target/riscv/cset-sext-zicond.c: New test. * gcc.target/riscv/cset-sext.c: New test.
Showing
- gcc/config/riscv/riscv.cc 3 additions, 2 deletionsgcc/config/riscv/riscv.cc
- gcc/testsuite/gcc.target/riscv/cset-sext-sfb.c 28 additions, 0 deletionsgcc/testsuite/gcc.target/riscv/cset-sext-sfb.c
- gcc/testsuite/gcc.target/riscv/cset-sext-thead.c 26 additions, 0 deletionsgcc/testsuite/gcc.target/riscv/cset-sext-thead.c
- gcc/testsuite/gcc.target/riscv/cset-sext-ventana.c 26 additions, 0 deletionsgcc/testsuite/gcc.target/riscv/cset-sext-ventana.c
- gcc/testsuite/gcc.target/riscv/cset-sext-zicond.c 26 additions, 0 deletionsgcc/testsuite/gcc.target/riscv/cset-sext-zicond.c
- gcc/testsuite/gcc.target/riscv/cset-sext.c 27 additions, 0 deletionsgcc/testsuite/gcc.target/riscv/cset-sext.c
Loading
Please register or sign in to comment