Skip to content

Commit

Permalink
[VE] Change the way of lowering store
Browse files Browse the repository at this point in the history
Change lowering store iff the data operand is leagalized.  In this way,
llvm can lower only operands first, then lower store instruction later.

Reviewed By: efocht

Differential Revision: https://reviews.llvm.org/D158253
  • Loading branch information
kaz7 committed Aug 18, 2023
1 parent 5e57752 commit 2e23956
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions llvm/lib/Target/VE/VVPISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ SDValue VETargetLowering::lowerVVP_LOAD_STORE(SDValue Op,

// VVP_STORE
assert(VVPOpc == VEISD::VVP_STORE);
if (getTypeAction(*CDAG.getDAG()->getContext(), Data.getValueType()) !=
TargetLowering::TypeLegal)
// Doesn't lower store instruction if an operand is not lowered yet.
// If it isn't, return SDValue(). In this way, LLVM will try to lower
// store instruction again after lowering all operands.
return SDValue();
return CDAG.getNode(VEISD::VVP_STORE, Op.getNode()->getVTList(),
{Chain, Data, BasePtr, StrideV, Mask, AVL});
}
Expand Down
14 changes: 13 additions & 1 deletion llvm/test/CodeGen/VE/Vector/ticket-64420.ll
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
; RUN: llc < %s -mtriple=ve -mattr=+vpu | FileCheck %s
; RUN: llc < %s -mtriple=ve -mattr=-vpu | FileCheck --check-prefix=SCALAR %s

; Check vector and scalar code generation for vector load instruction.
; For the case of scalar, generates 2 stores of 8 bytes length.
; For the case of vector, generates vst with 4 vector length. For the
; case of scalar, generates 2 stores of 8 bytes length.

; This is taken from a ticket below.
; https://github.com/llvm/llvm-project/issues/64420

; CHECK-LABEL: func:
; CHECK: # %bb.1:
; CHECK-NEXT: lea %s1, 256
; CHECK-NEXT: lvl %s1
; CHECK-NEXT: vbrd %v0, 0
; CHECK-NEXT: or %s1, 4, (0)1
; CHECK-NEXT: lvl %s1
; CHECK-NEXT: vstl %v0, 4, %s0
; CHECK-NEXT: b.l.t (, %s10)

; SCALAR-LABEL: func:
; SCALAR: # %bb.1:
; SCALAR-NEXT: st %s1, 8(, %s0)
Expand Down

0 comments on commit 2e23956

Please sign in to comment.