[llvm] b153cc5 - [RISCV] Fix boundary error in compress-opt-select.ll

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 07:43:37 PDT 2024


Author: Philip Reames
Date: 2024-09-17T07:43:28-07:00
New Revision: b153cc5c2bd9f08bf34ec13016f7b436b3e8a1d9

URL: https://github.com/llvm/llvm-project/commit/b153cc5c2bd9f08bf34ec13016f7b436b3e8a1d9
DIFF: https://github.com/llvm/llvm-project/commit/b153cc5c2bd9f08bf34ec13016f7b436b3e8a1d9.diff

LOG: [RISCV] Fix boundary error in compress-opt-select.ll

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 https://github.com/llvm/llvm-project/pull/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.

Added: 
    

Modified: 
    llvm/test/CodeGen/RISCV/compress-opt-select.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/RISCV/compress-opt-select.ll b/llvm/test/CodeGen/RISCV/compress-opt-select.ll
index cc27f326327df1..85e0a0df000294 100644
--- a/llvm/test/CodeGen/RISCV/compress-opt-select.ll
+++ b/llvm/test/CodeGen/RISCV/compress-opt-select.ll
@@ -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
 }


        


More information about the llvm-commits mailing list