Skip to content

Commit 67e824c

Browse files
committed
[RISC-V][PR target/118934] Fix ICE in RISC-V long branch support
I'm not sure if I goof'd this or if I merely upstreamed someone else's goof. Either way the long branch code isn't working correctly. We were using 'n' as the output modifier to negate the condition. But 'n' has a special meaning elsewhere, so when presented with a condition rather than what was expected, boom, the compiler ICE'd. Thankfully there's only a few places where we were using %n which I turned into %r. The BZ entry includes a good testcase, it just takes a long time to compile as it's trying to create the out-of-range scenario. I'm not including the testcase due to how long it takes, but I did test it locally to ensure it's working properly now. I'm sure that with a little bit of work I could create at testcase that worked before and fails with the trunk (by taking advantage of the fuzzyness in length computations). So I'm going to consider this a regression. Will push to the trunk after pre-commit testing does its thing. PR target/118934 gcc/ * config/riscv/corev.md (cv_branch): Adjust output template. (branch): Likewise. * config/riscv/riscv.md (branch): Likewise. * config/riscv/riscv.cc (riscv_asm_output_opcode): Handle 'r' rather than 'n'.
1 parent 585aa40 commit 67e824c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

gcc/config/riscv/corev.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,7 @@
26272627
"TARGET_XCVBI"
26282628
{
26292629
if (get_attr_length (insn) == 12)
2630-
return "cv.b%n1\t%2,%z3,1f; jump\t%l0,ra; 1:";
2630+
return "cv.b%r1\t%2,%z3,1f; jump\t%l0,ra; 1:";
26312631

26322632
return "cv.b%C1imm\t%2,%3,%0";
26332633
}
@@ -2645,7 +2645,7 @@
26452645
"TARGET_XCVBI"
26462646
{
26472647
if (get_attr_length (insn) == 12)
2648-
return "b%n1\t%2,%z3,1f; jump\t%l0,ra; 1:";
2648+
return "b%r1\t%2,%z3,1f; jump\t%l0,ra; 1:";
26492649

26502650
return "b%C1\t%2,%z3,%l0";
26512651
}

gcc/config/riscv/riscv.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -6868,7 +6868,7 @@ riscv_asm_output_opcode (FILE *asm_out_file, const char *p)
68686868
any outermost HIGH.
68696869
'R' Print the low-part relocation associated with OP.
68706870
'C' Print the integer branch condition for comparison OP.
6871-
'n' Print the inverse of the integer branch condition for comparison OP.
6871+
'r' Print the inverse of the integer branch condition for comparison OP.
68726872
'A' Print the atomic operation suffix for memory model OP.
68736873
'I' Print the LR suffix for memory model OP.
68746874
'J' Print the SC suffix for memory model OP.
@@ -7027,7 +7027,7 @@ riscv_print_operand (FILE *file, rtx op, int letter)
70277027
fputs (GET_RTX_NAME (code), file);
70287028
break;
70297029

7030-
case 'n':
7030+
case 'r':
70317031
/* The RTL names match the instruction names. */
70327032
fputs (GET_RTX_NAME (reverse_condition (code)), file);
70337033
break;

gcc/config/riscv/riscv.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3252,7 +3252,7 @@
32523252
"!TARGET_XCVBI"
32533253
{
32543254
if (get_attr_length (insn) == 12)
3255-
return "b%n1\t%2,%z3,1f; jump\t%l0,ra; 1:";
3255+
return "b%r1\t%2,%z3,1f; jump\t%l0,ra; 1:";
32563256

32573257
return "b%C1\t%2,%z3,%l0";
32583258
}

0 commit comments

Comments
 (0)