From ac6bde281d97d9ebbd04f28e31a36bd3743f3ed3 Mon Sep 17 00:00:00 2001 From: Jonas Paulsson Date: Wed, 11 Jan 2017 14:40:39 +0000 Subject: [PATCH] [SystemZ] Improve isFoldableMemAccessOffset(). A store of an extracted element or a load which gets inserted into a vector, will be combined into a vector load/store element instruction. Therefore, isFoldableMemAccessOffset(), which is called by LSR, should return false in these cases. Reviewer: Ulrich Weigand git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291673 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/SystemZ/SystemZISelLowering.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Target/SystemZ/SystemZISelLowering.cpp b/lib/Target/SystemZ/SystemZISelLowering.cpp index 2081809def7..2d0a06af18a 100644 --- a/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -547,8 +547,26 @@ bool SystemZTargetLowering::isFoldableMemAccessOffset(Instruction *I, assert (isa(I) || isa(I)); Type *MemAccessTy = (isa(I) ? I->getType() : I->getOperand(0)->getType()); - if (!isUInt<12>(Offset) && - (MemAccessTy->isFloatingPointTy() || MemAccessTy->isVectorTy())) + bool IsFPAccess = MemAccessTy->isFloatingPointTy(); + bool IsVectorAccess = MemAccessTy->isVectorTy(); + + // A store of an extracted vector element will be combined into a VSTE type + // instruction. + if (!IsVectorAccess && isa(I)) { + Value *DataOp = I->getOperand(0); + if (isa(DataOp)) + IsVectorAccess = true; + } + + // A load which gets inserted into a vector element will be combined into a + // VLE type instruction. + if (!IsVectorAccess && isa(I) && I->hasOneUse()) { + User *LoadUser = *I->user_begin(); + if (isa(LoadUser)) + IsVectorAccess = true; + } + + if (!isUInt<12>(Offset) && (IsFPAccess || IsVectorAccess)) return false; return true; -- 2.40.0