[llvm] AMDGPU/GlobalISel: Uniformity info based regbankselect (PR #73684)

Petar Avramovic via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 02:22:53 PDT 2024


https://github.com/petar-avramovic updated https://github.com/llvm/llvm-project/pull/73684

>From c762f62e1e1a2822ea09c1d8e040be23b605071f Mon Sep 17 00:00:00 2001
From: Petar Avramovic <Petar.Avramovic at amd.com>
Date: Fri, 1 Mar 2024 13:08:47 +0100
Subject: [PATCH 1/2] AMDGPU/GlobalISel: refactor build readfirstlane helpers

Refactor helpers that build readfirstlane for input registers.
Required by upcoming patches thet need to build readfirstlane
for output registers.
---
 .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp  | 83 +++++++++++--------
 .../Target/AMDGPU/AMDGPURegisterBankInfo.h    | 26 +++++-
 2 files changed, 71 insertions(+), 38 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index aa4ec785bf02a3..a88bd829475d7f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -700,58 +700,69 @@ static LLT getHalfSizedType(LLT Ty) {
 
 // Build one or more V_READFIRSTLANE_B32 instructions to move the given vector
 // source value into a scalar register.
-Register AMDGPURegisterBankInfo::buildReadFirstLane(MachineIRBuilder &B,
-                                                    MachineRegisterInfo &MRI,
-                                                    Register Src) const {
+Register AMDGPURegisterBankInfo::buildReadFirstLaneSrc(MachineIRBuilder &B,
+                                                       Register Src) const {
+  MachineRegisterInfo &MRI = *B.getMRI();
   LLT Ty = MRI.getType(Src);
   const RegisterBank *Bank = getRegBank(Src, MRI, *TRI);
 
-  if (Bank == &AMDGPU::SGPRRegBank)
-    return Src;
-
-  unsigned Bits = Ty.getSizeInBits();
-  assert(Bits % 32 == 0);
-
   if (Bank != &AMDGPU::VGPRRegBank) {
     // We need to copy from AGPR to VGPR
     Src = B.buildCopy(Ty, Src).getReg(0);
     MRI.setRegBank(Src, AMDGPU::VGPRRegBank);
   }
 
+  return buildReadFirstLaneForType(B, Ty, Src).getReg(0);
+}
+
+MachineInstrBuilder AMDGPURegisterBankInfo::buildReadFirstLaneB32(
+    MachineIRBuilder &B, const DstOp &SgprDst, const SrcOp &VgprSrc) const {
+  MachineRegisterInfo &MRI = *B.getMRI();
+  auto RFL = B.buildInstr(AMDGPU::V_READFIRSTLANE_B32, {SgprDst}, {VgprSrc});
+  MRI.setRegClass(RFL.getReg(0), &AMDGPU::SReg_32RegClass);
+  MRI.setRegClass(RFL.getReg(1), &AMDGPU::VGPR_32RegClass);
+  return RFL;
+}
+
+MachineInstrBuilder AMDGPURegisterBankInfo::buildReadFirstLaneSequenceOfB32(
+    MachineIRBuilder &B, const DstOp &SgprDst, const SrcOp &VgprSrc,
+    unsigned NumElts) const {
+  MachineRegisterInfo &MRI = *B.getMRI();
   LLT S32 = LLT::scalar(32);
-  unsigned NumParts = Bits / 32;
-  SmallVector<Register, 8> SrcParts;
-  SmallVector<Register, 8> DstParts;
+  SmallVector<Register, 8> SgprDstParts;
 
-  if (Bits == 32) {
-    SrcParts.push_back(Src);
-  } else {
-    auto Unmerge = B.buildUnmerge(S32, Src);
-    for (unsigned i = 0; i < NumParts; ++i)
-      SrcParts.push_back(Unmerge.getReg(i));
+  auto Unmerge = B.buildUnmerge(S32, VgprSrc);
+  for (unsigned i = 0; i < NumElts; ++i) {
+    SgprDstParts.push_back(
+        buildReadFirstLaneB32(B, S32, Unmerge.getReg(i)).getReg(0));
   }
 
-  for (unsigned i = 0; i < NumParts; ++i) {
-    Register SrcPart = SrcParts[i];
-    Register DstPart = MRI.createVirtualRegister(&AMDGPU::SReg_32RegClass);
-    MRI.setType(DstPart, NumParts == 1 ? Ty : S32);
+  auto Merge = B.buildMergeLikeInstr(SgprDst, SgprDstParts);
+  MRI.setRegBank(Merge.getReg(0), AMDGPU::SGPRRegBank);
+  return Merge;
+}
 
-    const TargetRegisterClass *Constrained =
-        constrainGenericRegister(SrcPart, AMDGPU::VGPR_32RegClass, MRI);
-    (void)Constrained;
-    assert(Constrained && "Failed to constrain readfirstlane src reg");
+MachineInstrBuilder AMDGPURegisterBankInfo::buildReadFirstLaneForType(
+    MachineIRBuilder &B, const DstOp &SgprDst, const SrcOp &VgprSrc) const {
+  MachineRegisterInfo &MRI = *B.getMRI();
+  LLT S32 = LLT::scalar(32);
+  LLT S64 = LLT::scalar(64);
+  LLT Ty = SgprDst.getLLTTy(MRI);
 
-    B.buildInstr(AMDGPU::V_READFIRSTLANE_B32, {DstPart}, {SrcPart});
+  if (Ty == S32 || (Ty.isPointer() && Ty.getSizeInBits() == 32)) {
+    return buildReadFirstLaneB32(B, SgprDst, VgprSrc);
+  }
 
-    DstParts.push_back(DstPart);
+  if (Ty == S64 || (Ty.isPointer() && Ty.getSizeInBits() == 64)) {
+    return buildReadFirstLaneSequenceOfB32(B, SgprDst, VgprSrc, 2);
   }
 
-  if (Bits == 32)
-    return DstParts[0];
+  if (Ty.isVector() && Ty.getElementType() == S32) {
+    return buildReadFirstLaneSequenceOfB32(B, SgprDst, VgprSrc,
+                                           Ty.getNumElements());
+  }
 
-  Register Dst = B.buildMergeLikeInstr(Ty, DstParts).getReg(0);
-  MRI.setRegBank(Dst, AMDGPU::SGPRRegBank);
-  return Dst;
+  llvm_unreachable("Type not supported");
 }
 
 /// Legalize instruction \p MI where operands in \p OpIndices must be SGPRs. If
@@ -888,7 +899,7 @@ bool AMDGPURegisterBankInfo::executeInWaterfallLoop(
         B.setMBB(*LoopBB);
       }
 
-      Register CurrentLaneReg = buildReadFirstLane(B, MRI, OpReg);
+      Register CurrentLaneReg = buildReadFirstLaneSrc(B, OpReg);
 
       // Build the comparison(s).
       unsigned OpSize = OpTy.getSizeInBits();
@@ -1020,7 +1031,7 @@ void AMDGPURegisterBankInfo::constrainOpWithReadfirstlane(
   if (Bank == &AMDGPU::SGPRRegBank)
     return;
 
-  Reg = buildReadFirstLane(B, MRI, Reg);
+  Reg = buildReadFirstLaneSrc(B, Reg);
   MI.getOperand(OpIdx).setReg(Reg);
 }
 
@@ -1603,7 +1614,7 @@ bool AMDGPURegisterBankInfo::applyMappingMAD_64_32(
     MRI.setRegBank(DstHi, AMDGPU::VGPRRegBank);
 
     if (!DstOnValu) {
-      DstHi = buildReadFirstLane(B, MRI, DstHi);
+      DstHi = buildReadFirstLaneSrc(B, DstHi);
     } else {
       MulHiInVgpr = true;
     }
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h
index 5f550b426ec093..59810e8f6354e9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h
@@ -14,6 +14,7 @@
 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUREGISTERBANKINFO_H
 
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/Register.h"
 #include "llvm/CodeGen/RegisterBankInfo.h"
@@ -57,8 +58,20 @@ class AMDGPURegisterBankInfo final : public AMDGPUGenRegisterBankInfo {
                               iterator_range<MachineBasicBlock::iterator> Range,
                               SmallSet<Register, 4> &SGPROperandRegs) const;
 
-  Register buildReadFirstLane(MachineIRBuilder &B, MachineRegisterInfo &MRI,
-                              Register Src) const;
+  Register buildReadFirstLaneSrc(MachineIRBuilder &B, Register Src) const;
+
+  MachineInstrBuilder buildReadFirstLaneForType(MachineIRBuilder &B,
+                                                const DstOp &SgprDst,
+                                                const SrcOp &VgprSrc) const;
+
+  MachineInstrBuilder buildReadFirstLaneB32(MachineIRBuilder &B,
+                                            const DstOp &SgprDst,
+                                            const SrcOp &VgprSrc) const;
+
+  MachineInstrBuilder buildReadFirstLaneSequenceOfB32(MachineIRBuilder &B,
+                                                      const DstOp &SgprDst,
+                                                      const SrcOp &VgprSrc,
+                                                      unsigned NumElts) const;
 
   bool executeInWaterfallLoop(MachineIRBuilder &B, MachineInstr &MI,
                               ArrayRef<unsigned> OpIndices) const;
@@ -116,6 +129,12 @@ class AMDGPURegisterBankInfo final : public AMDGPUGenRegisterBankInfo {
                                        const MachineRegisterInfo &MRI,
                                        const TargetRegisterInfo &TRI) const;
 
+  // Return a value mapping for an operand that is same as already assigned
+  // reg bank or corresponds to assigned register class + LLT
+  const ValueMapping *
+  getPreAssignedOpMapping(Register Reg, const MachineRegisterInfo &MRI,
+                          const TargetRegisterInfo &TRI) const;
+
   // Return a value mapping for an operand that is required to be a AGPR.
   const ValueMapping *getAGPROpMapping(Register Reg,
                                        const MachineRegisterInfo &MRI,
@@ -155,6 +174,9 @@ class AMDGPURegisterBankInfo final : public AMDGPUGenRegisterBankInfo {
 
   const InstructionMapping &getDefaultMappingSOP(const MachineInstr &MI) const;
   const InstructionMapping &getDefaultMappingVOP(const MachineInstr &MI) const;
+  const InstructionMapping &
+  getDefaultMappingVOPWithPreassignedDef(const MachineInstr &MI) const;
+
   const InstructionMapping &getDefaultMappingAllVGPR(
     const MachineInstr &MI) const;
 

>From a32e0ff0b689777b230e0a8291d10e53d0199093 Mon Sep 17 00:00:00 2001
From: Petar Avramovic <Petar.Avramovic at amd.com>
Date: Fri, 1 Mar 2024 14:17:41 +0100
Subject: [PATCH 2/2] AMDGPU/GlobalISel: uniformity analysis based register
 bank selection

Current algorithm only considers register banks for inputs but does
take control flow into account.
This is wrong in cases where inputs are uniform (in sgpr) but because
of divergent control flow instruction is divergent and should use vgpr
instead of sgpr register banks. Most notable example are phis.
Also in cases where only available machine instruction uses vgpr
registers uniform instructions end up using vgpr register banks.
Start with simple implementation for G_FADD.
Pre-select register bank for destination register using machine
uniformity analysis info. Then select register banks that would allow
selection of available machine instructions.
For G_FADD vgpr machine instruction is available on all targets but
sgpr version is not. When there is no sgpr version assign vgpr register
banks and move vgpr destination to sgpr using readfirstlane.
---
 .../lib/Target/AMDGPU/AMDGPURegBankSelect.cpp |  21 +-
 .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp  | 108 +++-
 .../Target/AMDGPU/AMDGPURegisterBankInfo.h    |   6 +
 .../GlobalISel/combine-fma-add-ext-mul.ll     |  74 ++-
 .../CodeGen/AMDGPU/GlobalISel/floor.f64.ll    |  16 +
 llvm/test/CodeGen/AMDGPU/GlobalISel/fpow.ll   |  17 +-
 .../GlobalISel/llvm.amdgcn.interp.inreg.ll    |   3 +
 .../AMDGPU/GlobalISel/regbankselect-fadd.mir  |   3 +-
 .../GlobalISel/regbankselect-salu-float.mir   |   4 +-
 .../test/CodeGen/AMDGPU/GlobalISel/sdivrem.ll | 550 +++++++++---------
 .../test/CodeGen/AMDGPU/GlobalISel/udivrem.ll | 246 ++++----
 llvm/test/CodeGen/AMDGPU/fadd.f16.ll          |  32 +-
 llvm/test/CodeGen/AMDGPU/llvm.exp.ll          | 399 +++++++------
 llvm/test/CodeGen/AMDGPU/llvm.exp10.ll        | 399 +++++++------
 llvm/test/CodeGen/AMDGPU/llvm.exp2.ll         | 166 +++---
 llvm/test/CodeGen/AMDGPU/llvm.log.ll          | 440 +++++++++-----
 llvm/test/CodeGen/AMDGPU/llvm.log10.ll        | 440 +++++++++-----
 17 files changed, 1769 insertions(+), 1155 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegBankSelect.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegBankSelect.cpp
index 2ea03ddb1fccd6..ed105716d0f844 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegBankSelect.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegBankSelect.cpp
@@ -68,7 +68,26 @@ bool AMDGPURegBankSelect::runOnMachineFunction(MachineFunction &MF) {
   MachineUniformityInfo Uniformity =
       computeMachineUniformityInfo(MF, CycleInfo, DomTree.getBase(),
                                    !ST.isSingleLaneExecution(F));
-  (void)Uniformity; // TODO: Use this
+
+  // Switch for uniformity info based regbank selection. Pre-selects register
+  // bank on dst registers using machine uniformity analysis.
+  // Keep in sync with switches in getInstrMapping and applyMappingImpl.
+  for (MachineBasicBlock &MBB : MF) {
+    for (MachineInstr &MI : MBB) {
+      switch (MI.getOpcode()) {
+      case AMDGPU::G_FADD: {
+        Register Dst = MI.getOperand(0).getReg();
+        if (Uniformity.isUniform(Dst))
+          MRI->setRegBank(Dst, RBI->getRegBank(AMDGPU::SGPRRegBankID));
+        else
+          MRI->setRegBank(Dst, RBI->getRegBank(AMDGPU::VGPRRegBankID));
+        break;
+      }
+      default:
+        break;
+      }
+    }
+  }
 
   assignRegisterBanks(MF);
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index a88bd829475d7f..f62d5d71ce420e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -715,6 +715,27 @@ Register AMDGPURegisterBankInfo::buildReadFirstLaneSrc(MachineIRBuilder &B,
   return buildReadFirstLaneForType(B, Ty, Src).getReg(0);
 }
 
+// Create new vgpr destination register for MI then move it to current
+// MI's sgpr destination using one or more V_READFIRSTLANE_B32 instructions.
+void AMDGPURegisterBankInfo::buildReadFirstLaneDst(MachineIRBuilder &B,
+                                                   MachineInstr &MI) const {
+  MachineRegisterInfo &MRI = *B.getMRI();
+  Register Dst = MI.getOperand(0).getReg();
+  const RegisterBank *DstBank = getRegBank(Dst, MRI, *TRI);
+  if (DstBank != &AMDGPU::SGPRRegBank)
+    return;
+
+  Register VgprDst = MRI.createGenericVirtualRegister(MRI.getType(Dst));
+  MRI.setRegBank(VgprDst, AMDGPU::VGPRRegBank);
+
+  MI.getOperand(0).setReg(VgprDst);
+  MachineBasicBlock *MBB = MI.getParent();
+  B.setInsertPt(*MBB, std::next(MI.getIterator()));
+  // readFirstLane VgprDst into Dst after MI.
+  buildReadFirstLaneForType(B, Dst, VgprDst);
+  return;
+}
+
 MachineInstrBuilder AMDGPURegisterBankInfo::buildReadFirstLaneB32(
     MachineIRBuilder &B, const DstOp &SgprDst, const SrcOp &VgprSrc) const {
   MachineRegisterInfo &MRI = *B.getMRI();
@@ -745,10 +766,16 @@ MachineInstrBuilder AMDGPURegisterBankInfo::buildReadFirstLaneSequenceOfB32(
 MachineInstrBuilder AMDGPURegisterBankInfo::buildReadFirstLaneForType(
     MachineIRBuilder &B, const DstOp &SgprDst, const SrcOp &VgprSrc) const {
   MachineRegisterInfo &MRI = *B.getMRI();
+  LLT S16 = LLT::scalar(16);
   LLT S32 = LLT::scalar(32);
   LLT S64 = LLT::scalar(64);
   LLT Ty = SgprDst.getLLTTy(MRI);
 
+  if (Ty == S16) {
+    return B.buildTrunc(
+        SgprDst, buildReadFirstLaneB32(B, S32, B.buildAnyExt(S32, VgprSrc)));
+  }
+
   if (Ty == S32 || (Ty.isPointer() && Ty.getSizeInBits() == 32)) {
     return buildReadFirstLaneB32(B, SgprDst, VgprSrc);
   }
@@ -1035,6 +1062,17 @@ void AMDGPURegisterBankInfo::constrainOpWithReadfirstlane(
   MI.getOperand(OpIdx).setReg(Reg);
 }
 
+// MI has uniform inputs and output but only available machine instruction has
+// vgpr dest. Make it uniform by moving dst to sgpr using readfirstlane.
+void AMDGPURegisterBankInfo::constrainVgprDstOpWithReadfirstlane(
+    MachineIRBuilder &B, MachineInstr &MI,
+    const OperandsMapper &OpdMapper) const {
+  const RegisterBank *DstBank =
+      OpdMapper.getInstrMapping().getOperandMapping(0).BreakDown[0].RegBank;
+  if (DstBank != &AMDGPU::VGPRRegBank)
+    buildReadFirstLaneDst(B, MI);
+}
+
 /// Split \p Ty into 2 pieces. The first will have \p FirstSize bits, and the
 /// rest will be in the remainder.
 static std::pair<LLT, LLT> splitUnequalType(LLT Ty, unsigned FirstSize) {
@@ -2191,6 +2229,21 @@ void AMDGPURegisterBankInfo::applyMappingImpl(
   B.setInstrAndDebugLoc(MI);
   unsigned Opc = MI.getOpcode();
   MachineRegisterInfo &MRI = OpdMapper.getMRI();
+
+  // Switch for uniformity info based regbank selection.
+  // Keep in sync with switches in AMDGPURegBankSelect and getInstrMapping.
+  switch (Opc) {
+  case AMDGPU::G_FADD: {
+    applyDefaultMapping(OpdMapper);
+    unsigned Size = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
+    if (!Subtarget.hasSALUFloatInsts() || (Size != 32 && Size != 16))
+      constrainVgprDstOpWithReadfirstlane(B, MI, OpdMapper);
+    return;
+  }
+  default:
+    break;
+  }
+
   switch (Opc) {
   case AMDGPU::G_CONSTANT:
   case AMDGPU::G_IMPLICIT_DEF: {
@@ -3567,6 +3620,28 @@ AMDGPURegisterBankInfo::getDefaultMappingVOP(const MachineInstr &MI) const {
                                MI.getNumOperands());
 }
 
+const RegisterBankInfo::InstructionMapping &
+AMDGPURegisterBankInfo::getDefaultMappingVOPWithPreassignedDef(
+    const MachineInstr &MI) const {
+  SmallVector<const ValueMapping *, 8> OpdsMapping(MI.getNumOperands());
+  const MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
+  // Dst reg bank should have been set already by uniformity info
+  OpdsMapping[0] =
+      getPreAssignedOpMapping(MI.getOperand(0).getReg(), MRI, *TRI);
+
+  for (unsigned i = 1, e = MI.getNumOperands(); i != e; ++i) {
+    const MachineOperand &Op = MI.getOperand(i);
+    if (!Op.isReg())
+      continue;
+
+    unsigned Size = getSizeInBits(Op.getReg(), MRI, *TRI);
+    unsigned BankID = Size == 1 ? AMDGPU::VCCRegBankID : AMDGPU::VGPRRegBankID;
+    OpdsMapping[i] = AMDGPU::getValueMapping(BankID, Size);
+  }
+  return getInstructionMapping(1, 1, getOperandsMapping(OpdsMapping),
+                               MI.getNumOperands());
+}
+
 const RegisterBankInfo::InstructionMapping &
 AMDGPURegisterBankInfo::getDefaultMappingAllVGPR(const MachineInstr &MI) const {
   const MachineFunction &MF = *MI.getParent()->getParent();
@@ -3719,6 +3794,20 @@ AMDGPURegisterBankInfo::getVGPROpMapping(Register Reg,
   return AMDGPU::getValueMapping(AMDGPU::VGPRRegBankID, Size);
 }
 
+const RegisterBankInfo::ValueMapping *
+AMDGPURegisterBankInfo::getPreAssignedOpMapping(
+    Register Reg, const MachineRegisterInfo &MRI,
+    const TargetRegisterInfo &TRI) const {
+  const RegisterBank *Bank = getRegBank(Reg, MRI, TRI);
+  assert(Bank);
+  unsigned BankId = Bank->getID();
+  unsigned Size = getSizeInBits(Reg, MRI, TRI);
+  assert(BankId == AMDGPU::SGPRRegBankID ||
+         BankId == (Size == 1 ? AMDGPU::VCCRegBankID : AMDGPU::VGPRRegBankID));
+
+  return AMDGPU::getValueMapping(BankId, Size);
+}
+
 const RegisterBankInfo::ValueMapping *
 AMDGPURegisterBankInfo::getAGPROpMapping(Register Reg,
                                          const MachineRegisterInfo &MRI,
@@ -3835,6 +3924,24 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
 
   SmallVector<const ValueMapping*, 8> OpdsMapping(MI.getNumOperands());
 
+  // Switch for uniformity info based regbank selection.
+  // Requires pre-selected, by AMDGPURegBankSelect, reg-banks on dst registers.
+  // Keep in sync with switches in AMDGPURegBankSelect and applyMappingImpl.
+  switch (MI.getOpcode()) {
+  case AMDGPU::G_FADD: {
+    Register Dst = MI.getOperand(0).getReg();
+    unsigned Size = MRI.getType(Dst).getSizeInBits();
+    const RegisterBank *DstBank = getRegBank(Dst, MRI, *TRI);
+    assert(DstBank);
+    if (Subtarget.hasSALUFloatInsts() && (Size == 32 || Size == 16) &&
+        DstBank == &AMDGPU::SGPRRegBank)
+      return getDefaultMappingSOP(MI);
+    return getDefaultMappingVOPWithPreassignedDef(MI);
+  }
+  default:
+    break;
+  }
+
   switch (MI.getOpcode()) {
   default:
     return getInvalidInstructionMapping();
@@ -3932,7 +4039,6 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
     if (isSALUMapping(MI))
       return getDefaultMappingSOP(MI);
     return getDefaultMappingVOP(MI);
-  case AMDGPU::G_FADD:
   case AMDGPU::G_FSUB:
   case AMDGPU::G_FMUL:
   case AMDGPU::G_FMA:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h
index 59810e8f6354e9..fa76c85d0486d0 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.h
@@ -60,6 +60,8 @@ class AMDGPURegisterBankInfo final : public AMDGPUGenRegisterBankInfo {
 
   Register buildReadFirstLaneSrc(MachineIRBuilder &B, Register Src) const;
 
+  void buildReadFirstLaneDst(MachineIRBuilder &B, MachineInstr &MI) const;
+
   MachineInstrBuilder buildReadFirstLaneForType(MachineIRBuilder &B,
                                                 const DstOp &SgprDst,
                                                 const SrcOp &VgprSrc) const;
@@ -78,6 +80,10 @@ class AMDGPURegisterBankInfo final : public AMDGPUGenRegisterBankInfo {
 
   void constrainOpWithReadfirstlane(MachineIRBuilder &B, MachineInstr &MI,
                                     unsigned OpIdx) const;
+  void
+  constrainVgprDstOpWithReadfirstlane(MachineIRBuilder &B, MachineInstr &MI,
+                                      const OperandsMapper &OpdMapper) const;
+
   bool applyMappingDynStackAlloc(MachineIRBuilder &B,
                                  const OperandsMapper &OpdMapper,
                                  MachineInstr &MI) const;
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fma-add-ext-mul.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fma-add-ext-mul.ll
index 4ebe1c499a1769..63285b70826864 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fma-add-ext-mul.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fma-add-ext-mul.ll
@@ -49,21 +49,31 @@ define amdgpu_vs <5 x float> @test_5xf16_5xf32_add_ext_mul(<5 x half> inreg %x,
 ; GFX9-FAST-DENORM-LABEL: test_5xf16_5xf32_add_ext_mul:
 ; GFX9-FAST-DENORM:       ; %bb.0: ; %.entry
 ; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v0, s3
-; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v1, s4
-; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v2, s5
 ; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v0, s0, v0
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v1, s4
 ; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v1, s1, v1
-; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v2, s2, v2
 ; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v3, v0
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v4, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v5, v1
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v6, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v7, v2
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s6, v3
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v1, s7, v4
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v2, s8, v5
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v3, s9, v6
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v4, s10, v7
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v0, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v2, s5
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v4, v1
+; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v2, s2, v2
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v1, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v2, v2
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s7, v0
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s1, v0
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s8, v4
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s9, v1
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v3, s6, v3
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s3, v0
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s10, v2
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s0, v3
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s4, v0
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v0, s0
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v1, s1
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v2, s2
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v3, s3
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v4, s4
 ; GFX9-FAST-DENORM-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-FAST-DENORM-LABEL: test_5xf16_5xf32_add_ext_mul:
@@ -90,23 +100,35 @@ define amdgpu_vs <6 x float> @test_6xf16_6xf32_add_ext_mul_rhs(<6 x half> inreg
 ; GFX9-FAST-DENORM-LABEL: test_6xf16_6xf32_add_ext_mul_rhs:
 ; GFX9-FAST-DENORM:       ; %bb.0: ; %.entry
 ; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v0, s3
-; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v1, s4
-; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v2, s5
 ; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v0, s0, v0
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v1, s4
 ; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v1, s1, v1
-; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v2, s2, v2
 ; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v3, v0
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v4, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v5, v1
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v6, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v7, v2
-; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v8, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s6, v3
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v1, s7, v4
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v2, s8, v5
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v3, s9, v6
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v4, s10, v7
-; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v5, s11, v8
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v0, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v2, s5
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v4, v1
+; GFX9-FAST-DENORM-NEXT:    v_pk_mul_f16 v2, s2, v2
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v1, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_e32 v5, v2
+; GFX9-FAST-DENORM-NEXT:    v_cvt_f32_f16_sdwa v2, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s7, v0
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s1, v0
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s8, v4
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s9, v1
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s3, v0
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s10, v5
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v3, s6, v3
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s4, v0
+; GFX9-FAST-DENORM-NEXT:    v_add_f32_e32 v0, s11, v2
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s0, v3
+; GFX9-FAST-DENORM-NEXT:    v_readfirstlane_b32 s5, v0
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v0, s0
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v1, s1
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v2, s2
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v3, s3
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v4, s4
+; GFX9-FAST-DENORM-NEXT:    v_mov_b32_e32 v5, s5
 ; GFX9-FAST-DENORM-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-FAST-DENORM-LABEL: test_6xf16_6xf32_add_ext_mul_rhs:
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/floor.f64.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/floor.f64.ll
index 34635b077cd92d..2ee5907d5d187a 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/floor.f64.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/floor.f64.ll
@@ -199,6 +199,10 @@ define amdgpu_ps <2 x float> @s_floor_f64(double inreg %x) {
 ; GFX6-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
 ; GFX6-NEXT:    v_cndmask_b32_e32 v1, v1, v3, vcc
 ; GFX6-NEXT:    v_add_f64 v[0:1], s[2:3], -v[0:1]
+; GFX6-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX6-NEXT:    v_readfirstlane_b32 s1, v1
+; GFX6-NEXT:    v_mov_b32_e32 v0, s0
+; GFX6-NEXT:    v_mov_b32_e32 v1, s1
 ; GFX6-NEXT:    ; return to shader part epilog
 ;
 ; GFX78-LABEL: s_floor_f64:
@@ -223,6 +227,10 @@ define amdgpu_ps <2 x float> @s_floor_f64_fneg(double inreg %x) {
 ; GFX6-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
 ; GFX6-NEXT:    v_cndmask_b32_e32 v1, v1, v3, vcc
 ; GFX6-NEXT:    v_add_f64 v[0:1], -s[2:3], -v[0:1]
+; GFX6-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX6-NEXT:    v_readfirstlane_b32 s1, v1
+; GFX6-NEXT:    v_mov_b32_e32 v0, s0
+; GFX6-NEXT:    v_mov_b32_e32 v1, s1
 ; GFX6-NEXT:    ; return to shader part epilog
 ;
 ; GFX78-LABEL: s_floor_f64_fneg:
@@ -248,6 +256,10 @@ define amdgpu_ps <2 x float> @s_floor_f64_fabs(double inreg %x) {
 ; GFX6-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
 ; GFX6-NEXT:    v_cndmask_b32_e32 v1, v1, v3, vcc
 ; GFX6-NEXT:    v_add_f64 v[0:1], |s[2:3]|, -v[0:1]
+; GFX6-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX6-NEXT:    v_readfirstlane_b32 s1, v1
+; GFX6-NEXT:    v_mov_b32_e32 v0, s0
+; GFX6-NEXT:    v_mov_b32_e32 v1, s1
 ; GFX6-NEXT:    ; return to shader part epilog
 ;
 ; GFX78-LABEL: s_floor_f64_fabs:
@@ -273,6 +285,10 @@ define amdgpu_ps <2 x float> @s_floor_f64_fneg_fabs(double inreg %x) {
 ; GFX6-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
 ; GFX6-NEXT:    v_cndmask_b32_e32 v1, v1, v3, vcc
 ; GFX6-NEXT:    v_add_f64 v[0:1], -|s[2:3]|, -v[0:1]
+; GFX6-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX6-NEXT:    v_readfirstlane_b32 s1, v1
+; GFX6-NEXT:    v_mov_b32_e32 v0, s0
+; GFX6-NEXT:    v_mov_b32_e32 v1, s1
 ; GFX6-NEXT:    ; return to shader part epilog
 ;
 ; GFX78-LABEL: s_floor_f64_fneg_fabs:
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/fpow.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/fpow.ll
index 0577117e9d9e1d..8f0613ebe688d0 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/fpow.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/fpow.ll
@@ -1480,7 +1480,8 @@ define amdgpu_ps float @v_pow_f32_sgpr_sgpr(float inreg %x, float inreg %y) {
 ; GFX6-NEXT:    v_cmp_lt_f32_e32 vcc, v0, v1
 ; GFX6-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
 ; GFX6-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX6-NEXT:    v_exp_f32_e32 v0, v0
+; GFX6-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX6-NEXT:    v_exp_f32_e32 v0, s0
 ; GFX6-NEXT:    v_mov_b32_e32 v1, 0x1f800000
 ; GFX6-NEXT:    v_cndmask_b32_e32 v1, 1.0, v1, vcc
 ; GFX6-NEXT:    v_mul_f32_e32 v0, v0, v1
@@ -1503,7 +1504,8 @@ define amdgpu_ps float @v_pow_f32_sgpr_sgpr(float inreg %x, float inreg %y) {
 ; GFX8-NEXT:    v_cmp_lt_f32_e32 vcc, v0, v1
 ; GFX8-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
 ; GFX8-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX8-NEXT:    v_exp_f32_e32 v0, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX8-NEXT:    v_exp_f32_e32 v0, s0
 ; GFX8-NEXT:    v_mov_b32_e32 v1, 0x1f800000
 ; GFX8-NEXT:    v_cndmask_b32_e32 v1, 1.0, v1, vcc
 ; GFX8-NEXT:    v_mul_f32_e32 v0, v0, v1
@@ -1526,7 +1528,8 @@ define amdgpu_ps float @v_pow_f32_sgpr_sgpr(float inreg %x, float inreg %y) {
 ; GFX9-NEXT:    v_cmp_lt_f32_e32 vcc, v0, v1
 ; GFX9-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
 ; GFX9-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX9-NEXT:    v_exp_f32_e32 v0, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX9-NEXT:    v_exp_f32_e32 v0, s0
 ; GFX9-NEXT:    v_mov_b32_e32 v1, 0x1f800000
 ; GFX9-NEXT:    v_cndmask_b32_e32 v1, 1.0, v1, vcc
 ; GFX9-NEXT:    v_mul_f32_e32 v0, v0, v1
@@ -1545,7 +1548,8 @@ define amdgpu_ps float @v_pow_f32_sgpr_sgpr(float inreg %x, float inreg %y) {
 ; GFX10-NEXT:    v_cndmask_b32_e64 v1, 0, 0x42800000, vcc_lo
 ; GFX10-NEXT:    v_add_f32_e32 v0, v0, v1
 ; GFX10-NEXT:    v_cndmask_b32_e64 v1, 1.0, 0x1f800000, vcc_lo
-; GFX10-NEXT:    v_exp_f32_e32 v0, v0
+; GFX10-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX10-NEXT:    v_exp_f32_e32 v0, s0
 ; GFX10-NEXT:    v_mul_f32_e32 v0, v0, v1
 ; GFX10-NEXT:    ; return to shader part epilog
 ;
@@ -1566,8 +1570,9 @@ define amdgpu_ps float @v_pow_f32_sgpr_sgpr(float inreg %x, float inreg %y) {
 ; GFX11-NEXT:    v_cndmask_b32_e64 v1, 0, 0x42800000, vcc_lo
 ; GFX11-NEXT:    v_add_f32_e32 v0, v0, v1
 ; GFX11-NEXT:    v_cndmask_b32_e64 v1, 1.0, 0x1f800000, vcc_lo
-; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_2)
-; GFX11-NEXT:    v_exp_f32_e32 v0, v0
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX11-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX11-NEXT:    v_exp_f32_e32 v0, s0
 ; GFX11-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX11-NEXT:    v_mul_f32_e32 v0, v0, v1
 ; GFX11-NEXT:    ; return to shader part epilog
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.interp.inreg.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.interp.inreg.ll
index de46037e96e802..aa27c5546666fe 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.interp.inreg.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.interp.inreg.ll
@@ -186,6 +186,9 @@ define amdgpu_ps half @v_interp_f16_imm_params(float inreg %i, float inreg %j) #
 ; GCN-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GCN-NEXT:    v_cvt_f16_f32_e32 v1, v1
 ; GCN-NEXT:    v_add_f16_e32 v0, v1, v0
+; GCN-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GCN-NEXT:    v_readfirstlane_b32 s0, v0
+; GCN-NEXT:    v_mov_b32_e32 v0, s0
 ; GCN-NEXT:    ; return to shader part epilog
 main_body:
   %l_p0 = call float @llvm.amdgcn.interp.inreg.p10.f16(float 0.0, float %i, float 0.0, i1 0)
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-fadd.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-fadd.mir
index 2807f971872009..172ff040e82f03 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-fadd.mir
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-fadd.mir
@@ -16,7 +16,8 @@ body: |
     ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
     ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[COPY]](s32)
     ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[COPY1]](s32)
-    ; CHECK-NEXT: [[FADD:%[0-9]+]]:vgpr(s32) = G_FADD [[COPY2]], [[COPY3]]
+    ; CHECK-NEXT: [[FADD:%[0-9]+]]:vgpr_32(s32) = G_FADD [[COPY2]], [[COPY3]]
+    ; CHECK-NEXT: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sreg_32(s32) = V_READFIRSTLANE_B32 [[FADD]](s32), implicit $exec
     %0:_(s32) = COPY $sgpr0
     %1:_(s32) = COPY $sgpr1
     %2:_(s32) = G_FADD %0, %1
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-salu-float.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-salu-float.mir
index 264c7b03aeebaf..0858e30507bebb 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-salu-float.mir
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-salu-float.mir
@@ -1,6 +1,6 @@
 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
-# RUN: llc -mtriple=amdgcn -mcpu=gfx1150 -run-pass=regbankselect %s -verify-machineinstrs -o - -regbankselect-fast | FileCheck --check-prefixes=GFX1150 %s
-# RUN: llc -mtriple=amdgcn -mcpu=gfx1150 -run-pass=regbankselect %s -verify-machineinstrs -o - -regbankselect-greedy | FileCheck --check-prefixes=GFX1150 %s
+# RUN: llc -mtriple=amdgcn -mcpu=gfx1150 -run-pass=amdgpu-regbankselect %s -verify-machineinstrs -o - -regbankselect-fast | FileCheck --check-prefixes=GFX1150 %s
+# RUN: llc -mtriple=amdgcn -mcpu=gfx1150 -run-pass=amdgpu-regbankselect %s -verify-machineinstrs -o - -regbankselect-greedy | FileCheck --check-prefixes=GFX1150 %s
 
 ---
 name:            fadd_f32
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/sdivrem.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/sdivrem.ll
index b666f45521661c..d432e84326bc83 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/sdivrem.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/sdivrem.ll
@@ -157,21 +157,23 @@ define amdgpu_kernel void @sdivrem_i64(ptr addrspace(1) %out0, ptr addrspace(1)
 ; GFX8-NEXT:    s_xor_b64 s[8:9], s[8:9], s[12:13]
 ; GFX8-NEXT:    v_cvt_f32_u32_e32 v0, s9
 ; GFX8-NEXT:    v_cvt_f32_u32_e32 v1, s8
-; GFX8-NEXT:    s_mov_b32 s3, s2
-; GFX8-NEXT:    s_xor_b64 s[10:11], s[0:1], s[2:3]
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX8-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, v0
-; GFX8-NEXT:    s_sub_u32 s14, 0, s8
-; GFX8-NEXT:    s_subb_u32 s15, 0, s9
+; GFX8-NEXT:    v_readfirstlane_b32 s3, v0
+; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, s3
+; GFX8-NEXT:    s_mov_b32 s3, s2
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX8-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX8-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s10, v0
+; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, s10
+; GFX8-NEXT:    s_xor_b64 s[10:11], s[0:1], s[2:3]
+; GFX8-NEXT:    s_sub_u32 s14, 0, s8
 ; GFX8-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX8-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s14, v3, 0
+; GFX8-NEXT:    s_subb_u32 s15, 0, s9
 ; GFX8-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s14, v4, v[1:2]
 ; GFX8-NEXT:    v_mul_hi_u32 v5, v3, v0
 ; GFX8-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s15, v3, v[1:2]
@@ -317,21 +319,23 @@ define amdgpu_kernel void @sdivrem_i64(ptr addrspace(1) %out0, ptr addrspace(1)
 ; GFX9-NEXT:    s_xor_b64 s[8:9], s[8:9], s[12:13]
 ; GFX9-NEXT:    v_cvt_f32_u32_e32 v0, s9
 ; GFX9-NEXT:    v_cvt_f32_u32_e32 v1, s8
-; GFX9-NEXT:    s_mov_b32 s3, s2
-; GFX9-NEXT:    s_xor_b64 s[10:11], s[0:1], s[2:3]
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX9-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, v0
-; GFX9-NEXT:    s_sub_u32 s14, 0, s8
-; GFX9-NEXT:    s_subb_u32 s15, 0, s9
+; GFX9-NEXT:    v_readfirstlane_b32 s3, v0
+; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, s3
+; GFX9-NEXT:    s_mov_b32 s3, s2
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX9-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX9-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX9-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX9-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s10, v0
+; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, s10
+; GFX9-NEXT:    s_xor_b64 s[10:11], s[0:1], s[2:3]
+; GFX9-NEXT:    s_sub_u32 s14, 0, s8
 ; GFX9-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX9-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s14, v3, 0
+; GFX9-NEXT:    s_subb_u32 s15, 0, s9
 ; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s14, v4, v[1:2]
 ; GFX9-NEXT:    v_mul_hi_u32 v5, v3, v0
 ; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s15, v3, v[1:2]
@@ -468,22 +472,24 @@ define amdgpu_kernel void @sdivrem_i64(ptr addrspace(1) %out0, ptr addrspace(1)
 ; GFX10-NEXT:    s_add_u32 s8, s10, s12
 ; GFX10-NEXT:    s_mov_b32 s13, s12
 ; GFX10-NEXT:    s_addc_u32 s9, s11, s12
-; GFX10-NEXT:    s_mov_b32 s3, s2
 ; GFX10-NEXT:    s_xor_b64 s[8:9], s[8:9], s[12:13]
-; GFX10-NEXT:    s_xor_b64 s[0:1], s[0:1], s[2:3]
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v0, s9
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v1, s8
-; GFX10-NEXT:    s_sub_u32 s10, 0, s8
 ; GFX10-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX10-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX10-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX10-NEXT:    v_readfirstlane_b32 s3, v0
+; GFX10-NEXT:    v_rcp_iflag_f32_e32 v0, s3
+; GFX10-NEXT:    s_mov_b32 s3, s2
+; GFX10-NEXT:    s_xor_b64 s[0:1], s[0:1], s[2:3]
 ; GFX10-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX10-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX10-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX10-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX10-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX10-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX10-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX10-NEXT:    v_readfirstlane_b32 s10, v0
+; GFX10-NEXT:    v_cvt_u32_f32_e32 v3, s10
+; GFX10-NEXT:    s_sub_u32 s10, 0, s8
 ; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s11, s10, v3, 0
 ; GFX10-NEXT:    v_mad_u64_u32 v[1:2], s11, s10, v4, v[1:2]
 ; GFX10-NEXT:    s_subb_u32 s11, 0, s9
@@ -1288,7 +1294,8 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX8-NEXT:    s_xor_b64 s[16:17], s[16:17], s[4:5]
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX8-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, s0
 ; GFX8-NEXT:    s_sub_u32 s18, 0, s12
 ; GFX8-NEXT:    s_subb_u32 s19, 0, s13
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
@@ -1296,7 +1303,8 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX8-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX8-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, s0
 ; GFX8-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX8-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s18, v3, 0
 ; GFX8-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s18, v4, v[1:2]
@@ -1415,7 +1423,8 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX8-NEXT:    v_subbrev_u32_e32 v16, vcc, 0, v0, vcc
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v14
 ; GFX8-NEXT:    v_add_f32_e32 v0, v0, v5
-; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s5, v0
+; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, s5
 ; GFX8-NEXT:    v_cmp_ne_u32_e32 vcc, 0, v11
 ; GFX8-NEXT:    v_cndmask_b32_e32 v5, v1, v12, vcc
 ; GFX8-NEXT:    s_xor_b64 s[12:13], s[0:1], s[6:7]
@@ -1424,7 +1433,8 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX8-NEXT:    v_trunc_f32_e32 v11, v1
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v11
 ; GFX8-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX8-NEXT:    v_cvt_u32_f32_e32 v12, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s5, v0
+; GFX8-NEXT:    v_cvt_u32_f32_e32 v12, s5
 ; GFX8-NEXT:    s_sub_u32 s5, 0, s2
 ; GFX8-NEXT:    s_subb_u32 s20, 0, s3
 ; GFX8-NEXT:    v_cndmask_b32_e32 v10, v10, v13, vcc
@@ -1599,7 +1609,8 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX9-NEXT:    s_xor_b64 s[16:17], s[16:17], s[4:5]
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX9-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, s0
 ; GFX9-NEXT:    s_sub_u32 s18, 0, s12
 ; GFX9-NEXT:    s_subb_u32 s19, 0, s13
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
@@ -1607,7 +1618,8 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX9-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX9-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX9-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, s0
 ; GFX9-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX9-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s18, v3, 0
 ; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s18, v4, v[1:2]
@@ -1667,7 +1679,7 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX9-NEXT:    v_mul_lo_u32 v3, s16, v1
 ; GFX9-NEXT:    v_mul_hi_u32 v4, s16, v0
 ; GFX9-NEXT:    v_mul_hi_u32 v0, s17, v0
-; GFX9-NEXT:    v_mul_hi_u32 v6, s17, v1
+; GFX9-NEXT:    v_mul_hi_u32 v5, s17, v1
 ; GFX9-NEXT:    v_add_co_u32_e32 v2, vcc, v2, v3
 ; GFX9-NEXT:    v_cndmask_b32_e64 v3, 0, 1, vcc
 ; GFX9-NEXT:    v_add_co_u32_e32 v2, vcc, v2, v4
@@ -1679,38 +1691,38 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX9-NEXT:    v_cndmask_b32_e64 v4, 0, 1, vcc
 ; GFX9-NEXT:    v_add_co_u32_e32 v0, vcc, v0, v3
 ; GFX9-NEXT:    v_cndmask_b32_e64 v3, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v5, vcc, v0, v2
-; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s12, v5, 0
+; GFX9-NEXT:    v_add_co_u32_e32 v6, vcc, v0, v2
+; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s12, v6, 0
 ; GFX9-NEXT:    v_cndmask_b32_e64 v0, 0, 1, vcc
 ; GFX9-NEXT:    v_add_u32_e32 v3, v4, v3
-; GFX9-NEXT:    v_add3_u32 v4, v3, v0, v6
+; GFX9-NEXT:    v_add3_u32 v8, v3, v0, v5
 ; GFX9-NEXT:    v_mov_b32_e32 v0, v2
-; GFX9-NEXT:    v_mad_u64_u32 v[2:3], s[0:1], s12, v4, v[0:1]
-; GFX9-NEXT:    v_mov_b32_e32 v6, s17
-; GFX9-NEXT:    v_sub_co_u32_e32 v8, vcc, s16, v1
-; GFX9-NEXT:    v_mad_u64_u32 v[2:3], s[0:1], s13, v5, v[2:3]
+; GFX9-NEXT:    v_mad_u64_u32 v[2:3], s[0:1], s12, v8, v[0:1]
+; GFX9-NEXT:    v_mov_b32_e32 v5, s17
+; GFX9-NEXT:    v_sub_co_u32_e32 v1, vcc, s16, v1
+; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[0:1], s13, v6, v[2:3]
 ; GFX9-NEXT:    s_ashr_i32 s16, s3, 31
 ; GFX9-NEXT:    v_mov_b32_e32 v0, 0
-; GFX9-NEXT:    v_subb_co_u32_e64 v6, s[0:1], v6, v2, vcc
-; GFX9-NEXT:    v_sub_u32_e32 v1, s17, v2
-; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s13, v6
-; GFX9-NEXT:    v_cndmask_b32_e64 v2, 0, -1, s[0:1]
-; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s12, v8
-; GFX9-NEXT:    v_subb_co_u32_e32 v1, vcc, v1, v7, vcc
-; GFX9-NEXT:    v_cndmask_b32_e64 v3, 0, -1, s[0:1]
-; GFX9-NEXT:    v_cmp_eq_u32_e64 s[0:1], s13, v6
-; GFX9-NEXT:    v_subrev_co_u32_e32 v10, vcc, s12, v8
-; GFX9-NEXT:    v_cndmask_b32_e64 v9, v2, v3, s[0:1]
-; GFX9-NEXT:    v_subbrev_co_u32_e64 v11, s[0:1], 0, v1, vcc
-; GFX9-NEXT:    v_add_co_u32_e64 v3, s[0:1], 1, v5
-; GFX9-NEXT:    v_addc_co_u32_e64 v12, s[0:1], 0, v4, s[0:1]
+; GFX9-NEXT:    v_subb_co_u32_e64 v2, s[0:1], v5, v3, vcc
+; GFX9-NEXT:    v_sub_u32_e32 v3, s17, v3
+; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s13, v2
+; GFX9-NEXT:    v_cndmask_b32_e64 v4, 0, -1, s[0:1]
+; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s12, v1
+; GFX9-NEXT:    v_subb_co_u32_e32 v3, vcc, v3, v7, vcc
+; GFX9-NEXT:    v_cndmask_b32_e64 v5, 0, -1, s[0:1]
+; GFX9-NEXT:    v_cmp_eq_u32_e64 s[0:1], s13, v2
+; GFX9-NEXT:    v_subrev_co_u32_e32 v10, vcc, s12, v1
+; GFX9-NEXT:    v_cndmask_b32_e64 v9, v4, v5, s[0:1]
+; GFX9-NEXT:    v_subbrev_co_u32_e64 v11, s[0:1], 0, v3, vcc
+; GFX9-NEXT:    v_add_co_u32_e64 v5, s[0:1], 1, v6
+; GFX9-NEXT:    v_addc_co_u32_e64 v12, s[0:1], 0, v8, s[0:1]
 ; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s13, v11
-; GFX9-NEXT:    v_cndmask_b32_e64 v2, 0, -1, s[0:1]
+; GFX9-NEXT:    v_cndmask_b32_e64 v4, 0, -1, s[0:1]
 ; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s12, v10
 ; GFX9-NEXT:    v_cndmask_b32_e64 v13, 0, -1, s[0:1]
 ; GFX9-NEXT:    v_cmp_eq_u32_e64 s[0:1], s13, v11
-; GFX9-NEXT:    v_cndmask_b32_e64 v13, v2, v13, s[0:1]
-; GFX9-NEXT:    v_add_co_u32_e64 v14, s[0:1], 1, v3
+; GFX9-NEXT:    v_cndmask_b32_e64 v13, v4, v13, s[0:1]
+; GFX9-NEXT:    v_add_co_u32_e64 v14, s[0:1], 1, v5
 ; GFX9-NEXT:    v_addc_co_u32_e64 v15, s[0:1], 0, v12, s[0:1]
 ; GFX9-NEXT:    s_add_u32 s0, s14, s6
 ; GFX9-NEXT:    s_addc_u32 s1, s15, s6
@@ -1718,116 +1730,118 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX9-NEXT:    s_mov_b32 s17, s16
 ; GFX9-NEXT:    s_addc_u32 s3, s3, s16
 ; GFX9-NEXT:    s_xor_b64 s[2:3], s[2:3], s[16:17]
-; GFX9-NEXT:    v_cvt_f32_u32_e32 v2, s3
+; GFX9-NEXT:    v_cvt_f32_u32_e32 v4, s3
 ; GFX9-NEXT:    v_cvt_f32_u32_e32 v16, s2
-; GFX9-NEXT:    v_subb_co_u32_e32 v1, vcc, v1, v7, vcc
-; GFX9-NEXT:    v_mul_f32_e32 v2, 0x4f800000, v2
-; GFX9-NEXT:    v_add_f32_e32 v2, v2, v16
-; GFX9-NEXT:    v_rcp_iflag_f32_e32 v2, v2
+; GFX9-NEXT:    v_subb_co_u32_e32 v3, vcc, v3, v7, vcc
+; GFX9-NEXT:    v_mul_f32_e32 v4, 0x4f800000, v4
+; GFX9-NEXT:    v_add_f32_e32 v4, v4, v16
+; GFX9-NEXT:    v_readfirstlane_b32 s5, v4
+; GFX9-NEXT:    v_rcp_iflag_f32_e32 v4, s5
 ; GFX9-NEXT:    v_subrev_co_u32_e32 v7, vcc, s12, v10
-; GFX9-NEXT:    v_subbrev_co_u32_e32 v16, vcc, 0, v1, vcc
-; GFX9-NEXT:    v_mul_f32_e32 v1, 0x5f7ffffc, v2
-; GFX9-NEXT:    v_mul_f32_e32 v2, 0x2f800000, v1
-; GFX9-NEXT:    v_trunc_f32_e32 v17, v2
-; GFX9-NEXT:    v_mul_f32_e32 v2, 0xcf800000, v17
-; GFX9-NEXT:    v_add_f32_e32 v1, v2, v1
-; GFX9-NEXT:    v_cvt_u32_f32_e32 v18, v1
+; GFX9-NEXT:    v_subbrev_co_u32_e32 v16, vcc, 0, v3, vcc
+; GFX9-NEXT:    v_mul_f32_e32 v3, 0x5f7ffffc, v4
+; GFX9-NEXT:    v_mul_f32_e32 v4, 0x2f800000, v3
+; GFX9-NEXT:    v_trunc_f32_e32 v17, v4
+; GFX9-NEXT:    v_mul_f32_e32 v4, 0xcf800000, v17
+; GFX9-NEXT:    v_add_f32_e32 v3, v4, v3
+; GFX9-NEXT:    v_readfirstlane_b32 s5, v3
+; GFX9-NEXT:    v_cvt_u32_f32_e32 v18, s5
 ; GFX9-NEXT:    s_xor_b64 s[12:13], s[0:1], s[6:7]
 ; GFX9-NEXT:    s_sub_u32 s5, 0, s2
 ; GFX9-NEXT:    v_cmp_ne_u32_e32 vcc, 0, v13
-; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s5, v18, 0
-; GFX9-NEXT:    v_cndmask_b32_e32 v13, v3, v14, vcc
+; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[0:1], s5, v18, 0
+; GFX9-NEXT:    v_cndmask_b32_e32 v13, v5, v14, vcc
 ; GFX9-NEXT:    v_cvt_u32_f32_e32 v14, v17
 ; GFX9-NEXT:    s_subb_u32 s20, 0, s3
 ; GFX9-NEXT:    v_cndmask_b32_e32 v12, v12, v15, vcc
 ; GFX9-NEXT:    v_cndmask_b32_e32 v7, v10, v7, vcc
-; GFX9-NEXT:    v_mad_u64_u32 v[2:3], s[0:1], s5, v14, v[2:3]
+; GFX9-NEXT:    v_mad_u64_u32 v[4:5], s[0:1], s5, v14, v[4:5]
 ; GFX9-NEXT:    v_cmp_ne_u32_e64 s[0:1], 0, v9
-; GFX9-NEXT:    v_cndmask_b32_e64 v9, v4, v12, s[0:1]
-; GFX9-NEXT:    v_mad_u64_u32 v[2:3], s[14:15], s20, v18, v[2:3]
-; GFX9-NEXT:    v_mul_lo_u32 v3, v14, v1
 ; GFX9-NEXT:    v_cndmask_b32_e32 v10, v11, v16, vcc
-; GFX9-NEXT:    v_mul_lo_u32 v4, v18, v2
-; GFX9-NEXT:    v_mul_hi_u32 v11, v18, v1
-; GFX9-NEXT:    v_mul_hi_u32 v1, v14, v1
-; GFX9-NEXT:    v_cndmask_b32_e64 v5, v5, v13, s[0:1]
-; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v4
-; GFX9-NEXT:    v_cndmask_b32_e64 v4, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v11
-; GFX9-NEXT:    v_cndmask_b32_e64 v3, 0, 1, vcc
-; GFX9-NEXT:    v_mul_lo_u32 v11, v14, v2
-; GFX9-NEXT:    v_add_u32_e32 v3, v4, v3
-; GFX9-NEXT:    v_mul_hi_u32 v4, v18, v2
-; GFX9-NEXT:    v_mul_hi_u32 v2, v14, v2
-; GFX9-NEXT:    v_add_co_u32_e32 v1, vcc, v11, v1
-; GFX9-NEXT:    v_cndmask_b32_e64 v11, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v1, vcc, v1, v4
-; GFX9-NEXT:    v_cndmask_b32_e64 v4, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v1, vcc, v1, v3
-; GFX9-NEXT:    v_add_u32_e32 v4, v11, v4
-; GFX9-NEXT:    v_cndmask_b32_e64 v3, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v11, vcc, v18, v1
-; GFX9-NEXT:    v_add3_u32 v2, v4, v3, v2
-; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[14:15], s5, v11, 0
-; GFX9-NEXT:    v_addc_co_u32_e32 v12, vcc, v14, v2, vcc
-; GFX9-NEXT:    v_mov_b32_e32 v1, v4
-; GFX9-NEXT:    v_cndmask_b32_e64 v7, v8, v7, s[0:1]
-; GFX9-NEXT:    v_cndmask_b32_e64 v6, v6, v10, s[0:1]
-; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s5, v12, v[1:2]
-; GFX9-NEXT:    v_xor_b32_e32 v8, s18, v5
-; GFX9-NEXT:    v_xor_b32_e32 v9, s19, v9
-; GFX9-NEXT:    v_mad_u64_u32 v[4:5], s[0:1], s20, v11, v[1:2]
-; GFX9-NEXT:    v_mov_b32_e32 v10, s19
-; GFX9-NEXT:    v_subrev_co_u32_e32 v1, vcc, s18, v8
-; GFX9-NEXT:    v_xor_b32_e32 v5, s4, v7
-; GFX9-NEXT:    v_mul_lo_u32 v7, v12, v3
-; GFX9-NEXT:    v_mul_lo_u32 v8, v11, v4
-; GFX9-NEXT:    v_subb_co_u32_e32 v2, vcc, v9, v10, vcc
-; GFX9-NEXT:    v_mul_hi_u32 v9, v11, v3
-; GFX9-NEXT:    v_add_co_u32_e32 v7, vcc, v7, v8
+; GFX9-NEXT:    v_mad_u64_u32 v[4:5], s[14:15], s20, v18, v[4:5]
+; GFX9-NEXT:    v_cndmask_b32_e64 v5, v8, v12, s[0:1]
+; GFX9-NEXT:    v_mul_lo_u32 v8, v14, v3
+; GFX9-NEXT:    v_mul_lo_u32 v9, v18, v4
+; GFX9-NEXT:    v_mul_hi_u32 v11, v18, v3
+; GFX9-NEXT:    v_mul_hi_u32 v3, v14, v3
+; GFX9-NEXT:    v_cndmask_b32_e64 v7, v1, v7, s[0:1]
+; GFX9-NEXT:    v_add_co_u32_e32 v8, vcc, v8, v9
+; GFX9-NEXT:    v_cndmask_b32_e64 v9, 0, 1, vcc
+; GFX9-NEXT:    v_add_co_u32_e32 v8, vcc, v8, v11
 ; GFX9-NEXT:    v_cndmask_b32_e64 v8, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v7, vcc, v7, v9
-; GFX9-NEXT:    v_cndmask_b32_e64 v7, 0, 1, vcc
-; GFX9-NEXT:    v_mul_lo_u32 v9, v12, v4
-; GFX9-NEXT:    v_mul_hi_u32 v3, v12, v3
-; GFX9-NEXT:    v_add_u32_e32 v7, v8, v7
-; GFX9-NEXT:    v_mul_hi_u32 v8, v11, v4
-; GFX9-NEXT:    v_mul_hi_u32 v4, v12, v4
-; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v9, v3
+; GFX9-NEXT:    v_mul_lo_u32 v11, v14, v4
+; GFX9-NEXT:    v_add_u32_e32 v8, v9, v8
+; GFX9-NEXT:    v_mul_hi_u32 v9, v18, v4
+; GFX9-NEXT:    v_mul_hi_u32 v4, v14, v4
+; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v11, v3
+; GFX9-NEXT:    v_cndmask_b32_e64 v11, 0, 1, vcc
+; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v9
 ; GFX9-NEXT:    v_cndmask_b32_e64 v9, 0, 1, vcc
 ; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v8
+; GFX9-NEXT:    v_add_u32_e32 v9, v11, v9
 ; GFX9-NEXT:    v_cndmask_b32_e64 v8, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v7
-; GFX9-NEXT:    v_add_u32_e32 v8, v9, v8
+; GFX9-NEXT:    v_add3_u32 v4, v9, v8, v4
+; GFX9-NEXT:    v_add_co_u32_e32 v8, vcc, v18, v3
+; GFX9-NEXT:    v_addc_co_u32_e32 v9, vcc, v14, v4, vcc
+; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[14:15], s5, v8, 0
+; GFX9-NEXT:    v_cndmask_b32_e64 v6, v6, v13, s[0:1]
+; GFX9-NEXT:    v_cndmask_b32_e64 v10, v2, v10, s[0:1]
+; GFX9-NEXT:    v_mov_b32_e32 v1, v4
+; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s5, v9, v[1:2]
+; GFX9-NEXT:    v_xor_b32_e32 v11, s19, v5
+; GFX9-NEXT:    v_xor_b32_e32 v6, s18, v6
+; GFX9-NEXT:    v_mad_u64_u32 v[4:5], s[0:1], s20, v8, v[1:2]
+; GFX9-NEXT:    v_mov_b32_e32 v12, s19
+; GFX9-NEXT:    v_subrev_co_u32_e32 v1, vcc, s18, v6
+; GFX9-NEXT:    v_xor_b32_e32 v5, s4, v7
+; GFX9-NEXT:    v_mul_lo_u32 v6, v9, v3
+; GFX9-NEXT:    v_mul_lo_u32 v7, v8, v4
+; GFX9-NEXT:    v_subb_co_u32_e32 v2, vcc, v11, v12, vcc
+; GFX9-NEXT:    v_mul_hi_u32 v11, v8, v3
+; GFX9-NEXT:    v_add_co_u32_e32 v6, vcc, v6, v7
 ; GFX9-NEXT:    v_cndmask_b32_e64 v7, 0, 1, vcc
-; GFX9-NEXT:    v_add3_u32 v4, v8, v7, v4
+; GFX9-NEXT:    v_add_co_u32_e32 v6, vcc, v6, v11
+; GFX9-NEXT:    v_cndmask_b32_e64 v6, 0, 1, vcc
+; GFX9-NEXT:    v_mul_lo_u32 v11, v9, v4
+; GFX9-NEXT:    v_mul_hi_u32 v3, v9, v3
+; GFX9-NEXT:    v_add_u32_e32 v6, v7, v6
+; GFX9-NEXT:    v_mul_hi_u32 v7, v8, v4
+; GFX9-NEXT:    v_mul_hi_u32 v4, v9, v4
 ; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v11, v3
-; GFX9-NEXT:    v_addc_co_u32_e32 v4, vcc, v12, v4, vcc
-; GFX9-NEXT:    v_mul_lo_u32 v7, s13, v3
-; GFX9-NEXT:    v_mul_lo_u32 v8, s12, v4
-; GFX9-NEXT:    v_mul_hi_u32 v10, s12, v3
+; GFX9-NEXT:    v_cndmask_b32_e64 v11, 0, 1, vcc
+; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v7
+; GFX9-NEXT:    v_cndmask_b32_e64 v7, 0, 1, vcc
+; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v6
+; GFX9-NEXT:    v_add_u32_e32 v7, v11, v7
+; GFX9-NEXT:    v_cndmask_b32_e64 v6, 0, 1, vcc
+; GFX9-NEXT:    v_add3_u32 v4, v7, v6, v4
+; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v8, v3
+; GFX9-NEXT:    v_addc_co_u32_e32 v4, vcc, v9, v4, vcc
+; GFX9-NEXT:    v_mul_lo_u32 v6, s13, v3
+; GFX9-NEXT:    v_mul_lo_u32 v7, s12, v4
+; GFX9-NEXT:    v_mul_hi_u32 v9, s12, v3
 ; GFX9-NEXT:    v_mul_hi_u32 v3, s13, v3
-; GFX9-NEXT:    v_mul_hi_u32 v12, s13, v4
-; GFX9-NEXT:    v_add_co_u32_e32 v7, vcc, v7, v8
-; GFX9-NEXT:    v_cndmask_b32_e64 v8, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v7, vcc, v7, v10
+; GFX9-NEXT:    v_mul_hi_u32 v13, s13, v4
+; GFX9-NEXT:    v_add_co_u32_e32 v6, vcc, v6, v7
 ; GFX9-NEXT:    v_cndmask_b32_e64 v7, 0, 1, vcc
-; GFX9-NEXT:    v_mul_lo_u32 v10, s13, v4
-; GFX9-NEXT:    v_add_u32_e32 v7, v8, v7
-; GFX9-NEXT:    v_mul_hi_u32 v8, s12, v4
-; GFX9-NEXT:    v_xor_b32_e32 v6, s4, v6
-; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v10, v3
-; GFX9-NEXT:    v_cndmask_b32_e64 v10, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v8
-; GFX9-NEXT:    v_cndmask_b32_e64 v8, 0, 1, vcc
-; GFX9-NEXT:    v_add_co_u32_e32 v11, vcc, v3, v7
-; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[0:1], s2, v11, 0
-; GFX9-NEXT:    v_mov_b32_e32 v9, s4
+; GFX9-NEXT:    v_add_co_u32_e32 v6, vcc, v6, v9
+; GFX9-NEXT:    v_cndmask_b32_e64 v6, 0, 1, vcc
+; GFX9-NEXT:    v_mul_lo_u32 v9, s13, v4
+; GFX9-NEXT:    v_add_u32_e32 v6, v7, v6
+; GFX9-NEXT:    v_mul_hi_u32 v7, s12, v4
+; GFX9-NEXT:    v_xor_b32_e32 v10, s4, v10
+; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v9, v3
+; GFX9-NEXT:    v_cndmask_b32_e64 v9, 0, 1, vcc
+; GFX9-NEXT:    v_add_co_u32_e32 v3, vcc, v3, v7
 ; GFX9-NEXT:    v_cndmask_b32_e64 v7, 0, 1, vcc
+; GFX9-NEXT:    v_add_co_u32_e32 v11, vcc, v3, v6
+; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[0:1], s2, v11, 0
+; GFX9-NEXT:    v_cndmask_b32_e64 v12, 0, 1, vcc
+; GFX9-NEXT:    v_add_u32_e32 v7, v9, v7
+; GFX9-NEXT:    v_mov_b32_e32 v8, s4
 ; GFX9-NEXT:    v_subrev_co_u32_e32 v5, vcc, s4, v5
-; GFX9-NEXT:    v_add_u32_e32 v8, v10, v8
-; GFX9-NEXT:    v_subb_co_u32_e32 v6, vcc, v6, v9, vcc
-; GFX9-NEXT:    v_add3_u32 v9, v8, v7, v12
+; GFX9-NEXT:    v_add3_u32 v9, v7, v12, v13
+; GFX9-NEXT:    v_subb_co_u32_e32 v6, vcc, v10, v8, vcc
 ; GFX9-NEXT:    v_mad_u64_u32 v[7:8], s[0:1], s2, v9, v[4:5]
 ; GFX9-NEXT:    v_mov_b32_e32 v10, s13
 ; GFX9-NEXT:    v_sub_co_u32_e32 v3, vcc, s12, v3
@@ -1904,45 +1918,49 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX10-NEXT:    s_ashr_i32 s12, s15, 31
 ; GFX10-NEXT:    s_xor_b64 s[18:19], s[4:5], s[16:17]
 ; GFX10-NEXT:    s_ashr_i32 s16, s3, 31
-; GFX10-NEXT:    s_add_u32 s14, s14, s12
-; GFX10-NEXT:    s_addc_u32 s15, s15, s12
+; GFX10-NEXT:    s_add_u32 s22, s14, s12
+; GFX10-NEXT:    s_addc_u32 s23, s15, s12
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v0, s6
 ; GFX10-NEXT:    v_mul_f32_e32 v1, 0x4f800000, v1
 ; GFX10-NEXT:    s_add_u32 s2, s2, s16
 ; GFX10-NEXT:    s_mov_b32 s17, s16
 ; GFX10-NEXT:    s_addc_u32 s3, s3, s16
 ; GFX10-NEXT:    s_mov_b32 s13, s12
-; GFX10-NEXT:    s_xor_b64 s[2:3], s[2:3], s[16:17]
+; GFX10-NEXT:    s_xor_b64 s[14:15], s[2:3], s[16:17]
 ; GFX10-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX10-NEXT:    v_cvt_f32_u32_e32 v1, s3
-; GFX10-NEXT:    v_cvt_f32_u32_e32 v2, s2
-; GFX10-NEXT:    s_xor_b64 s[14:15], s[14:15], s[12:13]
-; GFX10-NEXT:    v_rcp_iflag_f32_e32 v0, v0
-; GFX10-NEXT:    v_mul_f32_e32 v1, 0x4f800000, v1
-; GFX10-NEXT:    v_add_f32_e32 v1, v1, v2
-; GFX10-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
-; GFX10-NEXT:    v_rcp_iflag_f32_e32 v1, v1
+; GFX10-NEXT:    v_cvt_f32_u32_e32 v1, s15
+; GFX10-NEXT:    v_cvt_f32_u32_e32 v2, s14
+; GFX10-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX10-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v1
+; GFX10-NEXT:    v_rcp_iflag_f32_e32 v1, s2
+; GFX10-NEXT:    v_add_f32_e32 v0, v0, v2
+; GFX10-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX10-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v1
+; GFX10-NEXT:    v_rcp_iflag_f32_e32 v1, s2
 ; GFX10-NEXT:    v_mul_f32_e32 v2, 0x2f800000, v0
 ; GFX10-NEXT:    v_trunc_f32_e32 v2, v2
-; GFX10-NEXT:    v_mul_f32_e32 v3, 0x5f7ffffc, v1
-; GFX10-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
-; GFX10-NEXT:    v_mul_f32_e32 v4, 0x2f800000, v3
+; GFX10-NEXT:    v_mul_f32_e32 v1, 0x5f7ffffc, v1
+; GFX10-NEXT:    v_mul_f32_e32 v3, 0xcf800000, v2
+; GFX10-NEXT:    v_mul_f32_e32 v4, 0x2f800000, v1
 ; GFX10-NEXT:    v_cvt_u32_f32_e32 v9, v2
-; GFX10-NEXT:    v_add_f32_e32 v0, v1, v0
+; GFX10-NEXT:    v_add_f32_e32 v0, v3, v0
 ; GFX10-NEXT:    v_trunc_f32_e32 v6, v4
-; GFX10-NEXT:    v_cvt_u32_f32_e32 v7, v0
-; GFX10-NEXT:    v_mul_f32_e32 v4, 0xcf800000, v6
-; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s5, s21, v7, 0
-; GFX10-NEXT:    v_add_f32_e32 v3, v4, v3
-; GFX10-NEXT:    s_sub_u32 s5, 0, s2
-; GFX10-NEXT:    v_cvt_u32_f32_e32 v8, v3
+; GFX10-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX10-NEXT:    v_mul_f32_e32 v0, 0xcf800000, v6
+; GFX10-NEXT:    v_cvt_u32_f32_e32 v7, s2
+; GFX10-NEXT:    v_add_f32_e32 v3, v0, v1
+; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s2, s21, v7, 0
+; GFX10-NEXT:    v_readfirstlane_b32 s5, v3
+; GFX10-NEXT:    s_xor_b64 s[2:3], s[22:23], s[12:13]
+; GFX10-NEXT:    v_cvt_u32_f32_e32 v8, s5
+; GFX10-NEXT:    s_sub_u32 s5, 0, s14
 ; GFX10-NEXT:    v_mul_hi_u32 v10, v9, v0
 ; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s22, s5, v8, 0
 ; GFX10-NEXT:    v_mad_u64_u32 v[4:5], s22, s21, v9, v[1:2]
 ; GFX10-NEXT:    v_cvt_u32_f32_e32 v5, v6
 ; GFX10-NEXT:    v_mov_b32_e32 v1, v3
 ; GFX10-NEXT:    v_mul_hi_u32 v6, v7, v0
-; GFX10-NEXT:    s_subb_u32 s22, 0, s3
+; GFX10-NEXT:    s_subb_u32 s22, 0, s15
 ; GFX10-NEXT:    v_mul_hi_u32 v12, v8, v2
 ; GFX10-NEXT:    v_mul_lo_u32 v11, v5, v2
 ; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s23, s20, v7, v[4:5]
@@ -2030,144 +2048,144 @@ define amdgpu_kernel void @sdivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX10-NEXT:    v_cndmask_b32_e64 v11, 0, 1, s5
 ; GFX10-NEXT:    v_add_co_u32 v2, s5, v2, v17
 ; GFX10-NEXT:    v_add3_u32 v1, v4, v5, v1
-; GFX10-NEXT:    v_add_co_u32 v3, vcc_lo, v6, v3
-; GFX10-NEXT:    v_add_nc_u32_e32 v4, v12, v11
 ; GFX10-NEXT:    v_cndmask_b32_e64 v13, 0, 1, s5
+; GFX10-NEXT:    v_add_nc_u32_e32 v4, v12, v11
+; GFX10-NEXT:    v_add_co_u32 v3, vcc_lo, v6, v3
 ; GFX10-NEXT:    v_add_co_ci_u32_e32 v1, vcc_lo, v7, v1, vcc_lo
-; GFX10-NEXT:    v_mul_lo_u32 v6, s1, v3
 ; GFX10-NEXT:    v_add_co_u32 v2, s5, v2, v4
 ; GFX10-NEXT:    v_add_nc_u32_e32 v5, v14, v13
 ; GFX10-NEXT:    v_cndmask_b32_e64 v4, 0, 1, s5
+; GFX10-NEXT:    v_mul_lo_u32 v6, s1, v3
 ; GFX10-NEXT:    v_mul_lo_u32 v11, s0, v1
 ; GFX10-NEXT:    v_mul_hi_u32 v7, s0, v3
 ; GFX10-NEXT:    v_mul_hi_u32 v3, s1, v3
-; GFX10-NEXT:    v_mul_lo_u32 v12, s1, v1
 ; GFX10-NEXT:    v_add3_u32 v0, v5, v4, v0
+; GFX10-NEXT:    v_mul_lo_u32 v12, s1, v1
 ; GFX10-NEXT:    v_add_co_u32 v2, vcc_lo, v8, v2
 ; GFX10-NEXT:    v_mul_hi_u32 v4, s0, v1
-; GFX10-NEXT:    v_mul_hi_u32 v5, s1, v1
-; GFX10-NEXT:    v_add_co_u32 v1, s5, v6, v11
 ; GFX10-NEXT:    v_add_co_ci_u32_e32 v8, vcc_lo, v9, v0, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e64 v6, 0, 1, s5
+; GFX10-NEXT:    v_add_co_u32 v6, s5, v6, v11
+; GFX10-NEXT:    v_mul_lo_u32 v0, s3, v2
+; GFX10-NEXT:    v_cndmask_b32_e64 v9, 0, 1, s5
 ; GFX10-NEXT:    v_add_co_u32 v3, s5, v12, v3
+; GFX10-NEXT:    v_mul_lo_u32 v12, s2, v8
 ; GFX10-NEXT:    v_cndmask_b32_e64 v11, 0, 1, s5
-; GFX10-NEXT:    v_add_co_u32 v1, s5, v1, v7
-; GFX10-NEXT:    v_mul_lo_u32 v0, s15, v2
-; GFX10-NEXT:    v_mul_lo_u32 v12, s14, v8
-; GFX10-NEXT:    v_cndmask_b32_e64 v1, 0, 1, s5
+; GFX10-NEXT:    v_add_co_u32 v6, s5, v6, v7
+; GFX10-NEXT:    v_cndmask_b32_e64 v6, 0, 1, s5
+; GFX10-NEXT:    v_mul_hi_u32 v5, s1, v1
+; GFX10-NEXT:    v_mul_hi_u32 v1, s2, v2
 ; GFX10-NEXT:    v_add_co_u32 v3, s5, v3, v4
-; GFX10-NEXT:    v_mul_hi_u32 v9, s14, v2
+; GFX10-NEXT:    v_mul_hi_u32 v2, s3, v2
+; GFX10-NEXT:    v_mul_lo_u32 v7, s3, v8
 ; GFX10-NEXT:    v_cndmask_b32_e64 v4, 0, 1, s5
-; GFX10-NEXT:    v_mul_hi_u32 v2, s15, v2
-; GFX10-NEXT:    v_mul_lo_u32 v7, s15, v8
-; GFX10-NEXT:    v_add_nc_u32_e32 v1, v6, v1
-; GFX10-NEXT:    v_add_co_u32 v6, s5, v0, v12
-; GFX10-NEXT:    v_mul_hi_u32 v13, s14, v8
+; GFX10-NEXT:    v_add_co_u32 v0, s5, v0, v12
+; GFX10-NEXT:    v_add_nc_u32_e32 v6, v9, v6
+; GFX10-NEXT:    v_mul_hi_u32 v13, s2, v8
+; GFX10-NEXT:    v_cndmask_b32_e64 v9, 0, 1, s5
+; GFX10-NEXT:    v_add_co_u32 v0, s20, v0, v1
+; GFX10-NEXT:    v_add_co_u32 v6, s5, v3, v6
+; GFX10-NEXT:    v_cndmask_b32_e64 v3, 0, 1, s20
+; GFX10-NEXT:    v_add_co_u32 v2, s20, v7, v2
 ; GFX10-NEXT:    v_add_nc_u32_e32 v4, v11, v4
 ; GFX10-NEXT:    v_cndmask_b32_e64 v11, 0, 1, s5
-; GFX10-NEXT:    v_add_co_u32 v12, s5, v3, v1
-; GFX10-NEXT:    v_add_co_u32 v2, s20, v7, v2
-; GFX10-NEXT:    v_cndmask_b32_e64 v7, 0, 1, s5
-; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s5, s6, v12, 0
-; GFX10-NEXT:    v_add_co_u32 v6, s5, v6, v9
-; GFX10-NEXT:    v_cndmask_b32_e64 v6, 0, 1, s5
-; GFX10-NEXT:    v_add_co_u32 v9, s5, v2, v13
-; GFX10-NEXT:    v_cndmask_b32_e64 v3, 0, 1, s20
-; GFX10-NEXT:    v_cndmask_b32_e64 v2, 0, 1, s5
-; GFX10-NEXT:    v_add3_u32 v4, v4, v7, v5
-; GFX10-NEXT:    v_add_nc_u32_e32 v6, v11, v6
-; GFX10-NEXT:    v_mul_hi_u32 v5, s15, v8
-; GFX10-NEXT:    v_add_co_u32 v7, vcc_lo, v12, 1
-; GFX10-NEXT:    v_add_nc_u32_e32 v3, v3, v2
-; GFX10-NEXT:    v_mad_u64_u32 v[1:2], s5, s6, v4, v[1:2]
-; GFX10-NEXT:    v_add_co_u32 v6, s5, v9, v6
+; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s5, s6, v6, 0
+; GFX10-NEXT:    v_add_nc_u32_e32 v3, v9, v3
+; GFX10-NEXT:    v_add_co_u32 v2, s5, v2, v13
+; GFX10-NEXT:    v_cndmask_b32_e64 v7, 0, 1, s20
+; GFX10-NEXT:    v_cndmask_b32_e64 v9, 0, 1, s5
+; GFX10-NEXT:    v_add3_u32 v11, v4, v11, v5
+; GFX10-NEXT:    v_add_co_u32 v12, s5, v2, v3
+; GFX10-NEXT:    v_mul_hi_u32 v8, s3, v8
+; GFX10-NEXT:    v_add_nc_u32_e32 v7, v7, v9
 ; GFX10-NEXT:    v_cndmask_b32_e64 v9, 0, 1, s5
-; GFX10-NEXT:    v_add_co_ci_u32_e32 v8, vcc_lo, 0, v4, vcc_lo
-; GFX10-NEXT:    v_add_co_u32 v11, vcc_lo, v7, 1
-; GFX10-NEXT:    v_mad_u64_u32 v[1:2], s5, s7, v12, v[1:2]
-; GFX10-NEXT:    v_add3_u32 v5, v3, v9, v5
-; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s5, s2, v6, 0
-; GFX10-NEXT:    v_add_co_ci_u32_e32 v13, vcc_lo, 0, v8, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v14, vcc_lo, s0, v0
-; GFX10-NEXT:    v_sub_nc_u32_e32 v9, s1, v1
-; GFX10-NEXT:    v_sub_co_ci_u32_e64 v15, s0, s1, v1, vcc_lo
-; GFX10-NEXT:    v_mov_b32_e32 v0, v3
-; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v9, vcc_lo, s7, v9, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v3, vcc_lo, v14, s6
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v16, s0, 0, v9, vcc_lo
-; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s6, v14
-; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v9, vcc_lo, s7, v9, vcc_lo
+; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s5, s14, v12, 0
+; GFX10-NEXT:    v_add3_u32 v7, v7, v9, v8
+; GFX10-NEXT:    v_mad_u64_u32 v[4:5], s5, s6, v11, v[1:2]
+; GFX10-NEXT:    v_add_co_u32 v5, vcc_lo, v6, 1
+; GFX10-NEXT:    v_add_co_ci_u32_e32 v13, vcc_lo, 0, v11, vcc_lo
+; GFX10-NEXT:    v_mov_b32_e32 v1, v3
+; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s5, s7, v6, v[4:5]
+; GFX10-NEXT:    v_add_co_u32 v4, vcc_lo, v5, 1
+; GFX10-NEXT:    v_add_co_ci_u32_e32 v8, vcc_lo, 0, v13, vcc_lo
+; GFX10-NEXT:    v_sub_co_u32 v9, vcc_lo, s0, v0
+; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s0, s14, v7, v[1:2]
+; GFX10-NEXT:    v_sub_nc_u32_e32 v1, s1, v3
+; GFX10-NEXT:    v_sub_co_ci_u32_e64 v3, s0, s1, v3, vcc_lo
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s6, v9
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v15, vcc_lo, s7, v1, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e64 v14, 0, -1, s0
+; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s0, s15, v12, v[0:1]
+; GFX10-NEXT:    v_sub_co_u32 v1, vcc_lo, v9, s6
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v16, s0, 0, v15, vcc_lo
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s7, v3
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v15, vcc_lo, s7, v15, vcc_lo
+; GFX10-NEXT:    v_cmp_eq_u32_e32 vcc_lo, s7, v16
 ; GFX10-NEXT:    v_cndmask_b32_e64 v17, 0, -1, s0
-; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s6, v3
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s6, v1
 ; GFX10-NEXT:    v_cndmask_b32_e64 v18, 0, -1, s0
 ; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s7, v16
 ; GFX10-NEXT:    v_cndmask_b32_e64 v19, 0, -1, s0
-; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s7, v15
-; GFX10-NEXT:    v_cndmask_b32_e64 v20, 0, -1, s0
-; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s0, s2, v5, v[0:1]
-; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s7, v16
-; GFX10-NEXT:    v_cndmask_b32_e64 v1, v19, v18, s0
-; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s7, v15
-; GFX10-NEXT:    v_cmp_ne_u32_e32 vcc_lo, 0, v1
-; GFX10-NEXT:    v_cndmask_b32_e64 v17, v20, v17, s0
-; GFX10-NEXT:    v_sub_co_u32 v1, s0, v3, s6
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v9, s0, 0, v9, s0
-; GFX10-NEXT:    v_cndmask_b32_e32 v7, v7, v11, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e32 v3, v3, v1, vcc_lo
-; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s1, s3, v6, v[0:1]
+; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s7, v3
+; GFX10-NEXT:    v_cndmask_b32_e64 v14, v17, v14, s0
+; GFX10-NEXT:    v_cndmask_b32_e32 v17, v19, v18, vcc_lo
+; GFX10-NEXT:    v_sub_co_u32 v2, vcc_lo, s2, v2
+; GFX10-NEXT:    v_sub_co_ci_u32_e64 v18, s0, s3, v0, vcc_lo
 ; GFX10-NEXT:    v_cmp_ne_u32_e64 s0, 0, v17
-; GFX10-NEXT:    v_cndmask_b32_e32 v8, v8, v13, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e64 v1, v12, v7, s0
-; GFX10-NEXT:    v_cndmask_b32_e32 v7, v16, v9, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v2, vcc_lo, s14, v2
-; GFX10-NEXT:    v_cndmask_b32_e64 v4, v4, v8, s0
-; GFX10-NEXT:    v_sub_co_ci_u32_e64 v8, s1, s15, v0, vcc_lo
-; GFX10-NEXT:    v_sub_nc_u32_e32 v0, s15, v0
-; GFX10-NEXT:    v_cndmask_b32_e64 v3, v14, v3, s0
-; GFX10-NEXT:    v_cndmask_b32_e64 v7, v15, v7, s0
-; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s3, v8
-; GFX10-NEXT:    v_xor_b32_e32 v1, s18, v1
-; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v11, vcc_lo, s3, v0, vcc_lo
-; GFX10-NEXT:    v_cmp_le_u32_e32 vcc_lo, s2, v2
-; GFX10-NEXT:    v_xor_b32_e32 v4, s19, v4
-; GFX10-NEXT:    v_cndmask_b32_e64 v9, 0, -1, s0
+; GFX10-NEXT:    v_sub_co_u32 v17, s1, v1, s6
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v15, s1, 0, v15, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v4, v5, v4, s0
+; GFX10-NEXT:    v_cmp_ne_u32_e64 s1, 0, v14
+; GFX10-NEXT:    v_sub_nc_u32_e32 v0, s3, v0
+; GFX10-NEXT:    v_cndmask_b32_e64 v5, v13, v8, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v1, v1, v17, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s2, s15, v18
+; GFX10-NEXT:    v_cndmask_b32_e64 v4, v6, v4, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v6, v16, v15, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v5, v11, v5, s1
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v11, vcc_lo, s15, v0, vcc_lo
+; GFX10-NEXT:    v_cmp_le_u32_e32 vcc_lo, s14, v2
+; GFX10-NEXT:    v_xor_b32_e32 v0, s18, v4
+; GFX10-NEXT:    v_cndmask_b32_e64 v9, v9, v1, s1
+; GFX10-NEXT:    v_xor_b32_e32 v1, s19, v5
+; GFX10-NEXT:    v_cndmask_b32_e64 v3, v3, v6, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v4, 0, -1, vcc_lo
+; GFX10-NEXT:    v_sub_co_u32 v5, vcc_lo, v2, s14
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v6, s0, 0, v11, vcc_lo
+; GFX10-NEXT:    v_sub_co_u32 v0, s0, v0, s18
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v1, s0, s19, v1, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v8, 0, -1, s2
+; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s15, v18
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v11, vcc_lo, s15, v11, vcc_lo
+; GFX10-NEXT:    v_xor_b32_e32 v9, s4, v9
 ; GFX10-NEXT:    v_xor_b32_e32 v3, s4, v3
-; GFX10-NEXT:    v_xor_b32_e32 v7, s4, v7
-; GFX10-NEXT:    v_cndmask_b32_e64 v12, 0, -1, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v13, vcc_lo, v2, s2
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v14, s0, 0, v11, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v0, s0, v1, s18
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v1, s0, s19, v4, s0
-; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s3, v8
-; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v11, vcc_lo, s3, v11, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e64 v4, v9, v12, s0
-; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s3, v14
-; GFX10-NEXT:    v_cndmask_b32_e64 v9, 0, -1, s0
-; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s2, v13
-; GFX10-NEXT:    v_cndmask_b32_e64 v12, 0, -1, s0
-; GFX10-NEXT:    v_add_co_u32 v15, s0, v6, 1
-; GFX10-NEXT:    v_add_co_ci_u32_e64 v16, s0, 0, v5, s0
-; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s3, v14
-; GFX10-NEXT:    v_cndmask_b32_e64 v9, v9, v12, s0
-; GFX10-NEXT:    v_add_co_u32 v12, s0, v15, 1
-; GFX10-NEXT:    v_add_co_ci_u32_e64 v17, s0, 0, v16, s0
-; GFX10-NEXT:    v_cmp_ne_u32_e32 vcc_lo, 0, v9
-; GFX10-NEXT:    v_sub_co_u32 v9, s0, v13, s2
+; GFX10-NEXT:    v_cndmask_b32_e64 v4, v8, v4, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s15, v6
+; GFX10-NEXT:    v_cndmask_b32_e64 v8, 0, -1, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s14, v5
+; GFX10-NEXT:    v_cndmask_b32_e64 v13, 0, -1, s0
+; GFX10-NEXT:    v_add_co_u32 v14, s0, v12, 1
+; GFX10-NEXT:    v_add_co_ci_u32_e64 v15, s0, 0, v7, s0
+; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s15, v6
+; GFX10-NEXT:    v_cndmask_b32_e64 v8, v8, v13, s0
+; GFX10-NEXT:    v_add_co_u32 v13, s0, v14, 1
+; GFX10-NEXT:    v_add_co_ci_u32_e64 v16, s0, 0, v15, s0
+; GFX10-NEXT:    v_cmp_ne_u32_e32 vcc_lo, 0, v8
+; GFX10-NEXT:    v_sub_co_u32 v8, s0, v5, s14
 ; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v11, s0, 0, v11, s0
-; GFX10-NEXT:    v_cndmask_b32_e32 v12, v15, v12, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e32 v13, v14, v13, vcc_lo
 ; GFX10-NEXT:    v_cmp_ne_u32_e64 s0, 0, v4
-; GFX10-NEXT:    v_cndmask_b32_e32 v15, v16, v17, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e32 v4, v13, v9, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e32 v9, v14, v11, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e64 v6, v6, v12, s0
-; GFX10-NEXT:    v_cndmask_b32_e64 v11, v5, v15, s0
+; GFX10-NEXT:    v_cndmask_b32_e32 v14, v15, v16, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e32 v4, v5, v8, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e32 v5, v6, v11, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e64 v6, v12, v13, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v7, v7, v14, s0
 ; GFX10-NEXT:    v_cndmask_b32_e64 v2, v2, v4, s0
-; GFX10-NEXT:    v_cndmask_b32_e64 v8, v8, v9, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v8, v18, v5, s0
 ; GFX10-NEXT:    s_xor_b64 s[0:1], s[12:13], s[16:17]
-; GFX10-NEXT:    v_sub_co_u32 v4, vcc_lo, v3, s4
+; GFX10-NEXT:    v_sub_co_u32 v4, vcc_lo, v9, s4
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v5, vcc_lo, s4, v3, vcc_lo
 ; GFX10-NEXT:    v_xor_b32_e32 v3, s0, v6
-; GFX10-NEXT:    v_xor_b32_e32 v6, s1, v11
-; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v5, vcc_lo, s4, v7, vcc_lo
+; GFX10-NEXT:    v_xor_b32_e32 v6, s1, v7
 ; GFX10-NEXT:    v_xor_b32_e32 v7, s12, v2
 ; GFX10-NEXT:    v_xor_b32_e32 v8, s12, v8
 ; GFX10-NEXT:    v_sub_co_u32 v2, vcc_lo, v3, s0
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/udivrem.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/udivrem.ll
index a58397eccaba76..c0b645b36a3c0a 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/udivrem.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/udivrem.ll
@@ -120,13 +120,15 @@ define amdgpu_kernel void @udivrem_i64(ptr addrspace(1) %out0, ptr addrspace(1)
 ; GFX8-NEXT:    s_subb_u32 s3, 0, s11
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX8-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, s0
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX8-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX8-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, s0
 ; GFX8-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX8-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s2, v3, 0
 ; GFX8-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s2, v4, v[1:2]
@@ -259,13 +261,15 @@ define amdgpu_kernel void @udivrem_i64(ptr addrspace(1) %out0, ptr addrspace(1)
 ; GFX9-NEXT:    s_subb_u32 s3, 0, s11
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX9-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, s0
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX9-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX9-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX9-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX9-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, s0
 ; GFX9-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX9-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s2, v3, 0
 ; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s2, v4, v[1:2]
@@ -388,17 +392,19 @@ define amdgpu_kernel void @udivrem_i64(ptr addrspace(1) %out0, ptr addrspace(1)
 ; GFX10-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v0, s11
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v1, s10
-; GFX10-NEXT:    s_sub_u32 s0, 0, s10
 ; GFX10-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX10-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX10-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX10-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX10-NEXT:    v_rcp_iflag_f32_e32 v0, s0
 ; GFX10-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX10-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX10-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX10-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX10-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX10-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX10-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX10-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX10-NEXT:    v_cvt_u32_f32_e32 v3, s0
+; GFX10-NEXT:    s_sub_u32 s0, 0, s10
 ; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s1, s0, v3, 0
 ; GFX10-NEXT:    v_mad_u64_u32 v[1:2], s1, s0, v4, v[1:2]
 ; GFX10-NEXT:    s_subb_u32 s1, 0, s11
@@ -988,13 +994,15 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX8-NEXT:    s_subb_u32 s3, 0, s13
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX8-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX8-NEXT:    v_rcp_iflag_f32_e32 v0, s0
 ; GFX8-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX8-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX8-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX8-NEXT:    v_cvt_u32_f32_e32 v3, s0
 ; GFX8-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX8-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s2, v3, 0
 ; GFX8-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s2, v4, v[1:2]
@@ -1088,25 +1096,27 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX8-NEXT:    v_cvt_f32_u32_e32 v2, s15
 ; GFX8-NEXT:    v_subb_u32_e32 v5, vcc, v1, v4, vcc
 ; GFX8-NEXT:    v_cvt_f32_u32_e32 v1, s14
-; GFX8-NEXT:    v_mul_f32_e32 v2, 0x4f800000, v2
 ; GFX8-NEXT:    v_subrev_u32_e32 v10, vcc, s12, v8
-; GFX8-NEXT:    v_add_f32_e32 v1, v2, v1
-; GFX8-NEXT:    v_rcp_iflag_f32_e32 v1, v1
+; GFX8-NEXT:    v_mul_f32_e32 v2, 0x4f800000, v2
 ; GFX8-NEXT:    v_subbrev_u32_e64 v11, s[0:1], 0, v5, vcc
+; GFX8-NEXT:    v_add_f32_e32 v1, v2, v1
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX8-NEXT:    v_rcp_iflag_f32_e32 v1, s0
 ; GFX8-NEXT:    v_add_u32_e64 v12, s[0:1], 1, v6
+; GFX8-NEXT:    v_addc_u32_e64 v13, s[0:1], 0, v7, s[0:1]
 ; GFX8-NEXT:    v_mul_f32_e32 v1, 0x5f7ffffc, v1
 ; GFX8-NEXT:    v_mul_f32_e32 v2, 0x2f800000, v1
 ; GFX8-NEXT:    v_trunc_f32_e32 v14, v2
 ; GFX8-NEXT:    v_mul_f32_e32 v2, 0xcf800000, v14
-; GFX8-NEXT:    v_add_f32_e32 v1, v2, v1
-; GFX8-NEXT:    v_cvt_u32_f32_e32 v15, v1
-; GFX8-NEXT:    v_addc_u32_e64 v13, s[0:1], 0, v7, s[0:1]
 ; GFX8-NEXT:    v_cmp_le_u32_e64 s[0:1], s13, v11
+; GFX8-NEXT:    v_add_f32_e32 v1, v2, v1
 ; GFX8-NEXT:    v_cndmask_b32_e64 v3, 0, -1, s[0:1]
+; GFX8-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX8-NEXT:    v_cvt_u32_f32_e32 v15, s0
 ; GFX8-NEXT:    v_cmp_le_u32_e64 s[0:1], s12, v10
 ; GFX8-NEXT:    v_cndmask_b32_e64 v16, 0, -1, s[0:1]
-; GFX8-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s2, v15, 0
 ; GFX8-NEXT:    v_cvt_u32_f32_e32 v14, v14
+; GFX8-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s2, v15, 0
 ; GFX8-NEXT:    v_cmp_eq_u32_e64 s[0:1], s13, v11
 ; GFX8-NEXT:    v_cndmask_b32_e64 v16, v3, v16, s[0:1]
 ; GFX8-NEXT:    v_mad_u64_u32 v[2:3], s[0:1], s2, v14, v[2:3]
@@ -1256,14 +1266,16 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX9-NEXT:    s_subb_u32 s3, 0, s13
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX9-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX9-NEXT:    v_rcp_iflag_f32_e32 v0, s0
 ; GFX9-NEXT:    s_load_dwordx8 s[4:11], s[4:5], 0x0
 ; GFX9-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX9-NEXT:    v_mul_f32_e32 v1, 0x2f800000, v0
 ; GFX9-NEXT:    v_trunc_f32_e32 v2, v1
 ; GFX9-NEXT:    v_mul_f32_e32 v1, 0xcf800000, v2
 ; GFX9-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, v0
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX9-NEXT:    v_cvt_u32_f32_e32 v3, s0
 ; GFX9-NEXT:    v_cvt_u32_f32_e32 v4, v2
 ; GFX9-NEXT:    v_mad_u64_u32 v[0:1], s[0:1], s2, v3, 0
 ; GFX9-NEXT:    v_mad_u64_u32 v[1:2], s[0:1], s2, v4, v[1:2]
@@ -1357,25 +1369,27 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX9-NEXT:    v_cvt_f32_u32_e32 v4, s15
 ; GFX9-NEXT:    v_subb_co_u32_e32 v7, vcc, v3, v6, vcc
 ; GFX9-NEXT:    v_cvt_f32_u32_e32 v3, s14
-; GFX9-NEXT:    v_mul_f32_e32 v4, 0x4f800000, v4
 ; GFX9-NEXT:    v_subrev_co_u32_e32 v11, vcc, s12, v2
-; GFX9-NEXT:    v_add_f32_e32 v3, v4, v3
-; GFX9-NEXT:    v_rcp_iflag_f32_e32 v3, v3
+; GFX9-NEXT:    v_mul_f32_e32 v4, 0x4f800000, v4
 ; GFX9-NEXT:    v_subbrev_co_u32_e64 v12, s[0:1], 0, v7, vcc
+; GFX9-NEXT:    v_add_f32_e32 v3, v4, v3
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v3
+; GFX9-NEXT:    v_rcp_iflag_f32_e32 v3, s0
 ; GFX9-NEXT:    v_add_co_u32_e64 v13, s[0:1], 1, v8
+; GFX9-NEXT:    v_addc_co_u32_e64 v14, s[0:1], 0, v9, s[0:1]
 ; GFX9-NEXT:    v_mul_f32_e32 v3, 0x5f7ffffc, v3
 ; GFX9-NEXT:    v_mul_f32_e32 v4, 0x2f800000, v3
 ; GFX9-NEXT:    v_trunc_f32_e32 v15, v4
 ; GFX9-NEXT:    v_mul_f32_e32 v4, 0xcf800000, v15
-; GFX9-NEXT:    v_add_f32_e32 v3, v4, v3
-; GFX9-NEXT:    v_cvt_u32_f32_e32 v16, v3
-; GFX9-NEXT:    v_addc_co_u32_e64 v14, s[0:1], 0, v9, s[0:1]
 ; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s13, v12
+; GFX9-NEXT:    v_add_f32_e32 v3, v4, v3
 ; GFX9-NEXT:    v_cndmask_b32_e64 v5, 0, -1, s[0:1]
+; GFX9-NEXT:    v_readfirstlane_b32 s0, v3
+; GFX9-NEXT:    v_cvt_u32_f32_e32 v16, s0
 ; GFX9-NEXT:    v_cmp_le_u32_e64 s[0:1], s12, v11
 ; GFX9-NEXT:    v_cndmask_b32_e64 v17, 0, -1, s[0:1]
-; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[0:1], s2, v16, 0
 ; GFX9-NEXT:    v_cvt_u32_f32_e32 v15, v15
+; GFX9-NEXT:    v_mad_u64_u32 v[3:4], s[0:1], s2, v16, 0
 ; GFX9-NEXT:    v_cmp_eq_u32_e64 s[0:1], s13, v12
 ; GFX9-NEXT:    v_cndmask_b32_e64 v17, v5, v17, s[0:1]
 ; GFX9-NEXT:    v_mad_u64_u32 v[4:5], s[0:1], s2, v15, v[4:5]
@@ -1516,14 +1530,14 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v1, s15
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v2, s12
 ; GFX10-NEXT:    v_cvt_f32_u32_e32 v3, s14
-; GFX10-NEXT:    s_sub_u32 s0, 0, s12
 ; GFX10-NEXT:    v_mul_f32_e32 v0, 0x4f800000, v0
 ; GFX10-NEXT:    v_mul_f32_e32 v1, 0x4f800000, v1
-; GFX10-NEXT:    s_subb_u32 s1, 0, s13
 ; GFX10-NEXT:    v_add_f32_e32 v0, v0, v2
 ; GFX10-NEXT:    v_add_f32_e32 v1, v1, v3
-; GFX10-NEXT:    v_rcp_iflag_f32_e32 v0, v0
-; GFX10-NEXT:    v_rcp_iflag_f32_e32 v1, v1
+; GFX10-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX10-NEXT:    v_readfirstlane_b32 s1, v1
+; GFX10-NEXT:    v_rcp_iflag_f32_e32 v0, s0
+; GFX10-NEXT:    v_rcp_iflag_f32_e32 v1, s1
 ; GFX10-NEXT:    v_mul_f32_e32 v0, 0x5f7ffffc, v0
 ; GFX10-NEXT:    v_mul_f32_e32 v1, 0x5f7ffffc, v1
 ; GFX10-NEXT:    v_mul_f32_e32 v2, 0x2f800000, v0
@@ -1536,17 +1550,21 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX10-NEXT:    v_cvt_u32_f32_e32 v10, v5
 ; GFX10-NEXT:    v_add_f32_e32 v0, v2, v0
 ; GFX10-NEXT:    v_add_f32_e32 v1, v3, v1
-; GFX10-NEXT:    v_cvt_u32_f32_e32 v7, v0
-; GFX10-NEXT:    v_cvt_u32_f32_e32 v8, v1
-; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s2, s0, v7, 0
-; GFX10-NEXT:    s_sub_u32 s2, 0, s14
-; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s3, s2, v8, 0
+; GFX10-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX10-NEXT:    v_readfirstlane_b32 s1, v1
+; GFX10-NEXT:    v_cvt_u32_f32_e32 v7, s0
+; GFX10-NEXT:    s_sub_u32 s0, 0, s12
+; GFX10-NEXT:    v_cvt_u32_f32_e32 v8, s1
+; GFX10-NEXT:    s_subb_u32 s2, 0, s13
+; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s1, s0, v7, 0
+; GFX10-NEXT:    s_sub_u32 s1, 0, s14
+; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s3, s1, v8, 0
 ; GFX10-NEXT:    v_mul_hi_u32 v11, v9, v0
 ; GFX10-NEXT:    v_mad_u64_u32 v[4:5], s3, s0, v9, v[1:2]
-; GFX10-NEXT:    v_mad_u64_u32 v[5:6], s3, s2, v10, v[3:4]
+; GFX10-NEXT:    v_mad_u64_u32 v[5:6], s3, s1, v10, v[3:4]
 ; GFX10-NEXT:    v_mul_lo_u32 v6, v9, v0
 ; GFX10-NEXT:    s_subb_u32 s3, 0, s15
-; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s6, s1, v7, v[4:5]
+; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s6, s2, v7, v[4:5]
 ; GFX10-NEXT:    v_mul_hi_u32 v4, v7, v0
 ; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s6, s3, v8, v[5:6]
 ; GFX10-NEXT:    v_mul_lo_u32 v1, v10, v2
@@ -1591,13 +1609,13 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX10-NEXT:    v_add_co_u32 v8, vcc_lo, v8, v1
 ; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s6, s0, v7, 0
 ; GFX10-NEXT:    v_add_co_ci_u32_e32 v10, vcc_lo, v10, v2, vcc_lo
-; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s6, s2, v8, 0
+; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s6, s1, v8, 0
 ; GFX10-NEXT:    s_load_dwordx8 s[4:11], s[4:5], 0x0
 ; GFX10-NEXT:    v_mul_hi_u32 v11, v9, v0
 ; GFX10-NEXT:    v_mad_u64_u32 v[4:5], s0, s0, v9, v[1:2]
-; GFX10-NEXT:    v_mad_u64_u32 v[5:6], s0, s2, v10, v[3:4]
+; GFX10-NEXT:    v_mad_u64_u32 v[5:6], s0, s1, v10, v[3:4]
 ; GFX10-NEXT:    v_mul_lo_u32 v6, v9, v0
-; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s0, s1, v7, v[4:5]
+; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s0, s2, v7, v[4:5]
 ; GFX10-NEXT:    v_mul_hi_u32 v4, v7, v0
 ; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s0, s3, v8, v[5:6]
 ; GFX10-NEXT:    v_mul_lo_u32 v1, v10, v2
@@ -1678,89 +1696,89 @@ define amdgpu_kernel void @udivrem_v2i64(ptr addrspace(1) %out0, ptr addrspace(1
 ; GFX10-NEXT:    v_add_co_u32 v8, s0, v4, v0
 ; GFX10-NEXT:    v_cndmask_b32_e64 v4, 0, 1, s0
 ; GFX10-NEXT:    v_add_co_u32 v10, s0, v1, v2
-; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s1, s12, v8, 0
 ; GFX10-NEXT:    v_cndmask_b32_e64 v6, 0, 1, s0
+; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s0, s12, v8, 0
 ; GFX10-NEXT:    v_mad_u64_u32 v[2:3], s0, s14, v10, 0
+; GFX10-NEXT:    v_add3_u32 v11, v5, v4, v11
 ; GFX10-NEXT:    v_add_nc_u32_e32 v7, v9, v7
-; GFX10-NEXT:    v_add3_u32 v9, v5, v4, v11
 ; GFX10-NEXT:    v_add_co_u32 v12, vcc_lo, v8, 1
-; GFX10-NEXT:    v_mov_b32_e32 v11, 0
+; GFX10-NEXT:    v_mov_b32_e32 v9, 0
+; GFX10-NEXT:    v_add_co_ci_u32_e32 v13, vcc_lo, 0, v11, vcc_lo
+; GFX10-NEXT:    v_mad_u64_u32 v[4:5], s0, s12, v11, v[1:2]
 ; GFX10-NEXT:    v_add3_u32 v7, v7, v6, v14
-; GFX10-NEXT:    v_mad_u64_u32 v[4:5], s0, s12, v9, v[1:2]
-; GFX10-NEXT:    v_add_co_ci_u32_e32 v13, vcc_lo, 0, v9, vcc_lo
+; GFX10-NEXT:    v_add_co_u32 v1, vcc_lo, v12, 1
 ; GFX10-NEXT:    v_mad_u64_u32 v[5:6], s0, s14, v7, v[3:4]
-; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s0, s13, v8, v[4:5]
-; GFX10-NEXT:    v_add_co_u32 v4, vcc_lo, v12, 1
 ; GFX10-NEXT:    v_add_co_ci_u32_e32 v6, vcc_lo, 0, v13, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v14, vcc_lo, s8, v0
-; GFX10-NEXT:    v_mad_u64_u32 v[0:1], s0, s15, v10, v[5:6]
-; GFX10-NEXT:    v_sub_co_ci_u32_e64 v5, s0, s9, v3, vcc_lo
-; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s12, v14
-; GFX10-NEXT:    v_sub_nc_u32_e32 v1, s9, v3
+; GFX10-NEXT:    v_mad_u64_u32 v[3:4], s0, s13, v8, v[4:5]
+; GFX10-NEXT:    v_mad_u64_u32 v[4:5], s0, s15, v10, v[5:6]
+; GFX10-NEXT:    v_sub_co_u32 v5, vcc_lo, s8, v0
+; GFX10-NEXT:    v_sub_co_u32 v14, s0, s10, v2
+; GFX10-NEXT:    v_sub_co_ci_u32_e64 v2, s1, s9, v3, vcc_lo
+; GFX10-NEXT:    v_cmp_le_u32_e64 s1, s12, v5
+; GFX10-NEXT:    v_sub_nc_u32_e32 v0, s9, v3
+; GFX10-NEXT:    v_cndmask_b32_e64 v3, 0, -1, s1
+; GFX10-NEXT:    v_sub_co_ci_u32_e64 v15, s1, s11, v4, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s1, s14, v14
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v0, vcc_lo, s13, v0, vcc_lo
+; GFX10-NEXT:    v_sub_nc_u32_e32 v4, s11, v4
+; GFX10-NEXT:    v_cmp_le_u32_e32 vcc_lo, s15, v15
+; GFX10-NEXT:    v_cndmask_b32_e64 v16, 0, -1, s1
+; GFX10-NEXT:    v_cmp_le_u32_e64 s1, s13, v2
+; GFX10-NEXT:    v_cndmask_b32_e64 v18, 0, -1, vcc_lo
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v19, vcc_lo, s15, v4, s0
+; GFX10-NEXT:    v_sub_co_u32 v4, vcc_lo, v5, s12
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v20, s0, 0, v0, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e64 v17, 0, -1, s1
+; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s13, v2
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v0, vcc_lo, s13, v0, vcc_lo
+; GFX10-NEXT:    v_cmp_eq_u32_e32 vcc_lo, s15, v15
+; GFX10-NEXT:    v_cndmask_b32_e64 v3, v17, v3, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s12, v4
+; GFX10-NEXT:    v_cndmask_b32_e32 v16, v18, v16, vcc_lo
+; GFX10-NEXT:    v_cmp_eq_u32_e32 vcc_lo, s13, v20
+; GFX10-NEXT:    v_cndmask_b32_e64 v17, 0, -1, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s13, v20
+; GFX10-NEXT:    v_cndmask_b32_e64 v21, 0, -1, s0
+; GFX10-NEXT:    v_cndmask_b32_e32 v17, v21, v17, vcc_lo
+; GFX10-NEXT:    v_sub_co_u32 v18, vcc_lo, v14, s14
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v21, s0, 0, v19, vcc_lo
+; GFX10-NEXT:    v_cmp_ne_u32_e64 s0, 0, v17
+; GFX10-NEXT:    v_sub_co_u32 v17, s1, v4, s12
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v22, s1, 0, v0, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v0, v12, v1, s0
+; GFX10-NEXT:    v_cmp_ne_u32_e64 s1, 0, v3
+; GFX10-NEXT:    v_cndmask_b32_e64 v1, v13, v6, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v3, v4, v17, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s2, s15, v21
+; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v13, vcc_lo, s15, v19, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e64 v0, v8, v0, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v8, v20, v22, s0
+; GFX10-NEXT:    v_cmp_le_u32_e64 s0, s14, v18
+; GFX10-NEXT:    v_cndmask_b32_e64 v4, v5, v3, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v1, v11, v1, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v6, 0, -1, s2
 ; GFX10-NEXT:    v_cndmask_b32_e64 v3, 0, -1, s0
-; GFX10-NEXT:    v_sub_co_u32 v15, s0, s10, v2
-; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v1, vcc_lo, s13, v1, vcc_lo
-; GFX10-NEXT:    v_sub_co_ci_u32_e64 v16, s1, s11, v0, s0
-; GFX10-NEXT:    v_cmp_le_u32_e32 vcc_lo, s14, v15
-; GFX10-NEXT:    v_sub_nc_u32_e32 v0, s11, v0
-; GFX10-NEXT:    v_cndmask_b32_e64 v2, 0, -1, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v17, vcc_lo, v14, s12
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v18, s1, 0, v1, vcc_lo
-; GFX10-NEXT:    v_cmp_le_u32_e64 s1, s13, v5
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v23, s0, s15, v0, s0
-; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s13, v18
-; GFX10-NEXT:    v_subrev_co_ci_u32_e32 v1, vcc_lo, s13, v1, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e64 v19, 0, -1, s1
-; GFX10-NEXT:    v_cmp_le_u32_e64 s1, s12, v17
-; GFX10-NEXT:    v_cndmask_b32_e64 v20, 0, -1, s1
-; GFX10-NEXT:    v_cmp_le_u32_e64 s1, s13, v18
-; GFX10-NEXT:    v_cndmask_b32_e64 v21, 0, -1, s1
-; GFX10-NEXT:    v_cmp_le_u32_e64 s1, s15, v16
-; GFX10-NEXT:    v_cndmask_b32_e64 v0, v21, v20, s0
-; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s13, v5
-; GFX10-NEXT:    v_cndmask_b32_e64 v22, 0, -1, s1
-; GFX10-NEXT:    v_cmp_ne_u32_e32 vcc_lo, 0, v0
-; GFX10-NEXT:    v_cndmask_b32_e64 v3, v19, v3, s0
-; GFX10-NEXT:    v_sub_co_u32 v0, s0, v17, s12
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v19, s0, 0, v1, s0
-; GFX10-NEXT:    v_cndmask_b32_e32 v1, v12, v4, vcc_lo
-; GFX10-NEXT:    v_cmp_ne_u32_e64 s0, 0, v3
-; GFX10-NEXT:    v_cndmask_b32_e32 v3, v13, v6, vcc_lo
-; GFX10-NEXT:    v_sub_co_u32 v6, s1, v15, s14
-; GFX10-NEXT:    v_cndmask_b32_e32 v4, v17, v0, vcc_lo
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v12, s2, 0, v23, s1
-; GFX10-NEXT:    v_cndmask_b32_e64 v0, v8, v1, s0
-; GFX10-NEXT:    v_cndmask_b32_e64 v1, v9, v3, s0
-; GFX10-NEXT:    v_cndmask_b32_e32 v3, v18, v19, vcc_lo
-; GFX10-NEXT:    v_cmp_eq_u32_e32 vcc_lo, s15, v16
-; GFX10-NEXT:    v_cndmask_b32_e64 v4, v14, v4, s0
-; GFX10-NEXT:    v_cndmask_b32_e64 v5, v5, v3, s0
-; GFX10-NEXT:    v_cndmask_b32_e32 v2, v22, v2, vcc_lo
-; GFX10-NEXT:    v_cmp_le_u32_e32 vcc_lo, s15, v12
-; GFX10-NEXT:    v_cndmask_b32_e64 v8, 0, -1, vcc_lo
-; GFX10-NEXT:    v_cmp_le_u32_e32 vcc_lo, s14, v6
-; GFX10-NEXT:    v_cndmask_b32_e64 v9, 0, -1, vcc_lo
-; GFX10-NEXT:    v_add_co_u32 v13, vcc_lo, v10, 1
-; GFX10-NEXT:    v_add_co_ci_u32_e32 v14, vcc_lo, 0, v7, vcc_lo
-; GFX10-NEXT:    v_cmp_eq_u32_e32 vcc_lo, s15, v12
-; GFX10-NEXT:    v_cndmask_b32_e32 v8, v8, v9, vcc_lo
-; GFX10-NEXT:    v_add_co_u32 v9, vcc_lo, v13, 1
-; GFX10-NEXT:    v_add_co_ci_u32_e32 v17, vcc_lo, 0, v14, vcc_lo
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v18, vcc_lo, s15, v23, s1
-; GFX10-NEXT:    v_cmp_ne_u32_e32 vcc_lo, 0, v8
-; GFX10-NEXT:    v_sub_co_u32 v8, s1, v6, s14
-; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v18, s1, 0, v18, s1
-; GFX10-NEXT:    v_cndmask_b32_e32 v9, v13, v9, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e32 v13, v14, v17, vcc_lo
-; GFX10-NEXT:    v_cmp_ne_u32_e64 s1, 0, v2
-; GFX10-NEXT:    v_cndmask_b32_e32 v6, v6, v8, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e32 v8, v12, v18, vcc_lo
-; GFX10-NEXT:    v_cndmask_b32_e64 v2, v10, v9, s1
-; GFX10-NEXT:    v_cndmask_b32_e64 v3, v7, v13, s1
-; GFX10-NEXT:    v_cndmask_b32_e64 v6, v15, v6, s1
-; GFX10-NEXT:    v_cndmask_b32_e64 v7, v16, v8, s1
-; GFX10-NEXT:    global_store_dwordx4 v11, v[0:3], s[4:5]
-; GFX10-NEXT:    global_store_dwordx4 v11, v[4:7], s[6:7]
+; GFX10-NEXT:    v_add_co_u32 v5, s0, v10, 1
+; GFX10-NEXT:    v_add_co_ci_u32_e64 v11, s0, 0, v7, s0
+; GFX10-NEXT:    v_cmp_eq_u32_e64 s0, s15, v21
+; GFX10-NEXT:    v_cndmask_b32_e64 v3, v6, v3, s0
+; GFX10-NEXT:    v_add_co_u32 v6, s0, v5, 1
+; GFX10-NEXT:    v_add_co_ci_u32_e64 v12, s0, 0, v11, s0
+; GFX10-NEXT:    v_cmp_ne_u32_e32 vcc_lo, 0, v3
+; GFX10-NEXT:    v_sub_co_u32 v3, s0, v18, s14
+; GFX10-NEXT:    v_subrev_co_ci_u32_e64 v13, s0, 0, v13, s0
+; GFX10-NEXT:    v_cndmask_b32_e32 v6, v5, v6, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e32 v11, v11, v12, vcc_lo
+; GFX10-NEXT:    v_cmp_ne_u32_e64 s0, 0, v16
+; GFX10-NEXT:    v_cndmask_b32_e32 v12, v18, v3, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e32 v13, v21, v13, vcc_lo
+; GFX10-NEXT:    v_cndmask_b32_e64 v5, v2, v8, s1
+; GFX10-NEXT:    v_cndmask_b32_e64 v2, v10, v6, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v3, v7, v11, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v6, v14, v12, s0
+; GFX10-NEXT:    v_cndmask_b32_e64 v7, v15, v13, s0
+; GFX10-NEXT:    global_store_dwordx4 v9, v[0:3], s[4:5]
+; GFX10-NEXT:    global_store_dwordx4 v9, v[4:7], s[6:7]
 ; GFX10-NEXT:    s_endpgm
   %div = udiv <2 x i64> %x, %y
   store <2 x i64> %div, ptr addrspace(1) %out0
diff --git a/llvm/test/CodeGen/AMDGPU/fadd.f16.ll b/llvm/test/CodeGen/AMDGPU/fadd.f16.ll
index cdc6b5a48d0a69..db68d09e846a40 100644
--- a/llvm/test/CodeGen/AMDGPU/fadd.f16.ll
+++ b/llvm/test/CodeGen/AMDGPU/fadd.f16.ll
@@ -101,8 +101,11 @@ define amdgpu_kernel void @fadd_f16(
 ; GFX11-GISEL-NEXT:    buffer_load_u16 v1, off, s[0:3], 0 glc dlc
 ; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)
 ; GFX11-GISEL-NEXT:    v_mov_b16_e32 v0.h, v1.l
-; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX11-GISEL-NEXT:    v_add_f16_e32 v0.l, v0.l, v0.h
+; GFX11-GISEL-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX11-GISEL-NEXT:    v_mov_b32_e32 v0, s0
 ; GFX11-GISEL-NEXT:    buffer_store_b16 v0, off, s[4:7], 0
 ; GFX11-GISEL-NEXT:    s_nop 0
 ; GFX11-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -151,6 +154,9 @@ define amdgpu_kernel void @fadd_f16(
 ; GFX11-FAKE16-GISEL-NEXT:    buffer_load_u16 v1, off, s[0:3], 0 glc dlc
 ; GFX11-FAKE16-GISEL-NEXT:    s_waitcnt vmcnt(0)
 ; GFX11-FAKE16-GISEL-NEXT:    v_add_f16_e32 v0, v0, v1
+; GFX11-FAKE16-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX11-FAKE16-GISEL-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX11-FAKE16-GISEL-NEXT:    v_mov_b32_e32 v0, s0
 ; GFX11-FAKE16-GISEL-NEXT:    buffer_store_b16 v0, off, s[4:7], 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_nop 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -261,12 +267,15 @@ define amdgpu_kernel void @fadd_f16_imm_a(
 ; GFX11-GISEL-NEXT:    s_mov_b32 s7, 0x31016000
 ; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX11-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]
-; GFX11-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-GISEL-NEXT:    buffer_load_u16 v0, off, s[4:7], 0
 ; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)
 ; GFX11-GISEL-NEXT:    v_mov_b16_e32 v0.h, 0x3c00
-; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX11-GISEL-NEXT:    v_add_f16_e32 v0.l, v0.l, v0.h
+; GFX11-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX11-GISEL-NEXT:    v_mov_b32_e32 v0, s2
+; GFX11-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-GISEL-NEXT:    buffer_store_b16 v0, off, s[0:3], 0
 ; GFX11-GISEL-NEXT:    s_nop 0
 ; GFX11-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -299,10 +308,13 @@ define amdgpu_kernel void @fadd_f16_imm_a(
 ; GFX11-FAKE16-GISEL-NEXT:    s_mov_b32 s7, 0x31016000
 ; GFX11-FAKE16-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX11-FAKE16-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]
-; GFX11-FAKE16-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-FAKE16-GISEL-NEXT:    buffer_load_u16 v0, off, s[4:7], 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_waitcnt vmcnt(0)
 ; GFX11-FAKE16-GISEL-NEXT:    v_add_f16_e32 v0, 1.0, v0
+; GFX11-FAKE16-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX11-FAKE16-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX11-FAKE16-GISEL-NEXT:    v_mov_b32_e32 v0, s2
+; GFX11-FAKE16-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-FAKE16-GISEL-NEXT:    buffer_store_b16 v0, off, s[0:3], 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_nop 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -405,12 +417,15 @@ define amdgpu_kernel void @fadd_f16_imm_b(
 ; GFX11-GISEL-NEXT:    s_mov_b32 s7, 0x31016000
 ; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX11-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]
-; GFX11-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-GISEL-NEXT:    buffer_load_u16 v0, off, s[4:7], 0
 ; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)
 ; GFX11-GISEL-NEXT:    v_mov_b16_e32 v0.h, 0x4000
-; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX11-GISEL-NEXT:    v_add_f16_e32 v0.l, v0.l, v0.h
+; GFX11-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX11-GISEL-NEXT:    v_mov_b32_e32 v0, s2
+; GFX11-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-GISEL-NEXT:    buffer_store_b16 v0, off, s[0:3], 0
 ; GFX11-GISEL-NEXT:    s_nop 0
 ; GFX11-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -443,10 +458,13 @@ define amdgpu_kernel void @fadd_f16_imm_b(
 ; GFX11-FAKE16-GISEL-NEXT:    s_mov_b32 s7, 0x31016000
 ; GFX11-FAKE16-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX11-FAKE16-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]
-; GFX11-FAKE16-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-FAKE16-GISEL-NEXT:    buffer_load_u16 v0, off, s[4:7], 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_waitcnt vmcnt(0)
 ; GFX11-FAKE16-GISEL-NEXT:    v_add_f16_e32 v0, 2.0, v0
+; GFX11-FAKE16-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX11-FAKE16-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX11-FAKE16-GISEL-NEXT:    v_mov_b32_e32 v0, s2
+; GFX11-FAKE16-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]
 ; GFX11-FAKE16-GISEL-NEXT:    buffer_store_b16 v0, off, s[0:3], 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_nop 0
 ; GFX11-FAKE16-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.exp.ll b/llvm/test/CodeGen/AMDGPU/llvm.exp.ll
index 7a0450761e1f11..049e0762290a88 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.exp.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.exp.ll
@@ -47,8 +47,8 @@ define amdgpu_kernel void @s_exp_f32(ptr addrspace(1) %out, float %in) {
 ; VI-GISEL-LABEL: s_exp_f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dword s2, s[0:1], 0x2c
-; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x3fb8a000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x39a3b295
+; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x3fb8a000
 ; VI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    s_and_b32 s3, s2, 0xfffff000
@@ -56,17 +56,20 @@ define amdgpu_kernel void @s_exp_f32(ptr addrspace(1) %out, float %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x39a3b295, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3fb8a000, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s3, v0
 ; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s3, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v0
-; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v1
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v1, v0
+; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc2ce8ed0
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x42b17218
@@ -118,12 +121,13 @@ define amdgpu_kernel void @s_exp_f32(ptr addrspace(1) %out, float %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v0, s2, v1, v0
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v2, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v3
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v3
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s3
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0xc2ce8ed0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v2
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x42b17218
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s2, v1
@@ -166,7 +170,6 @@ define amdgpu_kernel void @s_exp_f32(ptr addrspace(1) %out, float %in) {
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x3fb8aa3b
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x32a5705f
 ; SI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x9
-; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
 ; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v0
 ; SI-GISEL-NEXT:    v_fma_f32 v0, s2, v0, -v2
@@ -174,17 +177,19 @@ define amdgpu_kernel void @s_exp_f32(ptr addrspace(1) %out, float %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v0, s2, v1, v0
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v2, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v3
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v3
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s3
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0xc2ce8ed0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v2
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v1
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v1, v0
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x42b17218
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s2, v1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
 ; SI-GISEL-NEXT:    s_mov_b32 s2, -1
+; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
 ; SI-GISEL-NEXT:    buffer_store_dword v0, off, s[0:3], 0
 ; SI-GISEL-NEXT:    s_endpgm
 ;
@@ -391,38 +396,44 @@ define amdgpu_kernel void @s_exp_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; VI-GISEL-LABEL: s_exp_v2f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[0:1], 0x24
-; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x3fb8a000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x39a3b295
+; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x3fb8a000
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    s_and_b32 s4, s2, 0xfffff000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s4
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x39a3b295, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3fb8a000, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s4, v0
 ; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s5, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s4, v1
+; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s4, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s5, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v3
+; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s4, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v3
+; VI-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; VI-GISEL-NEXT:    s_and_b32 s4, s3, 0xfffff000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s4
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v4, v2
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v4, v3
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v5, s3, v5
-; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x39a3b295, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3fb8a000, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v3, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v0
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s5, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s4, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; VI-GISEL-NEXT:    v_exp_f32_e32 v2, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v5
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v5, v0
-; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v5
-; VI-GISEL-NEXT:    v_exp_f32_e32 v5, v0
-; VI-GISEL-NEXT:    v_ldexp_f32 v2, v2, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s5, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v1, v0
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
+; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v5, s4
+; VI-GISEL-NEXT:    v_ldexp_f32 v2, v3, v2
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0xc2ce8ed0
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x42b17218
@@ -496,14 +507,16 @@ define amdgpu_kernel void @s_exp_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
 ; GFX900-GISEL-NEXT:    v_fma_f32 v0, s3, v1, v0
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v1, v5
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v2, v2
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v1
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v4
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v5, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
 ; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, v0
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, s4
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v2, v2, v3
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v2, v3, v2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v4
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0x42b17218
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 0, vcc
@@ -577,14 +590,16 @@ define amdgpu_kernel void @s_exp_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
 ; SI-GISEL-NEXT:    v_fma_f32 v0, s3, v1, v0
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v1, v5
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; SI-GISEL-NEXT:    v_exp_f32_e32 v2, v2
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v1
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v4
+; SI-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v5, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
 ; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
-; SI-GISEL-NEXT:    v_exp_f32_e32 v5, v0
+; SI-GISEL-NEXT:    v_exp_f32_e32 v5, s4
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v2, v2, v3
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v2, v3, v2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v4
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x42b17218
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 0, vcc
@@ -928,8 +943,8 @@ define amdgpu_kernel void @s_exp_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; VI-GISEL-LABEL: s_exp_v3f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x34
-; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x3fb8a000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x39a3b295
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x3fb8a000
 ; VI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    s_and_b32 s2, s4, 0xfffff000
@@ -937,48 +952,57 @@ define amdgpu_kernel void @s_exp_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, s4, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x39a3b295, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0x3fb8a000, v0
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s2, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s2, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s2, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s2, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v0, v3
+; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s2, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v3
+; VI-GISEL-NEXT:    v_exp_f32_e32 v3, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s5, 0xfffff000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v5, s5, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x39a3b295, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3fb8a000, v5
-; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v7
-; VI-GISEL-NEXT:    v_mul_f32_e32 v7, s2, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v7, v5
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v7, v6
-; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v6, v5
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; VI-GISEL-NEXT:    v_exp_f32_e32 v5, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v4, v0
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v4, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v5
+; VI-GISEL-NEXT:    v_mul_f32_e32 v5, s2, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v5, s3, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v5, v6
+; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v5, v5
+; VI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s6, 0xfffff000
-; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v4
-; VI-GISEL-NEXT:    v_ldexp_f32 v5, v5, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_ldexp_f32 v5, v6, v5
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v3, v0
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v6, s6, v6
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x39a3b295, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3fb8a000, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v6
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v6, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v6
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s3, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s2, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v3, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0xc2ce8ed0
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x42b17218
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v6
-; VI-GISEL-NEXT:    v_exp_f32_e32 v6, v1
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
+; VI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; VI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v4
@@ -1057,35 +1081,38 @@ define amdgpu_kernel void @s_exp_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x32a5705f
 ; GFX900-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; GFX900-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
-; GFX900-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
-; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
-; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
-; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
-; GFX900-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
-; GFX900-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, v5
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, s4, v1, -v0
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v4, v0
+; GFX900-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, s4, v2, v3
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
+; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
+; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v0, v3
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v5, v5, v6
+; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
+; GFX900-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX900-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, s2
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v5, v7
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, s2
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v5, v6, v5
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v1
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, s6, v1, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, s6, v2, v1
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v2, v6
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v2
-; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v6, v1
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v3
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v3, v0
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0x42b17218
 ; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, v1
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v3
@@ -1164,37 +1191,40 @@ define amdgpu_kernel void @s_exp_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x3fb8aa3b
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x32a5705f
 ; SI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x9
-; SI-GISEL-NEXT:    s_mov_b32 s2, -1
+; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
 ; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
-; SI-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
-; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
-; SI-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
-; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
-; SI-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
-; SI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; SI-GISEL-NEXT:    v_exp_f32_e32 v5, v5
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v3, s4, v1, -v0
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v4, v0
+; SI-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v3, s4, v2, v3
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
+; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
+; SI-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v3
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v5, v5, v6
+; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
+; SI-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; SI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; SI-GISEL-NEXT:    v_exp_f32_e32 v3, s2
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v5, v7
+; SI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v5, v6, v5
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v1
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; SI-GISEL-NEXT:    v_fma_f32 v1, s6, v1, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v1, s6, v2, v1
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v2, v6
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v2
-; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v6, v1
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v3
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v3, v0
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x42b17218
 ; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
-; SI-GISEL-NEXT:    v_exp_f32_e32 v6, v1
+; SI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v3
@@ -1207,7 +1237,7 @@ define amdgpu_kernel void @s_exp_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v4
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 0, vcc
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s6, v3
-; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
+; SI-GISEL-NEXT:    s_mov_b32 s2, -1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v2, v2, v7, vcc
 ; SI-GISEL-NEXT:    buffer_store_dwordx2 v[0:1], off, s[0:3], 0
 ; SI-GISEL-NEXT:    buffer_store_dword v2, off, s[0:3], 0 offset:8
@@ -1691,8 +1721,8 @@ define amdgpu_kernel void @s_exp_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; VI-GISEL-LABEL: s_exp_v4f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x34
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x3fb8a000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x39a3b295
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x3fb8a000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, 0x42b17218
 ; VI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
@@ -1701,67 +1731,79 @@ define amdgpu_kernel void @s_exp_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, s4, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x39a3b295, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0x3fb8a000, v0
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v4, v0
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v4, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v4
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v4
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s2, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v0, v1
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s2, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s5, 0xfffff000
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v2
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v1, s5, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x39a3b295, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3fb8a000, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v7
-; VI-GISEL-NEXT:    v_mul_f32_e32 v7, s2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v7, v1
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v7, v6
-; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v6, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; VI-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v1
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s3, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v1, v6
+; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s6, 0xfffff000
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, s2, v2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
-; VI-GISEL-NEXT:    v_ldexp_f32 v1, v1, v6
+; VI-GISEL-NEXT:    v_ldexp_f32 v1, v6, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v6, s6, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x39a3b295, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3fb8a000, v6
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v9
-; VI-GISEL-NEXT:    v_mul_f32_e32 v9, s2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v9, v6
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v9, v8
-; VI-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v9
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v8, v6
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v8, v9
-; VI-GISEL-NEXT:    v_exp_f32_e32 v6, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s3, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v6, v8
+; VI-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v8, s2, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v6
+; VI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s7, 0xfffff000
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s2, v3
-; VI-GISEL-NEXT:    v_ldexp_f32 v6, v6, v8
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
+; VI-GISEL-NEXT:    v_ldexp_f32 v6, v8, v6
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v8, s7, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x39a3b295, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3fb8a000, v8
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v8
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v8, v2
-; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v8
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s3, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v3
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v3, v2
+; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; VI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v7, vcc
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v4
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v8
-; VI-GISEL-NEXT:    v_exp_f32_e32 v8, v2
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v3
+; VI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 0, vcc
 ; VI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s5, v5
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v7, vcc
@@ -1860,43 +1902,47 @@ define amdgpu_kernel void @s_exp_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, s4, v3, v1
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v4
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, s5, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v2, -v1
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v7, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v3, v6
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v1, v6
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v7
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v5
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v1, v1, v6
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v1, v6, v1
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v8, s6, v2, -v6
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v9, v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v8, s6, v3, v8
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v9
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v8, v9
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, v6
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v9
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v7, vcc
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v4
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 0, vcc
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v6, v6, v8
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v6, v8, v6
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v8, s7, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, s7, v2, -v8
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, s7, v3, v2
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v3, v8
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v8, v2
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
 ; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v3
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v8, v2
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s5, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v7, vcc
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v4
@@ -1994,44 +2040,48 @@ define amdgpu_kernel void @s_exp_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v1, s4, v3, v1
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v4
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc2ce8ed0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
-; SI-GISEL-NEXT:    s_mov_b32 s2, -1
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v1
+; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v1, v0
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v1, s5, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v2, -v1
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v7, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v3, v6
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v6
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; SI-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v7
+; SI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v5
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v1, v1, v6
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v1, v6, v1
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v8, s6, v2, -v6
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v9, v6
 ; SI-GISEL-NEXT:    v_fma_f32 v8, s6, v3, v8
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v9
 ; SI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v8, v9
-; SI-GISEL-NEXT:    v_exp_f32_e32 v6, v6
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v9
+; SI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v7, vcc
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v4
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 0, vcc
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v6, v6, v8
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v6, v8, v6
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v8, s7, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v2, s7, v2, -v8
 ; SI-GISEL-NEXT:    v_fma_f32 v2, s7, v3, v2
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v3, v8
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v8, v2
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
 ; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v3
-; SI-GISEL-NEXT:    v_exp_f32_e32 v8, v2
+; SI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s5, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v7, vcc
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v4
@@ -2043,7 +2093,7 @@ define amdgpu_kernel void @s_exp_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v3, v3, 0, vcc
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s7, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v7, vcc
-; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
+; SI-GISEL-NEXT:    s_mov_b32 s2, -1
 ; SI-GISEL-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
 ; SI-GISEL-NEXT:    s_endpgm
 ;
@@ -5243,21 +5293,24 @@ define float @v_exp_f32_undef() {
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; VI-GISEL-NEXT:    v_sub_f32_e64 v0, s4, 0
-; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x3fb8a000
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x39a3b295
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x39a3b295, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0x3fb8a000, v0
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0, v1
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x39a3b295
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v3
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v2, v0
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x3fb8a000
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v0, v1
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc2ce8ed0
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x42b17218
@@ -5293,10 +5346,11 @@ define float @v_exp_f32_undef() {
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v2
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc2ce8ed0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x42b17218
@@ -5332,10 +5386,11 @@ define float @v_exp_f32_undef() {
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v2
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v1
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v1, v0
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc2ce8ed0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x42b17218
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.exp10.ll b/llvm/test/CodeGen/AMDGPU/llvm.exp10.ll
index 544c1de6c7bb77..aa8e3ba5101417 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.exp10.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.exp10.ll
@@ -49,8 +49,8 @@ define amdgpu_kernel void @s_exp10_f32(ptr addrspace(1) %out, float %in) {
 ; VI-GISEL-LABEL: s_exp10_f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dword s2, s[0:1], 0x2c
-; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x40549000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x3a2784bc
+; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x40549000
 ; VI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    s_and_b32 s3, s2, 0xfffff000
@@ -58,17 +58,20 @@ define amdgpu_kernel void @s_exp10_f32(ptr addrspace(1) %out, float %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3a2784bc, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x40549000, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s3, v0
 ; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s3, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v0
-; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v1
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v1, v0
+; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc23369f4
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x421a209b
@@ -120,12 +123,13 @@ define amdgpu_kernel void @s_exp10_f32(ptr addrspace(1) %out, float %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v0, s2, v1, v0
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v2, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v3
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v3
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s3
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0xc23369f4
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v2
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x421a209b
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s2, v1
@@ -168,7 +172,6 @@ define amdgpu_kernel void @s_exp10_f32(ptr addrspace(1) %out, float %in) {
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x40549a78
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x33979a37
 ; SI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x9
-; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
 ; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v0
 ; SI-GISEL-NEXT:    v_fma_f32 v0, s2, v0, -v2
@@ -176,17 +179,19 @@ define amdgpu_kernel void @s_exp10_f32(ptr addrspace(1) %out, float %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v0, s2, v1, v0
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v2, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v3
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v3
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s3
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0xc23369f4
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v2
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v1
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v1, v0
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x421a209b
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s2, v1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
 ; SI-GISEL-NEXT:    s_mov_b32 s2, -1
+; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
 ; SI-GISEL-NEXT:    buffer_store_dword v0, off, s[0:3], 0
 ; SI-GISEL-NEXT:    s_endpgm
 ;
@@ -393,38 +398,44 @@ define amdgpu_kernel void @s_exp10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; VI-GISEL-LABEL: s_exp10_v2f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[0:1], 0x24
-; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x40549000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x3a2784bc
+; VI-GISEL-NEXT:    v_mov_b32_e32 v0, 0x40549000
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    s_and_b32 s4, s2, 0xfffff000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s4
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3a2784bc, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x40549000, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s4, v0
 ; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s5, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s4, v1
+; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s4, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s5, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v3
+; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s4, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v3
+; VI-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; VI-GISEL-NEXT:    s_and_b32 s4, s3, 0xfffff000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s4
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v4, v2
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v4, v3
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v5, s3, v5
-; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3a2784bc, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x40549000, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v3, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v0
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s5, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s4, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; VI-GISEL-NEXT:    v_exp_f32_e32 v2, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v5
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v5, v0
-; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v5
-; VI-GISEL-NEXT:    v_exp_f32_e32 v5, v0
-; VI-GISEL-NEXT:    v_ldexp_f32 v2, v2, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s5, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v1, v0
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
+; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v5, s4
+; VI-GISEL-NEXT:    v_ldexp_f32 v2, v3, v2
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0xc23369f4
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x421a209b
@@ -498,14 +509,16 @@ define amdgpu_kernel void @s_exp10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
 ; GFX900-GISEL-NEXT:    v_fma_f32 v0, s3, v1, v0
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v1, v5
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v2, v2
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v1
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v4
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v5, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
 ; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, v0
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, s4
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v2, v2, v3
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v2, v3, v2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v4
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0x421a209b
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 0, vcc
@@ -579,14 +592,16 @@ define amdgpu_kernel void @s_exp10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
 ; SI-GISEL-NEXT:    v_fma_f32 v0, s3, v1, v0
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v1, v5
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; SI-GISEL-NEXT:    v_exp_f32_e32 v2, v2
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v1
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v4
+; SI-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v5, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
 ; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
-; SI-GISEL-NEXT:    v_exp_f32_e32 v5, v0
+; SI-GISEL-NEXT:    v_exp_f32_e32 v5, s4
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v2, v2, v3
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v2, v3, v2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v4
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x421a209b
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 0, vcc
@@ -930,8 +945,8 @@ define amdgpu_kernel void @s_exp10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; VI-GISEL-LABEL: s_exp10_v3f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x34
-; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x40549000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x3a2784bc
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x40549000
 ; VI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    s_and_b32 s2, s4, 0xfffff000
@@ -939,48 +954,57 @@ define amdgpu_kernel void @s_exp10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, s4, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3a2784bc, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0x40549000, v0
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s2, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s2, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s2, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s2, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v0, v3
+; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s2, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v3
+; VI-GISEL-NEXT:    v_exp_f32_e32 v3, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s5, 0xfffff000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v5, s5, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3a2784bc, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x40549000, v5
-; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v7
-; VI-GISEL-NEXT:    v_mul_f32_e32 v7, s2, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v7, v5
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v7, v6
-; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v6, v5
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; VI-GISEL-NEXT:    v_exp_f32_e32 v5, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v4, v0
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v4, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v5
+; VI-GISEL-NEXT:    v_mul_f32_e32 v5, s2, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v5, s3, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v5, v6
+; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v5, v5
+; VI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s6, 0xfffff000
-; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v4
-; VI-GISEL-NEXT:    v_ldexp_f32 v5, v5, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_ldexp_f32 v5, v6, v5
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v3, v0
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v6, s6, v6
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3a2784bc, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x40549000, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v6
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v6, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v6
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s3, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s2, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v3, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0xc23369f4
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x421a209b
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v6
-; VI-GISEL-NEXT:    v_exp_f32_e32 v6, v1
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
+; VI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; VI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v4
@@ -1059,35 +1083,38 @@ define amdgpu_kernel void @s_exp10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x33979a37
 ; GFX900-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; GFX900-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
-; GFX900-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
-; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
-; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
-; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
-; GFX900-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
-; GFX900-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, v5
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, s4, v1, -v0
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v4, v0
+; GFX900-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, s4, v2, v3
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
+; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
+; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v0, v3
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v5, v5, v6
+; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
+; GFX900-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX900-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, s2
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v5, v7
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, s2
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v5, v6, v5
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v1
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, s6, v1, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, s6, v2, v1
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v2, v6
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v2
-; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v6, v1
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v3
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v3, v0
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0x421a209b
 ; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, v1
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v3
@@ -1166,37 +1193,40 @@ define amdgpu_kernel void @s_exp10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x40549a78
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x33979a37
 ; SI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x9
-; SI-GISEL-NEXT:    s_mov_b32 s2, -1
+; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
 ; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
-; SI-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
-; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
-; SI-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
-; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
-; SI-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
-; SI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; SI-GISEL-NEXT:    v_exp_f32_e32 v5, v5
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v0, s4, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v3, s4, v1, -v0
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v4, v0
+; SI-GISEL-NEXT:    v_mul_f32_e32 v5, s5, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v3, s4, v2, v3
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
+; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v1, -v5
+; SI-GISEL-NEXT:    v_rndne_f32_e32 v7, v5
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v3
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v5, v5, v6
+; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v2, v6
+; SI-GISEL-NEXT:    v_sub_f32_e32 v5, v5, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; SI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; SI-GISEL-NEXT:    v_exp_f32_e32 v3, s2
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v5, v7
+; SI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v5, v6, v5
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v1
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v4
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; SI-GISEL-NEXT:    v_fma_f32 v1, s6, v1, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v1, s6, v2, v1
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v2, v6
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v2
-; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v6, v1
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v3
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v3, v0
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x421a209b
 ; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v2, v2
-; SI-GISEL-NEXT:    v_exp_f32_e32 v6, v1
+; SI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v3
@@ -1209,7 +1239,7 @@ define amdgpu_kernel void @s_exp10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v4
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 0, vcc
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s6, v3
-; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
+; SI-GISEL-NEXT:    s_mov_b32 s2, -1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v2, v2, v7, vcc
 ; SI-GISEL-NEXT:    buffer_store_dwordx2 v[0:1], off, s[0:3], 0
 ; SI-GISEL-NEXT:    buffer_store_dword v2, off, s[0:3], 0 offset:8
@@ -1693,8 +1723,8 @@ define amdgpu_kernel void @s_exp10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; VI-GISEL-LABEL: s_exp10_v4f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x34
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x40549000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x3a2784bc
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x40549000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, 0x421a209b
 ; VI-GISEL-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0x24
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
@@ -1703,67 +1733,79 @@ define amdgpu_kernel void @s_exp10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, s4, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3a2784bc, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0x40549000, v0
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v4, v0
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v4, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v4
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v4
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, s2, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s3, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v0, v1
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s2, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s5, 0xfffff000
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v2
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v1, s5, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3a2784bc, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x40549000, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v7
-; VI-GISEL-NEXT:    v_mul_f32_e32 v7, s2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v7, v1
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v7, v6
-; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v6, v1
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; VI-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v1
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s3, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v1, v6
+; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s6, 0xfffff000
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, s2, v2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
-; VI-GISEL-NEXT:    v_ldexp_f32 v1, v1, v6
+; VI-GISEL-NEXT:    v_ldexp_f32 v1, v6, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v6, s6, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x3a2784bc, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x40549000, v6
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v9
-; VI-GISEL-NEXT:    v_mul_f32_e32 v9, s2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v9, v6
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v9, v8
-; VI-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v9
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v8, v6
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v8, v9
-; VI-GISEL-NEXT:    v_exp_f32_e32 v6, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v6, s2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s3, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v6, v8
+; VI-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v8, s2, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v6
+; VI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; VI-GISEL-NEXT:    s_and_b32 s2, s7, 0xfffff000
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s2, v3
-; VI-GISEL-NEXT:    v_ldexp_f32 v6, v6, v8
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s2, v2
+; VI-GISEL-NEXT:    v_ldexp_f32 v6, v8, v6
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v8, s7, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x3a2784bc, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x40549000, v8
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v8
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v8, v2
-; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s3, v8
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s3, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v3
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v3, v2
+; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s2, v2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; VI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v7, vcc
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v4
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v8
-; VI-GISEL-NEXT:    v_exp_f32_e32 v8, v2
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v3
+; VI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 0, vcc
 ; VI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s5, v5
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v7, vcc
@@ -1862,43 +1904,47 @@ define amdgpu_kernel void @s_exp10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, s4, v3, v1
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v4
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, s5, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v2, -v1
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v7, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v6, s5, v3, v6
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v1, v6
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v7
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v5
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v1, v1, v6
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v1, v6, v1
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v8, s6, v2, -v6
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v9, v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v8, s6, v3, v8
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v9
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v8, v9
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v6, v6
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v9
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v7, vcc
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v4
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 0, vcc
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v6, v6, v8
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v6, v8, v6
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v8, s7, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, s7, v2, -v8
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, s7, v3, v2
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v3, v8
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v8, v2
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
 ; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v3
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v8, v2
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s5, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v7, vcc
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v4
@@ -1996,44 +2042,48 @@ define amdgpu_kernel void @s_exp10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; SI-GISEL-NEXT:    v_fma_f32 v1, s4, v3, v1
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v1
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v4
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v4
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0xc23369f4
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v4
-; SI-GISEL-NEXT:    s_mov_b32 s2, -1
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v1
+; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v1, v0
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v1, s5, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v2, -v1
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v7, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v6, s5, v3, v6
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v6
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v7
-; SI-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v7
+; SI-GISEL-NEXT:    v_exp_f32_e32 v6, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, 0, vcc
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x7f800000
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s4, v5
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v1, v1, v6
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v1, v6, v1
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v6, s6, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v8, s6, v2, -v6
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v9, v6
 ; SI-GISEL-NEXT:    v_fma_f32 v8, s6, v3, v8
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v6, v6, v9
 ; SI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v8, v9
-; SI-GISEL-NEXT:    v_exp_f32_e32 v6, v6
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v6, v9
+; SI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v7, vcc
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v4
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 0, vcc
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v6, v6, v8
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v6, v8, v6
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v8, s7, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v2, s7, v2, -v8
 ; SI-GISEL-NEXT:    v_fma_f32 v2, s7, v3, v2
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v3, v8
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v8, v8, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v8, v2
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
 ; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v3, v3
-; SI-GISEL-NEXT:    v_exp_f32_e32 v8, v2
+; SI-GISEL-NEXT:    v_exp_f32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s5, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v7, vcc
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v4
@@ -2045,7 +2095,7 @@ define amdgpu_kernel void @s_exp10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v3, v3, 0, vcc
 ; SI-GISEL-NEXT:    v_cmp_gt_f32_e32 vcc, s7, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v7, vcc
-; SI-GISEL-NEXT:    s_mov_b32 s3, 0xf000
+; SI-GISEL-NEXT:    s_mov_b32 s2, -1
 ; SI-GISEL-NEXT:    buffer_store_dwordx4 v[0:3], off, s[0:3], 0
 ; SI-GISEL-NEXT:    s_endpgm
 ;
@@ -5321,21 +5371,24 @@ define float @v_exp10_f32_undef() {
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; VI-GISEL-NEXT:    v_sub_f32_e64 v0, s4, 0
-; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x40549000
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x3a2784bc
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3a2784bc, v0
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0x40549000, v0
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0, v1
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x3a2784bc
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, v0, v3
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v2, v0
-; VI-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x40549000
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 0, v2
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; VI-GISEL-NEXT:    v_rndne_f32_e32 v0, v1
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v0
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; VI-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc23369f4
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x421a209b
@@ -5371,10 +5424,11 @@ define float @v_exp10_f32_undef() {
 ; GFX900-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; GFX900-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v2
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v0, v1
+; GFX900-GISEL-NEXT:    v_ldexp_f32 v0, v1, v0
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc23369f4
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x421a209b
@@ -5410,10 +5464,11 @@ define float @v_exp10_f32_undef() {
 ; SI-GISEL-NEXT:    v_rndne_f32_e32 v2, v1
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v2
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, v1, v0
-; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v1, v2
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v0
+; SI-GISEL-NEXT:    v_cvt_i32_f32_e32 v0, v2
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v0, v1
+; SI-GISEL-NEXT:    v_ldexp_f32_e32 v0, v1, v0
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc23369f4
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x421a209b
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.exp2.ll b/llvm/test/CodeGen/AMDGPU/llvm.exp2.ll
index 36e78975cdb015..6f96e434366657 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.exp2.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.exp2.ll
@@ -40,7 +40,8 @@ define amdgpu_kernel void @s_exp2_f32(ptr addrspace(1) %out, float %in) {
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v0
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v1, vcc
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, s2, v0
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; SI-GISEL-NEXT:    v_exp_f32_e32 v0, s2
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x1f800000
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v1, vcc
 ; SI-GISEL-NEXT:    s_mov_b32 s2, -1
@@ -77,7 +78,8 @@ define amdgpu_kernel void @s_exp2_f32(ptr addrspace(1) %out, float %in) {
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v0
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v1, vcc
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, s2, v0
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v0, s2
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x1f800000
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v1, vcc
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, v0, v1
@@ -114,7 +116,8 @@ define amdgpu_kernel void @s_exp2_f32(ptr addrspace(1) %out, float %in) {
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s2, v0
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v1, vcc
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, s2, v0
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, s2
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x1f800000
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v1, vcc
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v0, v0, v1
@@ -204,13 +207,15 @@ define amdgpu_kernel void @s_exp2_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x1f800000
 ; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v0
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v1, vcc
-; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, 0, v1, s[0:1]
 ; SI-GISEL-NEXT:    v_add_f32_e32 v3, s6, v3
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; SI-GISEL-NEXT:    v_exp_f32_e32 v3, s0
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
+; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, 0, v1, s[0:1]
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, s7, v0
-; SI-GISEL-NEXT:    v_exp_f32_e32 v3, v3
-; SI-GISEL-NEXT:    v_exp_f32_e32 v1, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 1.0, v2, vcc
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v2, s[0:1]
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v0, v3, v0
@@ -252,13 +257,15 @@ define amdgpu_kernel void @s_exp2_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x1f800000
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v0
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v1, vcc
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, 0, v1, s[0:1]
 ; VI-GISEL-NEXT:    v_add_f32_e32 v3, s6, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; VI-GISEL-NEXT:    v_exp_f32_e32 v3, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, 0, v1, s[0:1]
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, s7, v0
-; VI-GISEL-NEXT:    v_exp_f32_e32 v3, v3
-; VI-GISEL-NEXT:    v_exp_f32_e32 v1, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 1.0, v2, vcc
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v2, s[0:1]
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, v3, v0
@@ -299,13 +306,15 @@ define amdgpu_kernel void @s_exp2_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x1f800000
 ; GFX900-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v0
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v1, vcc
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, 0, v1, s[0:1]
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v3, s6, v3
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, s0
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, 0, v1, s[0:1]
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, s7, v0
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, v3
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, 1.0, v2, vcc
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v2, s[0:1]
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v0, v3, v0
@@ -421,21 +430,24 @@ define amdgpu_kernel void @s_exp2_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc
 ; SI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; SI-GISEL-NEXT:    v_exp_f32_e32 v0, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v4, 1.0, v3, vcc
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v1
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s6, v1
+; SI-GISEL-NEXT:    s_mov_b32 s10, -1
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v0, v0, v4
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v4, 0, v2, vcc
 ; SI-GISEL-NEXT:    v_add_f32_e32 v4, s5, v4
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; SI-GISEL-NEXT:    v_exp_f32_e32 v4, s0
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s6, v1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v2, s[0:1]
-; SI-GISEL-NEXT:    v_exp_f32_e32 v4, v4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, s6, v1
-; SI-GISEL-NEXT:    v_exp_f32_e32 v2, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; SI-GISEL-NEXT:    v_exp_f32_e32 v2, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v3, vcc
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v1, v4, v1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v3, 1.0, v3, s[0:1]
-; SI-GISEL-NEXT:    s_mov_b32 s10, -1
 ; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf000
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v2, v2, v3
 ; SI-GISEL-NEXT:    buffer_store_dwordx2 v[0:1], off, s[8:11], 0
@@ -476,7 +488,6 @@ define amdgpu_kernel void @s_exp2_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; VI-GISEL-LABEL: s_exp2_v3f32:
 ; VI-GISEL:       ; %bb.0:
 ; VI-GISEL-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x34
-; VI-GISEL-NEXT:    s_load_dwordx2 s[2:3], s[0:1], 0x24
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc2fc0000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x42800000
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x1f800000
@@ -484,21 +495,26 @@ define amdgpu_kernel void @s_exp2_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v0, s2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v4, 1.0, v3, vcc
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v1
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s6, v1
+; VI-GISEL-NEXT:    s_load_dwordx2 s[2:3], s[0:1], 0x24
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, v0, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v4, 0, v2, vcc
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v2, s[0:1]
 ; VI-GISEL-NEXT:    v_add_f32_e32 v4, s5, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_exp_f32_e32 v4, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s6, v1
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v2, s[0:1]
 ; VI-GISEL-NEXT:    v_add_f32_e32 v1, s6, v1
-; VI-GISEL-NEXT:    v_exp_f32_e32 v4, v4
-; VI-GISEL-NEXT:    v_exp_f32_e32 v2, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v2, s4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v3, vcc
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v3, 1.0, v3, s[0:1]
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, v4, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s2
 ; VI-GISEL-NEXT:    flat_store_dwordx3 v[3:4], v[0:2]
@@ -537,7 +553,6 @@ define amdgpu_kernel void @s_exp2_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX900-GISEL-LABEL: s_exp2_v3f32:
 ; GFX900-GISEL:       ; %bb.0:
 ; GFX900-GISEL-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x34
-; GFX900-GISEL-NEXT:    s_load_dwordx2 s[2:3], s[0:1], 0x24
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0xc2fc0000
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x42800000
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0x1f800000
@@ -545,22 +560,27 @@ define amdgpu_kernel void @s_exp2_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v1
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v0
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, s2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v4, 1.0, v3, vcc
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s5, v1
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s6, v1
+; GFX900-GISEL-NEXT:    s_load_dwordx2 s[2:3], s[0:1], 0x24
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v0, v0, v4
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v4, 0, v2, vcc
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v2, s[0:1]
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v4, s5, v4
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v4, s0
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s6, v1
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v2, s[0:1]
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, s6, v1
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v4, v4
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v2, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v2, s4
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v3, vcc
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v3, 1.0, v3, s[0:1]
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, v4, v1
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v2, v2, v3
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0
+; GFX900-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX900-GISEL-NEXT:    global_store_dwordx3 v3, v[0:2], s[2:3]
 ; GFX900-GISEL-NEXT:    s_endpgm
 ;
@@ -692,39 +712,43 @@ define amdgpu_kernel void @s_exp2_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ;
 ; SI-GISEL-LABEL: s_exp2_v4f32:
 ; SI-GISEL:       ; %bb.0:
-; SI-GISEL-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0xd
-; SI-GISEL-NEXT:    s_load_dwordx2 s[8:9], s[0:1], 0x9
+; SI-GISEL-NEXT:    s_load_dwordx4 s[8:11], s[0:1], 0xd
+; SI-GISEL-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0xc2fc0000
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x42800000
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x1f800000
 ; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v2
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s8, v2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v3, vcc
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
-; SI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
+; SI-GISEL-NEXT:    v_add_f32_e32 v0, s8, v0
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v0
+; SI-GISEL-NEXT:    v_exp_f32_e32 v0, s0
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s9, v2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v3, s[0:1]
-; SI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
-; SI-GISEL-NEXT:    v_add_f32_e32 v1, s5, v1
-; SI-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; SI-GISEL-NEXT:    v_add_f32_e32 v1, s9, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; SI-GISEL-NEXT:    v_exp_f32_e32 v1, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v5, 1.0, v4, vcc
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v0, v0, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v5, 1.0, v4, s[0:1]
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v2
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s10, v2
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v1, v1, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v5, 0, v3, vcc
+; SI-GISEL-NEXT:    v_add_f32_e32 v5, s10, v5
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; SI-GISEL-NEXT:    v_exp_f32_e32 v5, s0
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s11, v2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v3, s[0:1]
-; SI-GISEL-NEXT:    v_add_f32_e32 v5, s6, v5
-; SI-GISEL-NEXT:    v_add_f32_e32 v2, s7, v2
-; SI-GISEL-NEXT:    v_exp_f32_e32 v5, v5
-; SI-GISEL-NEXT:    v_exp_f32_e32 v3, v2
+; SI-GISEL-NEXT:    v_add_f32_e32 v2, s11, v2
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; SI-GISEL-NEXT:    v_exp_f32_e32 v3, s2
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v2, 1.0, v4, vcc
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 1.0, v4, s[0:1]
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v2, v5, v2
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v3, v3, v4
-; SI-GISEL-NEXT:    s_mov_b32 s10, -1
-; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf000
-; SI-GISEL-NEXT:    buffer_store_dwordx4 v[0:3], off, s[8:11], 0
+; SI-GISEL-NEXT:    s_mov_b32 s6, -1
+; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000
+; SI-GISEL-NEXT:    buffer_store_dwordx4 v[0:3], off, s[4:7], 0
 ; SI-GISEL-NEXT:    s_endpgm
 ;
 ; VI-SDAG-LABEL: s_exp2_v4f32:
@@ -774,24 +798,28 @@ define amdgpu_kernel void @s_exp2_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v3, vcc
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v0
+; VI-GISEL-NEXT:    v_exp_f32_e32 v0, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v3, s[0:1]
-; VI-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; VI-GISEL-NEXT:    v_add_f32_e32 v1, s5, v1
-; VI-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v5, 1.0, v4, vcc
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v0, v0, v5
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v5, 1.0, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v2
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, v1, v5
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v5, 0, v3, vcc
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v3, s[0:1]
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, s6, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; VI-GISEL-NEXT:    v_exp_f32_e32 v5, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v3, s[0:1]
 ; VI-GISEL-NEXT:    v_add_f32_e32 v2, s7, v2
-; VI-GISEL-NEXT:    v_exp_f32_e32 v5, v5
-; VI-GISEL-NEXT:    v_exp_f32_e32 v3, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; VI-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v2, 1.0, v4, vcc
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 1.0, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, v5, v2
@@ -847,24 +875,28 @@ define amdgpu_kernel void @s_exp2_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; GFX900-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v3, vcc
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v0, s4, v0
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v0
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, s0
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, v3, s[0:1]
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v0, v0
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, s5, v1
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v1, s4
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v5, 1.0, v4, vcc
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v0, v0, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v5, 1.0, v4, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v2
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, v1, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v5, 0, v3, vcc
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v3, s[0:1]
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v5, s6, v5
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, s0
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v3, s[0:1]
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, s7, v2
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v5, v5
-; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, v2
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; GFX900-GISEL-NEXT:    v_exp_f32_e32 v3, s4
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v2, 1.0, v4, vcc
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v4, 1.0, v4, s[0:1]
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v2, v5, v2
@@ -1820,10 +1852,14 @@ define float @v_exp2_f32_undef() {
 ; GCN-GISEL-LABEL: v_exp2_f32_undef:
 ; GCN-GISEL:       ; %bb.0:
 ; GCN-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GCN-GISEL-NEXT:    v_mov_b32_e32 v0, 0xc2fc0000
 ; GCN-GISEL-NEXT:    v_mov_b32_e32 v1, 0x42800000
 ; GCN-GISEL-NEXT:    v_add_f32_e32 v1, s4, v1
-; GCN-GISEL-NEXT:    v_add_f32_e64 v2, s4, 0
+; GCN-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; GCN-GISEL-NEXT:    v_add_f32_e64 v1, s4, 0
+; GCN-GISEL-NEXT:    v_mov_b32_e32 v0, 0xc2fc0000
+; GCN-GISEL-NEXT:    v_readfirstlane_b32 s5, v1
+; GCN-GISEL-NEXT:    v_mov_b32_e32 v1, s4
+; GCN-GISEL-NEXT:    v_mov_b32_e32 v2, s5
 ; GCN-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s4, v0
 ; GCN-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v1, vcc
 ; GCN-GISEL-NEXT:    v_exp_f32_e32 v0, v0
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.log.ll b/llvm/test/CodeGen/AMDGPU/llvm.log.ll
index d847af780acab3..7351444a4119fa 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.log.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.log.ll
@@ -59,6 +59,8 @@ define amdgpu_kernel void @s_log_f32(ptr addrspace(1) %out, float %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v4
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v2, v1
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v4, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; SI-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v3
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x41b17218
@@ -115,15 +117,19 @@ define amdgpu_kernel void @s_log_f32(ptr addrspace(1) %out, float %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v0, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3805fdf4, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3805fdf4, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3f317000, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3f317000, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s0, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3f317000, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v2
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s0, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x41b17218
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[0:1]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v0, v1
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
@@ -177,6 +183,8 @@ define amdgpu_kernel void @s_log_f32(ptr addrspace(1) %out, float %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v4
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v2, v1
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v4, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v3
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x41b17218
@@ -224,19 +232,21 @@ define amdgpu_kernel void @s_log_f32(ptr addrspace(1) %out, float %in) {
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, 1.0, 0x4f800000, s3
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v0, s2, v0
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3f317217, v0
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v2, 0x3f317217, v0, -v1
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v2, 0x3377d1cf, v0
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, 0x41b17218, s3
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_dual_cndmask_b32 v0, v0, v1 :: v_dual_mov_b32 v1, 0
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v2
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, 0x41b17218, s3
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s3, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s3
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v0, v0, v1 :: v_dual_mov_b32 v1, 0
 ; GFX1100-GISEL-NEXT:    global_store_b32 v1, v0, s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -375,6 +385,8 @@ define amdgpu_kernel void @s_log_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v2, v3, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v2, v4, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; SI-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v6, s[0:1]
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
@@ -388,6 +400,8 @@ define amdgpu_kernel void @s_log_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v1, v3, -v2
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v1, v4, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; SI-GISEL-NEXT:    v_mov_b32_e32 v2, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v1|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v2, vcc
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v6, s[0:1]
@@ -458,11 +472,15 @@ define amdgpu_kernel void @s_log_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v5, v2, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3805fdf4, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3805fdf4, v5
-; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3f317000, v5
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3f317000, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v5, s0, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317000, v4
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s0
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v3
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
@@ -477,10 +495,14 @@ define amdgpu_kernel void @s_log_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3805fdf4, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3805fdf4, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v7, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3f317000, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v5, s2, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3f317000, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s2, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v1|, v3
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v2, vcc
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v4, s[0:1]
@@ -545,6 +567,8 @@ define amdgpu_kernel void @s_log_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v2, v3, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v2, v4, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v6, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
@@ -558,6 +582,8 @@ define amdgpu_kernel void @s_log_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v1, v3, -v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v1, v4, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v1|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v2, vcc
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v6, s[0:1]
@@ -613,24 +639,29 @@ define amdgpu_kernel void @s_log_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v0, s2, v0 :: v_dual_mul_f32 v1, s3, v1
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v1, v1
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v2, 0x3f317217, v0 :: v_dual_mul_f32 v3, 0x3f317217, v1
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v4, 0x3f317217, v0, -v2
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v5, 0x3f317217, v1, -v3
 ; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v4, 0x3377d1cf, v0 :: v_dual_fmac_f32 v5, 0x3377d1cf, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_dual_add_f32 v2, v2, v4 :: v_dual_add_f32 v3, v3, v5
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, 0x41b17218, s4
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v5, 0, 0x41b17218, s5
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v1|
-; GFX1100-GISEL-NEXT:    v_dual_mov_b32 v2, 0 :: v_dual_cndmask_b32 v1, v1, v3
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v0, v0, v4 :: v_dual_sub_f32 v1, v1, v5
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, 0x41b17218, s4
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s4, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s3, v3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, 0, 0x41b17218, s5
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s4
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v1|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, s3, s2
+; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v2
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    v_dual_mov_b32 v2, 0 :: v_dual_sub_f32 v1, v1, v3
 ; GFX1100-GISEL-NEXT:    global_store_b64 v2, v[0:1], s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -819,6 +850,8 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v3, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v4, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; SI-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v6, s[0:1]
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s9, v1
@@ -827,15 +860,17 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; SI-GISEL-NEXT:    v_log_f32_e32 v6, v6
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x41b17218
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s10, v1
-; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v8
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3f317217, v6
-; SI-GISEL-NEXT:    v_mul_f32_e32 v1, s10, v1
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s10, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v9, v6, v3, -v8
-; SI-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; SI-GISEL-NEXT:    v_fma_f32 v9, v6, v4, v9
+; SI-GISEL-NEXT:    v_mul_f32_e32 v1, s10, v1
 ; SI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
+; SI-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; SI-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v6|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v6, v8, s[2:3]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, v7, s[0:1]
@@ -844,6 +879,8 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v2, v3, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v2, v4, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v3, v6, v3
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; SI-GISEL-NEXT:    v_mov_b32_e32 v3, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v3, s[0:1]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v7, vcc
@@ -934,49 +971,61 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v4, v0, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3805fdf4, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3805fdf4, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317000, v4
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317000, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3f317000, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
-; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v4
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v3, s[0:1]
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s0, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v1
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v3, 1.0, v2, s[0:1]
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s5, v3
-; VI-GISEL-NEXT:    v_log_f32_e32 v3, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 1.0, v2, s[0:1]
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s5, v4
+; VI-GISEL-NEXT:    v_log_f32_e32 v4, v4
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, 0x41b17218
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v6, 0, v5, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v6
-; VI-GISEL-NEXT:    v_and_b32_e32 v6, 0xfffff000, v3
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v7, v3, v6
-; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
+; VI-GISEL-NEXT:    v_and_b32_e32 v6, 0xfffff000, v4
+; VI-GISEL-NEXT:    v_sub_f32_e32 v7, v4, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3805fdf4, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x3805fdf4, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v9, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3f317000, v7
-; VI-GISEL-NEXT:    v_log_f32_e32 v2, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v7, v7, v8
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v7, s2, v7
+; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3f317000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v3|, v4
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v3, v6, s[2:3]
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v3, 0, v5, s[0:1]
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v3
-; VI-GISEL-NEXT:    v_and_b32_e32 v3, 0xfffff000, v2
-; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v2, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v4|, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v4, v6, s[2:3]
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v5, s[0:1]
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v4
+; VI-GISEL-NEXT:    v_and_b32_e32 v4, 0xfffff000, v2
+; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v2, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3805fdf4, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3805fdf4, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3805fdf4, v4
 ; VI-GISEL-NEXT:    v_add_f32_e32 v7, v8, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3f317000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3f317000, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v6
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v4
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v3, s[0:1]
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s0, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317000, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v5, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s8
@@ -1053,6 +1102,8 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v3, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v4, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v6, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v1
@@ -1061,15 +1112,17 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_log_f32_e32 v6, v6
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v7, 0x41b17218
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v8
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3f317217, v6
-; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v9, v6, v3, -v8
-; GFX900-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; GFX900-GISEL-NEXT:    v_fma_f32 v9, v6, v4, v9
+; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
+; GFX900-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v6|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, v6, v8, s[2:3]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, v7, s[0:1]
@@ -1078,6 +1131,8 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v2, v3, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v2, v4, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v3, v6, v3
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v3, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v7, vcc
@@ -1154,20 +1209,19 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, 1.0, 0x4f800000, s2
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 1.0, 0x4f800000, s3
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_4)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, 0x4f800000, s7
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v10, 0, 0x41b17218, s3
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v9, 0, 0x41b17218, s2
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v0, s4, v0 :: v_dual_mul_f32 v1, s5, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v2, s6, v2
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v1, v1
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3f317217, v0
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v2, v2
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317217, v1
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s5, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_4) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v6, 0x3f317217, v0, -v3
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
@@ -1178,21 +1232,29 @@ define amdgpu_kernel void @s_log_v3f32(ptr addrspace(1) %out, <3 x float> %in) {
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v7, 0x3377d1cf, v1
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v3, v3, v6
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, 0x41b17218, s7
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, 0x41b17218, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v4, v4, v7
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v1|
-; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v8, 0x3377d1cf, v2 :: v_dual_mov_b32 v3, 0
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v4, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v2|
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v10
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_dual_add_f32 v5, v5, v8 :: v_dual_sub_f32 v0, v0, v9
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v2, v2, v5, vcc_lo
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v7, 0, 0x41b17218, s3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, 0, 0x41b17218, s7
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s3, v4
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s5
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v1|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v6
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, s3, s2
+; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v8, 0x3377d1cf, v2
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v2|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v7
+; GFX1100-GISEL-NEXT:    v_add_f32_e32 v5, v5, v8
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s4, v5
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, s4, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v6
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v2, v2, v3 :: v_dual_mov_b32 v3, 0
 ; GFX1100-GISEL-NEXT:    global_store_b96 v3, v[0:2], s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -1436,6 +1498,8 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v4, -v1
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v5, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; SI-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s9, v2
@@ -1453,18 +1517,22 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v9, 1.0, v3, vcc
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v9, s10, v9
 ; SI-GISEL-NEXT:    v_log_f32_e32 v9, v9
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; SI-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v1|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, v8, s[2:3]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v8, 0, v7, s[0:1]
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s11, v2
-; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v8
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3f317217, v9
-; SI-GISEL-NEXT:    v_mul_f32_e32 v2, s11, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v10, v9, v4, -v8
-; SI-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v10, v9, v5, v10
 ; SI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v10
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v8
+; SI-GISEL-NEXT:    v_mov_b32_e32 v8, s0
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s11, v2
+; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
+; SI-GISEL-NEXT:    v_mul_f32_e32 v2, s11, v2
+; SI-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v9|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v9, v8, s[2:3]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
@@ -1473,6 +1541,8 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v4, v3, v4, -v8
 ; SI-GISEL-NEXT:    v_fma_f32 v4, v3, v5, v4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v4, v8, v4
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v4
+; SI-GISEL-NEXT:    v_mov_b32_e32 v4, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v3|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v4, vcc
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v7, s[0:1]
@@ -1578,12 +1648,16 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v4, v0, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3805fdf4, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3805fdf4, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317000, v4
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317000, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3f317000, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s0, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
@@ -1598,31 +1672,39 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3805fdf4, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x3805fdf4, v6
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v9, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3f317000, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v7, v7, v8
-; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3f317000, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v7, s2, v7
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v7
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v7, 1.0, v3, vcc
+; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3f317000, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, s6, v7
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
 ; VI-GISEL-NEXT:    v_log_f32_e32 v7, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v1|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, v6, s[2:3]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, v5, s[0:1]
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v6
 ; VI-GISEL-NEXT:    v_and_b32_e32 v6, 0xfffff000, v7
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v8, v7, v6
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x3805fdf4, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v10, 0x3805fdf4, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v9, v10, v9
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v9
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3f317000, v8
-; VI-GISEL-NEXT:    v_log_f32_e32 v3, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
+; VI-GISEL-NEXT:    v_add_f32_e32 v8, s0, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3f317000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s0, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
+; VI-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v7|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v7, v6, s[2:3]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v6, 0, v5, vcc
@@ -1632,10 +1714,14 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3805fdf4, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x3805fdf4, v6
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v9, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3f317000, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v7, v7, v8
+; VI-GISEL-NEXT:    v_add_f32_e32 v7, s2, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3f317000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v3|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v6, vcc
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v5, s[0:1]
@@ -1726,6 +1812,8 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v4, -v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v5, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v1, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
@@ -1743,18 +1831,22 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v9, 1.0, v3, vcc
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v9, s6, v9
 ; GFX900-GISEL-NEXT:    v_log_f32_e32 v9, v9
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v1|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, v8, s[2:3]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v8, 0, v7, s[0:1]
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v8
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3f317217, v9
-; GFX900-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v10, v9, v4, -v8
-; GFX900-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v10, v9, v5, v10
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v8, v8, v10
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v8
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v8, s0
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
+; GFX900-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
+; GFX900-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v9|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v9, v8, s[2:3]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
@@ -1763,6 +1855,8 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v4, v3, v4, -v8
 ; GFX900-GISEL-NEXT:    v_fma_f32 v4, v3, v5, v4
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v4, v8, v4
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v4
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v3|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v4, vcc
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v7, s[0:1]
@@ -1848,47 +1942,52 @@ define amdgpu_kernel void @s_log_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, 0x4f800000, s8
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, 1.0, 0x4f800000, s9
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, 0x41b17218, s2
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v8, 0, 0x41b17218, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v0, s4, v0 :: v_dual_mul_f32 v1, s5, v1
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v2, s6, v2 :: v_dual_mul_f32 v3, s7, v3
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v9, 0, 0x41b17218, s3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v13, 0, 0x41b17218, s3
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v1, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(TRANS32_DEP_3)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(TRANS32_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v2, v2
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v3, v3
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v14, 0, 0x41b17218, s8
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v15, 0, 0x41b17218, s9
-; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v5, 0x3f317217, v0 :: v_dual_mul_f32 v6, 0x3f317217, v1
+; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v4, 0x3f317217, v0 :: v_dual_mul_f32 v5, 0x3f317217, v1
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
-; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v7, 0x3f317217, v2 :: v_dual_mul_f32 v8, 0x3f317217, v3
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
-; GFX1100-GISEL-NEXT:    v_fma_f32 v10, 0x3f317217, v0, -v5
-; GFX1100-GISEL-NEXT:    v_fma_f32 v11, 0x3f317217, v1, -v6
+; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v6, 0x3f317217, v2 :: v_dual_mul_f32 v7, 0x3f317217, v3
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s6, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_fma_f32 v9, 0x3f317217, v0, -v4
+; GFX1100-GISEL-NEXT:    v_fma_f32 v10, 0x3f317217, v1, -v5
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
-; GFX1100-GISEL-NEXT:    v_fma_f32 v12, 0x3f317217, v2, -v7
-; GFX1100-GISEL-NEXT:    v_fma_f32 v13, 0x3f317217, v3, -v8
-; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v10, 0x3377d1cf, v0 :: v_dual_fmac_f32 v11, 0x3377d1cf, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v12, 0x3377d1cf, v2 :: v_dual_fmac_f32 v13, 0x3377d1cf, v3
-; GFX1100-GISEL-NEXT:    v_dual_add_f32 v5, v5, v10 :: v_dual_add_f32 v6, v6, v11
+; GFX1100-GISEL-NEXT:    v_fma_f32 v11, 0x3f317217, v2, -v6
+; GFX1100-GISEL-NEXT:    v_fma_f32 v12, 0x3f317217, v3, -v7
+; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v9, 0x3377d1cf, v0 :: v_dual_fmac_f32 v10, 0x3377d1cf, v1
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_dual_add_f32 v7, v7, v12 :: v_dual_add_f32 v8, v8, v13
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v5, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v1|
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v6, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v2|
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_dual_mov_b32 v4, 0 :: v_dual_sub_f32 v1, v1, v9
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v2, v2, v7, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v3|
-; GFX1100-GISEL-NEXT:    v_dual_cndmask_b32 v3, v3, v8 :: v_dual_sub_f32 v2, v2, v14
+; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v11, 0x3377d1cf, v2 :: v_dual_fmac_f32 v12, 0x3377d1cf, v3
+; GFX1100-GISEL-NEXT:    v_dual_add_f32 v4, v4, v9 :: v_dual_add_f32 v5, v5, v10
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_dual_add_f32 v6, v6, v11 :: v_dual_add_f32 v7, v7, v12
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v9, 0, 0x41b17218, s9
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v4
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s3, v5
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s4, v6
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s5, v7
+; GFX1100-GISEL-NEXT:    v_mov_b32_e32 v4, 0
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s6
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v1|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, s3, s2
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v2|
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v0, v0, v8 :: v_dual_sub_f32 v1, v1, v13
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, s4, s2
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v3|
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, v3, s5, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v15
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v2, v2, v14 :: v_dual_sub_f32 v3, v3, v9
 ; GFX1100-GISEL-NEXT:    global_store_b128 v4, v[0:3], s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -5577,10 +5676,12 @@ define float @v_log_f32_undef() {
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v2
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v3, v1
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v2, v1
-; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v2
-; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[4:5]
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; SI-GISEL-NEXT:    v_mov_b32_e32 v2, s4
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v1
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x41b17218
+; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[4:5]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]
@@ -5617,14 +5718,18 @@ define float @v_log_f32_undef() {
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3805fdf4, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3805fdf4, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3f317000, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s4, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3f317000, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v2
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[4:5]
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s4
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x41b17218
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[4:5]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]
@@ -5659,10 +5764,12 @@ define float @v_log_f32_undef() {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v3, v1
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v2, v1
-; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v2
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[4:5]
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, s4
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v1
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x41b17218
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[4:5]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; GFX900-GISEL-NEXT:    s_setpc_b64 s[30:31]
@@ -5692,15 +5799,16 @@ define float @v_log_f32_undef() {
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3f317217, v0
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s0, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s1, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v2, 0x3f317217, v0, -v1
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v2, 0x3377d1cf, v0
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s0
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, 0x41b17218, vcc_lo
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s0, s1
 ; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; GFX1100-GISEL-NEXT:    s_setpc_b64 s[30:31]
 ;
@@ -5744,10 +5852,12 @@ define float @v_log_f32_0() {
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317217, v0
 ; SI-GISEL-NEXT:    v_fma_f32 v2, v0, v2, -v4
 ; SI-GISEL-NEXT:    v_fma_f32 v2, v0, v3, v2
-; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v4, v2
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v3
-; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
+; SI-GISEL-NEXT:    v_mov_b32_e32 v3, s4
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v2
+; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x41b17218
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, 0, v1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
@@ -5782,14 +5892,18 @@ define float @v_log_f32_0() {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v0, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3805fdf4, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3805fdf4, v3
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3f317000, v3
 ; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
+; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3f317000, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s4, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3f317000, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
-; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v3
-; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s4, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s4
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v2
+; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x41b17218
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, 0, v1
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
@@ -5822,10 +5936,12 @@ define float @v_log_f32_0() {
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3f317217, v0
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, v0, v2, -v4
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, v0, v3, v2
-; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v4, v2
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v3
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, s4
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v2
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x41b17218
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, 0, v1
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
@@ -5853,16 +5969,18 @@ define float @v_log_f32_0() {
 ; GFX1100-GISEL:       ; %bb.0:
 ; GFX1100-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, 0
-; GFX1100-GISEL-NEXT:    v_cmp_lt_f32_e64 s0, 0, 0x800000
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3f317217, v0
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s1, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v2, 0x3f317217, v0, -v1
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v2, 0x3377d1cf, v0
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v1, vcc_lo
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s0, s1
+; GFX1100-GISEL-NEXT:    v_cmp_lt_f32_e64 s0, 0, 0x800000
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, 0x41b17218, s0
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.log10.ll b/llvm/test/CodeGen/AMDGPU/llvm.log10.ll
index 3f060de9f6596d..00f72a0f00ab55 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.log10.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.log10.ll
@@ -59,6 +59,8 @@ define amdgpu_kernel void @s_log10_f32(ptr addrspace(1) %out, float %in) {
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v4
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v2, v1
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v4, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; SI-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v3
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x411a209b
@@ -115,15 +117,19 @@ define amdgpu_kernel void @s_log10_f32(ptr addrspace(1) %out, float %in) {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v0, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x369a84fb, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x369a84fb, v2
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3e9a2000, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3e9a2000, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s0, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3e9a2000, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v2
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v2
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s0, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x411a209b
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[0:1]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v0, v1
 ; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)
@@ -177,6 +183,8 @@ define amdgpu_kernel void @s_log10_f32(ptr addrspace(1) %out, float %in) {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v4
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v2, v1
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v4, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v3
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x411a209b
@@ -224,19 +232,21 @@ define amdgpu_kernel void @s_log10_f32(ptr addrspace(1) %out, float %in) {
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, 1.0, 0x4f800000, s3
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v0, s2, v0
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3e9a209a, v0
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v2, 0x3e9a209a, v0, -v1
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v2, 0x3284fbcf, v0
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, 0x411a209b, s3
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_dual_cndmask_b32 v0, v0, v1 :: v_dual_mov_b32 v1, 0
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v2
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v1
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, 0x411a209b, s3
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s3, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s3
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v0, v0, v1 :: v_dual_mov_b32 v1, 0
 ; GFX1100-GISEL-NEXT:    global_store_b32 v1, v0, s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -375,6 +385,8 @@ define amdgpu_kernel void @s_log10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v2, v3, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v2, v4, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; SI-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v6, s[0:1]
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
@@ -388,6 +400,8 @@ define amdgpu_kernel void @s_log10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v1, v3, -v2
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v1, v4, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; SI-GISEL-NEXT:    v_mov_b32_e32 v2, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v1|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v2, vcc
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v6, s[0:1]
@@ -458,11 +472,15 @@ define amdgpu_kernel void @s_log10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v5, v2, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x369a84fb, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x369a84fb, v5
-; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3e9a2000, v5
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3e9a2000, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v5, s0, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a2000, v4
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s0
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v3
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
@@ -477,10 +495,14 @@ define amdgpu_kernel void @s_log10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x369a84fb, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x369a84fb, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v6, v7, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x3e9a2000, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v5, s2, v5
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v5
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3e9a2000, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s2, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v1|, v3
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v2, vcc
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v4, s[0:1]
@@ -545,6 +567,8 @@ define amdgpu_kernel void @s_log10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v2, v3, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v2, v4, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v6, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v0
@@ -558,6 +582,8 @@ define amdgpu_kernel void @s_log10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v1, v3, -v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v1, v4, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v1|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v2, vcc
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, v6, s[0:1]
@@ -613,24 +639,29 @@ define amdgpu_kernel void @s_log10_v2f32(ptr addrspace(1) %out, <2 x float> %in)
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v0, s2, v0 :: v_dual_mul_f32 v1, s3, v1
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v1, v1
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v2, 0x3e9a209a, v0 :: v_dual_mul_f32 v3, 0x3e9a209a, v1
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v4, 0x3e9a209a, v0, -v2
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v5, 0x3e9a209a, v1, -v3
 ; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v4, 0x3284fbcf, v0 :: v_dual_fmac_f32 v5, 0x3284fbcf, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_dual_add_f32 v2, v2, v4 :: v_dual_add_f32 v3, v3, v5
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, 0x411a209b, s4
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v5, 0, 0x411a209b, s5
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v1|
-; GFX1100-GISEL-NEXT:    v_dual_mov_b32 v2, 0 :: v_dual_cndmask_b32 v1, v1, v3
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v0, v0, v4 :: v_dual_sub_f32 v1, v1, v5
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v2
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 0, 0x411a209b, s4
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s4, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s3, v3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, 0, 0x411a209b, s5
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s4
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v1|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, s3, s2
+; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v2
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    v_dual_mov_b32 v2, 0 :: v_dual_sub_f32 v1, v1, v3
 ; GFX1100-GISEL-NEXT:    global_store_b64 v2, v[0:1], s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -819,6 +850,8 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v3, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v4, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; SI-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v6, s[0:1]
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s9, v1
@@ -827,15 +860,17 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; SI-GISEL-NEXT:    v_log_f32_e32 v6, v6
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v7, 0x411a209b
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s10, v1
-; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v8
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3e9a209a, v6
-; SI-GISEL-NEXT:    v_mul_f32_e32 v1, s10, v1
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s10, v1
 ; SI-GISEL-NEXT:    v_fma_f32 v9, v6, v3, -v8
-; SI-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; SI-GISEL-NEXT:    v_fma_f32 v9, v6, v4, v9
+; SI-GISEL-NEXT:    v_mul_f32_e32 v1, s10, v1
 ; SI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
+; SI-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; SI-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v6|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v6, v8, s[2:3]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, v7, s[0:1]
@@ -844,6 +879,8 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v2, v3, -v6
 ; SI-GISEL-NEXT:    v_fma_f32 v3, v2, v4, v3
 ; SI-GISEL-NEXT:    v_add_f32_e32 v3, v6, v3
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; SI-GISEL-NEXT:    v_mov_b32_e32 v3, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v3, s[0:1]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v7, vcc
@@ -934,49 +971,61 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v4, v0, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x369a84fb, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x369a84fb, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a2000, v4
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a2000, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3e9a2000, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
-; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v4
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v3, s[0:1]
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s0, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v1
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v3, 1.0, v2, s[0:1]
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, s5, v3
-; VI-GISEL-NEXT:    v_log_f32_e32 v3, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 1.0, v2, s[0:1]
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, s5, v4
+; VI-GISEL-NEXT:    v_log_f32_e32 v4, v4
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v5, 0x411a209b
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v6, 0, v5, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v6
-; VI-GISEL-NEXT:    v_and_b32_e32 v6, 0xfffff000, v3
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
-; VI-GISEL-NEXT:    v_sub_f32_e32 v7, v3, v6
-; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
+; VI-GISEL-NEXT:    v_and_b32_e32 v6, 0xfffff000, v4
+; VI-GISEL-NEXT:    v_sub_f32_e32 v7, v4, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x369a84fb, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x369a84fb, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v9, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3e9a2000, v7
-; VI-GISEL-NEXT:    v_log_f32_e32 v2, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v7, v7, v8
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v7, s2, v7
+; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3e9a2000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v3|, v4
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v3, v6, s[2:3]
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v3, 0, v5, s[0:1]
-; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v3
-; VI-GISEL-NEXT:    v_and_b32_e32 v3, 0xfffff000, v2
-; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v2, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v4|, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v4, v6, s[2:3]
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v5, s[0:1]
+; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v4
+; VI-GISEL-NEXT:    v_and_b32_e32 v4, 0xfffff000, v2
+; VI-GISEL-NEXT:    v_sub_f32_e32 v6, v2, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x369a84fb, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x369a84fb, v3
+; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x369a84fb, v4
 ; VI-GISEL-NEXT:    v_add_f32_e32 v7, v8, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3e9a2000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3e9a2000, v3
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v6
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v4
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v3, s[0:1]
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s0, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a2000, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v3
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v4, s[0:1]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v5, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v3
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s8
@@ -1053,6 +1102,8 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v3, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v4, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v6, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v6, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v1
@@ -1061,15 +1112,17 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX900-GISEL-NEXT:    v_log_f32_e32 v6, v6
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v7, 0x411a209b
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v8
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3e9a209a, v6
-; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v9, v6, v3, -v8
-; GFX900-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 1.0, v2, vcc
 ; GFX900-GISEL-NEXT:    v_fma_f32 v9, v6, v4, v9
+; GFX900-GISEL-NEXT:    v_mul_f32_e32 v1, s6, v1
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
+; GFX900-GISEL-NEXT:    v_log_f32_e32 v2, v1
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v6|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, v6, v8, s[2:3]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, v7, s[0:1]
@@ -1078,6 +1131,8 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v2, v3, -v6
 ; GFX900-GISEL-NEXT:    v_fma_f32 v3, v2, v4, v3
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v3, v6, v3
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v3
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v2|, v5
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, v3, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v3, 0, v7, vcc
@@ -1154,20 +1209,19 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, 1.0, 0x4f800000, s2
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 1.0, 0x4f800000, s3
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_4)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, 0x4f800000, s7
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v10, 0, 0x411a209b, s3
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v9, 0, 0x411a209b, s2
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v0, s4, v0 :: v_dual_mul_f32 v1, s5, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v2, s6, v2
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v1, v1
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3e9a209a, v0
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v2, v2
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a209a, v1
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s5, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_4) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v6, 0x3e9a209a, v0, -v3
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
@@ -1178,21 +1232,29 @@ define amdgpu_kernel void @s_log10_v3f32(ptr addrspace(1) %out, <3 x float> %in)
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v7, 0x3284fbcf, v1
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v3, v3, v6
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, 0x411a209b, s7
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, 0x411a209b, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v4, v4, v7
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v1|
-; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v8, 0x3284fbcf, v2 :: v_dual_mov_b32 v3, 0
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v4, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v2|
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v10
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_dual_add_f32 v5, v5, v8 :: v_dual_sub_f32 v0, v0, v9
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v2, v2, v5, vcc_lo
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v7, 0, 0x411a209b, s3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, 0, 0x411a209b, s7
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s3, v4
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s5
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v1|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v6
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, s3, s2
+; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v8, 0x3284fbcf, v2
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v2|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v7
+; GFX1100-GISEL-NEXT:    v_add_f32_e32 v5, v5, v8
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s4, v5
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, s4, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v2, v2, v6
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v2, v2, v3 :: v_dual_mov_b32 v3, 0
 ; GFX1100-GISEL-NEXT:    global_store_b96 v3, v[0:2], s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -1436,6 +1498,8 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v4, -v1
 ; SI-GISEL-NEXT:    v_fma_f32 v7, v0, v5, v7
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v7
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; SI-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s9, v2
@@ -1453,18 +1517,22 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v9, 1.0, v3, vcc
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v9, s10, v9
 ; SI-GISEL-NEXT:    v_log_f32_e32 v9, v9
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; SI-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v1|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, v8, s[2:3]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v8, 0, v7, s[0:1]
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s11, v2
-; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v8
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3e9a209a, v9
-; SI-GISEL-NEXT:    v_mul_f32_e32 v2, s11, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v10, v9, v4, -v8
-; SI-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; SI-GISEL-NEXT:    v_fma_f32 v10, v9, v5, v10
 ; SI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v10
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s0, v8
+; SI-GISEL-NEXT:    v_mov_b32_e32 v8, s0
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s11, v2
+; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
+; SI-GISEL-NEXT:    v_mul_f32_e32 v2, s11, v2
+; SI-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v9|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v9, v8, s[2:3]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
@@ -1473,6 +1541,8 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; SI-GISEL-NEXT:    v_fma_f32 v4, v3, v4, -v8
 ; SI-GISEL-NEXT:    v_fma_f32 v4, v3, v5, v4
 ; SI-GISEL-NEXT:    v_add_f32_e32 v4, v8, v4
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s2, v4
+; SI-GISEL-NEXT:    v_mov_b32_e32 v4, s2
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v3|, v6
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v4, vcc
 ; SI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v7, s[0:1]
@@ -1578,12 +1648,16 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v4, v0, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x369a84fb, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x369a84fb, v4
-; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a2000, v4
 ; VI-GISEL-NEXT:    v_add_f32_e32 v5, v5, v6
+; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a2000, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v5
+; VI-GISEL-NEXT:    v_add_f32_e32 v4, s0, v4
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3e9a2000, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s0, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
@@ -1598,31 +1672,39 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x369a84fb, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x369a84fb, v6
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v9, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3e9a2000, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v7, v7, v8
-; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3e9a2000, v6
+; VI-GISEL-NEXT:    v_add_f32_e32 v7, s2, v7
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, s6, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v7
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v7, 1.0, v3, vcc
+; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3e9a2000, v6
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, s6, v7
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
 ; VI-GISEL-NEXT:    v_log_f32_e32 v7, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v1|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, v6, s[2:3]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v6, 0, v5, s[0:1]
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v6
 ; VI-GISEL-NEXT:    v_and_b32_e32 v6, 0xfffff000, v7
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v8, v7, v6
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x369a84fb, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v10, 0x369a84fb, v6
-; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v9, v10, v9
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v9
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3e9a2000, v8
-; VI-GISEL-NEXT:    v_log_f32_e32 v3, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v8, v8, v9
+; VI-GISEL-NEXT:    v_add_f32_e32 v8, s0, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3e9a2000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v8
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s0, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s0, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s0
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
+; VI-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
+; VI-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v7|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v7, v6, s[2:3]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v6, 0, v5, vcc
@@ -1632,10 +1714,14 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v8, 0x369a84fb, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v9, 0x369a84fb, v6
 ; VI-GISEL-NEXT:    v_add_f32_e32 v8, v9, v8
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v7, 0x3e9a2000, v7
-; VI-GISEL-NEXT:    v_add_f32_e32 v7, v7, v8
+; VI-GISEL-NEXT:    v_add_f32_e32 v7, s2, v7
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v7
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v6, 0x3e9a2000, v6
-; VI-GISEL-NEXT:    v_add_f32_e32 v6, v6, v7
+; VI-GISEL-NEXT:    v_add_f32_e32 v6, s2, v6
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s2, v6
+; VI-GISEL-NEXT:    v_mov_b32_e32 v6, s2
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v3|, v4
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v6, vcc
 ; VI-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v5, s[0:1]
@@ -1726,6 +1812,8 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v4, -v1
 ; GFX900-GISEL-NEXT:    v_fma_f32 v7, v0, v5, v7
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v1, v7
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, s0
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], |v0|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[0:1]
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s5, v2
@@ -1743,18 +1831,22 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v9, 1.0, v3, vcc
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v9, s6, v9
 ; GFX900-GISEL-NEXT:    v_log_f32_e32 v9, v9
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v8
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v8, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v1|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, v8, s[2:3]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v8, 0, v7, s[0:1]
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v1, v1, v8
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v8, 0x3e9a209a, v9
-; GFX900-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v10, v9, v4, -v8
-; GFX900-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v10, v9, v5, v10
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v8, v8, v10
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s0, v8
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v8, s0
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[0:1], s7, v2
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, v3, s[0:1]
+; GFX900-GISEL-NEXT:    v_mul_f32_e32 v2, s7, v2
+; GFX900-GISEL-NEXT:    v_log_f32_e32 v3, v2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[2:3], |v9|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v2, v9, v8, s[2:3]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v8, 0, v7, vcc
@@ -1763,6 +1855,8 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; GFX900-GISEL-NEXT:    v_fma_f32 v4, v3, v4, -v8
 ; GFX900-GISEL-NEXT:    v_fma_f32 v4, v3, v5, v4
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v4, v8, v4
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s2, v4
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v4, s2
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v3|, v6
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v3, v3, v4, vcc
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, v7, s[0:1]
@@ -1848,47 +1942,52 @@ define amdgpu_kernel void @s_log10_v4f32(ptr addrspace(1) %out, <4 x float> %in)
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, 1.0, 0x4f800000, s8
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, 1.0, 0x4f800000, s9
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v4, 0, 0x411a209b, s2
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v8, 0, 0x411a209b, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v0, s4, v0 :: v_dual_mul_f32 v1, s5, v1
 ; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v2, s6, v2 :: v_dual_mul_f32 v3, s7, v3
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v9, 0, 0x411a209b, s3
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v13, 0, 0x411a209b, s3
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v1, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(TRANS32_DEP_3)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(TRANS32_DEP_3)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v2, v2
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v3, v3
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v14, 0, 0x411a209b, s8
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v15, 0, 0x411a209b, s9
-; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v5, 0x3e9a209a, v0 :: v_dual_mul_f32 v6, 0x3e9a209a, v1
+; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v4, 0x3e9a209a, v0 :: v_dual_mul_f32 v5, 0x3e9a209a, v1
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
-; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v7, 0x3e9a209a, v2 :: v_dual_mul_f32 v8, 0x3e9a209a, v3
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
-; GFX1100-GISEL-NEXT:    v_fma_f32 v10, 0x3e9a209a, v0, -v5
-; GFX1100-GISEL-NEXT:    v_fma_f32 v11, 0x3e9a209a, v1, -v6
+; GFX1100-GISEL-NEXT:    v_dual_mul_f32 v6, 0x3e9a209a, v2 :: v_dual_mul_f32 v7, 0x3e9a209a, v3
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s6, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_fma_f32 v9, 0x3e9a209a, v0, -v4
+; GFX1100-GISEL-NEXT:    v_fma_f32 v10, 0x3e9a209a, v1, -v5
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
-; GFX1100-GISEL-NEXT:    v_fma_f32 v12, 0x3e9a209a, v2, -v7
-; GFX1100-GISEL-NEXT:    v_fma_f32 v13, 0x3e9a209a, v3, -v8
-; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v10, 0x3284fbcf, v0 :: v_dual_fmac_f32 v11, 0x3284fbcf, v1
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v12, 0x3284fbcf, v2 :: v_dual_fmac_f32 v13, 0x3284fbcf, v3
-; GFX1100-GISEL-NEXT:    v_dual_add_f32 v5, v5, v10 :: v_dual_add_f32 v6, v6, v11
+; GFX1100-GISEL-NEXT:    v_fma_f32 v11, 0x3e9a209a, v2, -v6
+; GFX1100-GISEL-NEXT:    v_fma_f32 v12, 0x3e9a209a, v3, -v7
+; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v9, 0x3284fbcf, v0 :: v_dual_fmac_f32 v10, 0x3284fbcf, v1
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_dual_add_f32 v7, v7, v12 :: v_dual_add_f32 v8, v8, v13
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v5, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v1|
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v1, v1, v6, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v2|
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v4
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_2)
-; GFX1100-GISEL-NEXT:    v_dual_mov_b32 v4, 0 :: v_dual_sub_f32 v1, v1, v9
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v2, v2, v7, vcc_lo
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v3|
-; GFX1100-GISEL-NEXT:    v_dual_cndmask_b32 v3, v3, v8 :: v_dual_sub_f32 v2, v2, v14
+; GFX1100-GISEL-NEXT:    v_dual_fmac_f32 v11, 0x3284fbcf, v2 :: v_dual_fmac_f32 v12, 0x3284fbcf, v3
+; GFX1100-GISEL-NEXT:    v_dual_add_f32 v4, v4, v9 :: v_dual_add_f32 v5, v5, v10
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
+; GFX1100-GISEL-NEXT:    v_dual_add_f32 v6, v6, v11 :: v_dual_add_f32 v7, v7, v12
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v9, 0, 0x411a209b, s9
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s2, v4
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s3, v5
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s4, v6
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s5, v7
+; GFX1100-GISEL-NEXT:    v_mov_b32_e32 v4, 0
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s2, s6
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v1|
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, s3, s2
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v2|
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v0, v0, v8 :: v_dual_sub_f32 v1, v1, v13
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, s4, s2
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s2, 0x7f800000, |v3|
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v3, v3, s5, s2
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
-; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v3, v3, v15
+; GFX1100-GISEL-NEXT:    v_dual_sub_f32 v2, v2, v14 :: v_dual_sub_f32 v3, v3, v9
 ; GFX1100-GISEL-NEXT:    global_store_b128 v4, v[0:3], s[0:1]
 ; GFX1100-GISEL-NEXT:    s_nop 0
 ; GFX1100-GISEL-NEXT:    s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
@@ -5577,10 +5676,12 @@ define float @v_log10_f32_undef() {
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v2
 ; SI-GISEL-NEXT:    v_fma_f32 v1, v0, v3, v1
 ; SI-GISEL-NEXT:    v_add_f32_e32 v1, v2, v1
-; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v2
-; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[4:5]
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; SI-GISEL-NEXT:    v_mov_b32_e32 v2, s4
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v1
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x411a209b
+; SI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[4:5]
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; SI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]
@@ -5617,14 +5718,18 @@ define float @v_log10_f32_undef() {
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x369a84fb, v1
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x369a84fb, v2
 ; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3e9a2000, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s4, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3e9a2000, v1
-; VI-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v2
-; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[4:5]
+; VI-GISEL-NEXT:    v_add_f32_e32 v1, s4, v1
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s4
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v1
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x411a209b
+; VI-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[4:5]
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]
@@ -5659,10 +5764,12 @@ define float @v_log10_f32_undef() {
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v1, -v2
 ; GFX900-GISEL-NEXT:    v_fma_f32 v1, v0, v3, v1
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v1, v2, v1
-; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v2
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s[4:5]
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v1
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7f800000
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, s4
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 s[4:5], |v0|, v1
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v1, 0x411a209b
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v2, s[4:5]
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v1, vcc
 ; GFX900-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; GFX900-GISEL-NEXT:    s_setpc_b64 s[30:31]
@@ -5692,15 +5799,16 @@ define float @v_log10_f32_undef() {
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, v0
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3e9a209a, v0
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s0, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s1, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v2, 0x3e9a209a, v0, -v1
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v2, 0x3284fbcf, v0
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, v1, s0
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, 0x411a209b, vcc_lo
-; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s0, s1
 ; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1
 ; GFX1100-GISEL-NEXT:    s_setpc_b64 s[30:31]
 ;
@@ -5744,10 +5852,12 @@ define float @v_log10_f32_0() {
 ; SI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a209a, v0
 ; SI-GISEL-NEXT:    v_fma_f32 v2, v0, v2, -v4
 ; SI-GISEL-NEXT:    v_fma_f32 v2, v0, v3, v2
-; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
 ; SI-GISEL-NEXT:    v_add_f32_e32 v2, v4, v2
-; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v3
-; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
+; SI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
+; SI-GISEL-NEXT:    v_mov_b32_e32 v3, s4
+; SI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v2
+; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc
 ; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x411a209b
 ; SI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, 0, v1
 ; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
@@ -5782,14 +5892,18 @@ define float @v_log10_f32_0() {
 ; VI-GISEL-NEXT:    v_sub_f32_e32 v3, v0, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 0x369a84fb, v2
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v5, 0x369a84fb, v3
-; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3e9a2000, v3
 ; VI-GISEL-NEXT:    v_add_f32_e32 v4, v4, v5
-; VI-GISEL-NEXT:    v_add_f32_e32 v3, v3, v4
+; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 0x3e9a2000, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v4
+; VI-GISEL-NEXT:    v_add_f32_e32 v3, s4, v3
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v3
 ; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 0x3e9a2000, v2
-; VI-GISEL-NEXT:    v_add_f32_e32 v2, v2, v3
-; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
-; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v3
-; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
+; VI-GISEL-NEXT:    v_add_f32_e32 v2, s4, v2
+; VI-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
+; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s4
+; VI-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v2
+; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc
 ; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x411a209b
 ; VI-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, 0, v1
 ; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
@@ -5822,10 +5936,12 @@ define float @v_log10_f32_0() {
 ; GFX900-GISEL-NEXT:    v_mul_f32_e32 v4, 0x3e9a209a, v0
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, v0, v2, -v4
 ; GFX900-GISEL-NEXT:    v_fma_f32 v2, v0, v3, v2
-; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7f800000
 ; GFX900-GISEL-NEXT:    v_add_f32_e32 v2, v4, v2
-; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v3
-; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v2, vcc
+; GFX900-GISEL-NEXT:    v_readfirstlane_b32 s4, v2
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7f800000
+; GFX900-GISEL-NEXT:    v_mov_b32_e32 v3, s4
+; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e64 vcc, |v0|, v2
+; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v3, vcc
 ; GFX900-GISEL-NEXT:    v_mov_b32_e32 v2, 0x411a209b
 ; GFX900-GISEL-NEXT:    v_cmp_lt_f32_e32 vcc, 0, v1
 ; GFX900-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0, v2, vcc
@@ -5853,16 +5969,18 @@ define float @v_log10_f32_0() {
 ; GFX1100-GISEL:       ; %bb.0:
 ; GFX1100-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; GFX1100-GISEL-NEXT:    v_log_f32_e32 v0, 0
-; GFX1100-GISEL-NEXT:    v_cmp_lt_f32_e64 s0, 0, 0x800000
 ; GFX1100-GISEL-NEXT:    s_waitcnt_depctr 0xfff
 ; GFX1100-GISEL-NEXT:    v_mul_f32_e32 v1, 0x3e9a209a, v0
-; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 vcc_lo, 0x7f800000, |v0|
+; GFX1100-GISEL-NEXT:    v_cmp_gt_f32_e64 s1, 0x7f800000, |v0|
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_fma_f32 v2, 0x3e9a209a, v0, -v1
 ; GFX1100-GISEL-NEXT:    v_fmac_f32_e32 v2, 0x3284fbcf, v0
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_add_f32_e32 v1, v1, v2
-; GFX1100-GISEL-NEXT:    v_cndmask_b32_e32 v0, v0, v1, vcc_lo
+; GFX1100-GISEL-NEXT:    v_readfirstlane_b32 s0, v1
+; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
+; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v0, v0, s0, s1
+; GFX1100-GISEL-NEXT:    v_cmp_lt_f32_e64 s0, 0, 0x800000
 ; GFX1100-GISEL-NEXT:    v_cndmask_b32_e64 v1, 0, 0x411a209b, s0
 ; GFX1100-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)
 ; GFX1100-GISEL-NEXT:    v_sub_f32_e32 v0, v0, v1



More information about the llvm-commits mailing list