From: Richard Sandiford Date: Tue, 1 Oct 2013 14:33:55 +0000 (+0000) Subject: [SystemZ] Extend pseudo conditional 8- and 16-bit stores to high words X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=00f5335ea0b62f0921d215a4d04e2fe5f33771ce;p=oota-llvm.git [SystemZ] Extend pseudo conditional 8- and 16-bit stores to high words As the comment says, we always want to use STOC for 32-bit stores. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191767 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/SystemZ/SystemZISelLowering.cpp b/lib/Target/SystemZ/SystemZISelLowering.cpp index 4785f75d69b..f9cc3b8d159 100644 --- a/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -2893,6 +2893,14 @@ EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *MBB) const { case SystemZ::SelectF128: return emitSelect(MI, MBB); + case SystemZ::CondStore8Mux: + return emitCondStore(MI, MBB, SystemZ::STCMux, 0, false); + case SystemZ::CondStore8MuxInv: + return emitCondStore(MI, MBB, SystemZ::STCMux, 0, true); + case SystemZ::CondStore16Mux: + return emitCondStore(MI, MBB, SystemZ::STHMux, 0, false); + case SystemZ::CondStore16MuxInv: + return emitCondStore(MI, MBB, SystemZ::STHMux, 0, true); case SystemZ::CondStore8: return emitCondStore(MI, MBB, SystemZ::STC, 0, false); case SystemZ::CondStore8Inv: diff --git a/lib/Target/SystemZ/SystemZInstrInfo.td b/lib/Target/SystemZ/SystemZInstrInfo.td index bf333b5ee8a..88508e33c5d 100644 --- a/lib/Target/SystemZ/SystemZInstrInfo.td +++ b/lib/Target/SystemZ/SystemZInstrInfo.td @@ -202,12 +202,20 @@ def Select32Mux : SelectWrapper, Requires<[FeatureHighWord]>; def Select32 : SelectWrapper; def Select64 : SelectWrapper; -defm CondStore8 : CondStores; -defm CondStore16 : CondStores; -defm CondStore32 : CondStores; +// We don't define 32-bit Mux stores because the low-only STOC should +// always be used if possible. +defm CondStore8Mux : CondStores, + Requires<[FeatureHighWord]>; +defm CondStore16Mux : CondStores, + Requires<[FeatureHighWord]>; +defm CondStore8 : CondStores; +defm CondStore16 : CondStores; +defm CondStore32 : CondStores; defm : CondStores64; diff --git a/test/CodeGen/SystemZ/fp-move-09.ll b/test/CodeGen/SystemZ/fp-move-09.ll index 8c3e9c9c863..52b2ee2e31a 100644 --- a/test/CodeGen/SystemZ/fp-move-09.ll +++ b/test/CodeGen/SystemZ/fp-move-09.ll @@ -28,3 +28,35 @@ define void @f2(float %val, i8 *%ptr) { store i8 %trunc, i8 *%ptr ret void } + +; Like f2, but with a conditional store. +define void @f3(float %val, i8 *%ptr, i32 %which) { +; CHECK-LABEL: f3: +; CHECK: cijlh %r3, 0, +; CHECK: lgdr [[REG:%r[0-5]]], %f0 +; CHECK: stch [[REG]], 0(%r2) +; CHECK: br %r14 + %int = bitcast float %val to i32 + %trunc = trunc i32 %int to i8 + %old = load i8 *%ptr + %cmp = icmp eq i32 %which, 0 + %res = select i1 %cmp, i8 %trunc, i8 %old + store i8 %res, i8 *%ptr + ret void +} + +; ...and again with 16-bit memory. +define void @f4(float %val, i16 *%ptr, i32 %which) { +; CHECK-LABEL: f4: +; CHECK: cijlh %r3, 0, +; CHECK: lgdr [[REG:%r[0-5]]], %f0 +; CHECK: sthh [[REG]], 0(%r2) +; CHECK: br %r14 + %int = bitcast float %val to i32 + %trunc = trunc i32 %int to i16 + %old = load i16 *%ptr + %cmp = icmp eq i32 %which, 0 + %res = select i1 %cmp, i16 %trunc, i16 %old + store i16 %res, i16 *%ptr + ret void +}