[PATCH] D118216: [RISCV] LUI used for address computation should not isAsCheapAsAMove
Haocong Lu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 9 02:41:24 PST 2022
Luhaocong updated this revision to Diff 407102.
Luhaocong retitled this revision from "[RISCV] eliminate rematerialization of array's base address" to "[RISCV] LUI used for address computation should not isAsCheapAsAMove".
Luhaocong edited the summary of this revision.
Luhaocong added a comment.
modify description
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118216/new/
https://reviews.llvm.org/D118216
Files:
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/test/CodeGen/RISCV/unroll-loop-cse.ll
Index: llvm/test/CodeGen/RISCV/unroll-loop-cse.ll
===================================================================
--- llvm/test/CodeGen/RISCV/unroll-loop-cse.ll
+++ llvm/test/CodeGen/RISCV/unroll-loop-cse.ll
@@ -18,28 +18,20 @@
; CHECK-NEXT: bne a3, a4, .LBB0_6
; CHECK-NEXT: # %bb.1:
; CHECK-NEXT: addi a1, a1, %lo(x)
-; CHECK-NEXT: lw a1, 4(a1)
+; CHECK-NEXT: lw a3, 4(a1)
; CHECK-NEXT: addi a2, a2, %lo(check)
-; CHECK-NEXT: lw a2, 4(a2)
-; CHECK-NEXT: bne a1, a2, .LBB0_6
+; CHECK-NEXT: lw a4, 4(a2)
+; CHECK-NEXT: bne a3, a4, .LBB0_6
; CHECK-NEXT: # %bb.2:
-; CHECK-NEXT: lui a1, %hi(x)
-; CHECK-NEXT: addi a1, a1, %lo(x)
; CHECK-NEXT: lw a3, 8(a1)
-; CHECK-NEXT: lui a2, %hi(check)
-; CHECK-NEXT: addi a2, a2, %lo(check)
; CHECK-NEXT: lw a4, 8(a2)
; CHECK-NEXT: bne a3, a4, .LBB0_6
; CHECK-NEXT: # %bb.3:
-; CHECK-NEXT: lw a1, 12(a1)
-; CHECK-NEXT: lw a2, 12(a2)
-; CHECK-NEXT: bne a1, a2, .LBB0_6
+; CHECK-NEXT: lw a3, 12(a1)
+; CHECK-NEXT: lw a4, 12(a2)
+; CHECK-NEXT: bne a3, a4, .LBB0_6
; CHECK-NEXT: # %bb.4:
-; CHECK-NEXT: lui a1, %hi(x)
-; CHECK-NEXT: addi a1, a1, %lo(x)
; CHECK-NEXT: lw a3, 16(a1)
-; CHECK-NEXT: lui a2, %hi(check)
-; CHECK-NEXT: addi a2, a2, %lo(check)
; CHECK-NEXT: lw a4, 16(a2)
; CHECK-NEXT: bne a3, a4, .LBB0_6
; CHECK-NEXT: # %bb.5:
Index: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -998,6 +998,8 @@
return (MI.getOperand(1).isReg() &&
MI.getOperand(1).getReg() == RISCV::X0) ||
(MI.getOperand(2).isImm() && MI.getOperand(2).getImm() == 0);
+ case RISCV::LUI:
+ return MI.getOperand(1).getTargetFlags() != RISCVII::MO_HI;
}
return MI.isAsCheapAsAMove();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118216.407102.patch
Type: text/x-patch
Size: 1904 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220209/23a393a0/attachment.bin>
More information about the llvm-commits
mailing list