Skip to content

Commit

Permalink
[RISCV] Fix boundary error in compress-opt-select.ll
Browse files Browse the repository at this point in the history
Per the comment, this test is intending to test the first constant which
can't be encoded via a c.addi.  However, -32 *can* be encoded as in a
c.addi, and all that's preventing it from doing so is the register
allocators choice to use a difference destination register on the
add than it's source.  (Which compressed doesn't support.)

The current LLC codegen for this test looks like:

	addi	a1, a0, -32
	li	a0, -99
	bnez	a1, .LBB0_2
	li	a0, 42
.LBB0_2:
	ret

After llvm#108889, we sink the LI, and
the register allocator picks the same source and dest register for the addi
resulting in the c.addi form being emitted.  So, to avoid a confusing diff
let's fix the test to check what was originally intended.
  • Loading branch information
preames committed Sep 17, 2024
1 parent 267ad43 commit b153cc5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/RISCV/compress-opt-select.ll
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ define i32 @f_small_edge_neg(i32 %in0) minsize {
; constant is medium and not fit in 6 bit (compress imm),
; but fit in 12 bit (imm)
; RV32IFDC-LABEL: <f_medium_ledge_pos>:
; RV32IFDC: addi [[MAYZEROREG:.*]], [[REG:.*]], -0x20
; RV32IFDC: addi [[MAYZEROREG:.*]], [[REG:.*]], -0x21
; RV32IFDC: RESBROPT [[MAYZEROREG]], [[PLACE:.*]]
; --- no compress extension
; RV32IFD-LABEL: <f_medium_ledge_pos>:
; RV32IFD: addi [[REG:.*]], zero, 0x20
; RV32IFD: addi [[REG:.*]], zero, 0x21
; RV32IFD: RESBRNORMAL [[ANOTHER:.*]], [[REG]], [[PLACE:.*]]
define i32 @f_medium_ledge_pos(i32 %in0) minsize {
%cmp = icmp CMPCOND i32 %in0, 32
%cmp = icmp CMPCOND i32 %in0, 33
%toRet = select i1 %cmp, i32 -99, i32 42
ret i32 %toRet
}
Expand Down

0 comments on commit b153cc5

Please sign in to comment.