Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 864946f

Browse files
committed
[SystemZ] Support load-and-zero-rightmost-byte facility
This adds support for the LZRF/LZRG/LLZRGF instructions that were added on z13, and uses them for code generation were appropriate. SystemZDAGToDAGISel::tryRISBGZero is updated again to prefer LLZRGF over RISBG where both would be possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286586 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9035357 commit 864946f

File tree

10 files changed

+507
-3
lines changed

10 files changed

+507
-3
lines changed

lib/Target/SystemZ/SystemZFeatures.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ def Arch10NewFeatures : SystemZFeatureList<[
111111
//
112112
//===----------------------------------------------------------------------===//
113113

114+
def FeatureLoadAndZeroRightmostByte : SystemZFeature<
115+
"load-and-zero-rightmost-byte", "LoadAndZeroRightmostByte",
116+
"Assume that the load-and-zero-rightmost-byte facility is installed"
117+
>;
118+
114119
def FeatureLoadStoreOnCond2 : SystemZFeature<
115120
"load-store-on-cond-2", "LoadStoreOnCond2",
116121
"Assume that the load/store-on-condition facility 2 is installed"
@@ -123,6 +128,7 @@ def FeatureVector : SystemZFeature<
123128
def FeatureNoVector : SystemZMissingFeature<"Vector">;
124129

125130
def Arch11NewFeatures : SystemZFeatureList<[
131+
FeatureLoadAndZeroRightmostByte,
126132
FeatureLoadStoreOnCond2,
127133
FeatureVector
128134
]>;

lib/Target/SystemZ/SystemZISelDAGToDAG.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,16 @@ bool SystemZDAGToDAGISel::tryRISBGZero(SDNode *N) {
957957
SystemZ::isImmLF(~RISBG.Mask) ||
958958
SystemZ::isImmHF(~RISBG.Mask))
959959
PreferAnd = true;
960+
// And likewise for the LLZRGF instruction, which doesn't have a register
961+
// to register version.
962+
else if (auto *Load = dyn_cast<LoadSDNode>(RISBG.Input)) {
963+
if (Load->getMemoryVT() == MVT::i32 &&
964+
(Load->getExtensionType() == ISD::EXTLOAD ||
965+
Load->getExtensionType() == ISD::ZEXTLOAD) &&
966+
RISBG.Mask == 0xffffff00 &&
967+
Subtarget->hasLoadAndZeroRightmostByte())
968+
PreferAnd = true;
969+
}
960970
if (PreferAnd) {
961971
// Replace the current node with an AND. Note that the current node
962972
// might already be that same AND, in which case it is already CSE'd

lib/Target/SystemZ/SystemZInstrInfo.td

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,16 @@ let canFoldAsLoad = 1 in {
387387
def LGRL : UnaryRILPC<"lgrl", 0xC48, aligned_load, GR64>;
388388
}
389389

390+
// Load and zero rightmost byte.
391+
let Predicates = [FeatureLoadAndZeroRightmostByte] in {
392+
def LZRF : UnaryRXY<"lzrf", 0xE33B, null_frag, GR32, 4>;
393+
def LZRG : UnaryRXY<"lzrg", 0xE32A, null_frag, GR64, 8>;
394+
def : Pat<(and (i32 (load bdxaddr20only:$src)), 0xffffff00),
395+
(LZRF bdxaddr20only:$src)>;
396+
def : Pat<(and (i64 (load bdxaddr20only:$src)), 0xffffffffffffff00),
397+
(LZRG bdxaddr20only:$src)>;
398+
}
399+
390400
// Register stores.
391401
let SimpleBDXStore = 1 in {
392402
// Expands to ST, STY or STFH, depending on the choice of register.
@@ -583,6 +593,13 @@ def : Pat<(and GR64:$src, 0x7fffffff),
583593
def : Pat<(and (i64 (azextloadi32 bdxaddr20only:$src)), 0x7fffffff),
584594
(LLGT bdxaddr20only:$src)>;
585595

596+
// Load and zero rightmost byte.
597+
let Predicates = [FeatureLoadAndZeroRightmostByte] in {
598+
def LLZRGF : UnaryRXY<"llzrgf", 0xE33A, null_frag, GR64, 4>;
599+
def : Pat<(and (i64 (azextloadi32 bdxaddr20only:$src)), 0xffffff00),
600+
(LLZRGF bdxaddr20only:$src)>;
601+
}
602+
586603
//===----------------------------------------------------------------------===//
587604
// Truncations
588605
//===----------------------------------------------------------------------===//

lib/Target/SystemZ/SystemZScheduleZ13.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ def : InstRW<[FXa], (instregex "LG(F|H)I$")>;
194194
def : InstRW<[FXa], (instregex "LHI(Mux)?$")>;
195195
def : InstRW<[FXa], (instregex "LR(Mux)?$")>;
196196

197+
// Load and zero rightmost byte
198+
def : InstRW<[LSU], (instregex "LZR(F|G)$")>;
199+
197200
// Load and test
198201
def : InstRW<[FXa, LSU, Lat5], (instregex "LT(G)?$")>;
199202
def : InstRW<[FXa], (instregex "LT(G)?R$")>;
@@ -244,6 +247,9 @@ def : InstRW<[FXa, LSU, Lat5], (instregex "LL(C|H)H$")>;
244247
def : InstRW<[LSU], (instregex "LLHRL$")>;
245248
def : InstRW<[LSU], (instregex "LLG(C|H|F|T|HRL|FRL)$")>;
246249

250+
// Load and zero rightmost byte
251+
def : InstRW<[LSU], (instregex "LLZRGF$")>;
252+
247253
//===----------------------------------------------------------------------===//
248254
// Truncations
249255
//===----------------------------------------------------------------------===//

lib/Target/SystemZ/SystemZSubtarget.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
4040
HasPopulationCount(false), HasFastSerialization(false),
4141
HasInterlockedAccess1(false), HasMiscellaneousExtensions(false),
4242
HasTransactionalExecution(false), HasProcessorAssist(false),
43-
HasVector(false), HasLoadStoreOnCond2(false), TargetTriple(TT),
44-
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
45-
TSInfo(), FrameLowering() {}
43+
HasVector(false), HasLoadStoreOnCond2(false),
44+
HasLoadAndZeroRightmostByte(false),
45+
TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
46+
TLInfo(TM, *this), TSInfo(), FrameLowering() {}
4647

4748
bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
4849
CodeModel::Model CM) const {

lib/Target/SystemZ/SystemZSubtarget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SystemZSubtarget : public SystemZGenSubtargetInfo {
4646
bool HasProcessorAssist;
4747
bool HasVector;
4848
bool HasLoadStoreOnCond2;
49+
bool HasLoadAndZeroRightmostByte;
4950

5051
private:
5152
Triple TargetTriple;
@@ -115,6 +116,11 @@ class SystemZSubtarget : public SystemZGenSubtargetInfo {
115116
// Return true if the target has the processor-assist facility.
116117
bool hasProcessorAssist() const { return HasProcessorAssist; }
117118

119+
// Return true if the target has the load-and-zero-rightmost-byte facility.
120+
bool hasLoadAndZeroRightmostByte() const {
121+
return HasLoadAndZeroRightmostByte;
122+
}
123+
118124
// Return true if the target has the vector facility.
119125
bool hasVector() const { return HasVector; }
120126

0 commit comments

Comments
 (0)