[llvm-branch-commits] [llvm] [GlobalISel] Fixup commuted combine matching (PR #236954)

Alan Li via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 29 16:50:21 PDT 2026


https://github.com/lialan updated https://github.com/llvm/llvm-project/pull/236954

>From 0e4ca00830fdeaa7e789d919abc03b680b275d77 Mon Sep 17 00:00:00 2001
From: Alan Li <me at alanli.org>
Date: Thu, 29 Oct 2026 16:23:49 -0700
Subject: [PATCH] [GlobalISel] Fixup commuted combine matching

Match the subtraction on either side of (A-C1)+C2. Check constants and
use counts through the matched operands.

Look through single-use copies when unmerging constants to avoid extra
AMDGPU materializations. Preserve shared constants and copies, physical
register copies, and constant-fold barriers.

Cover commuted subtraction and copied constants in MIR tests, and update
affected AMDGPU assembly checks.
---
 .../lib/CodeGen/GlobalISel/CombinerHelper.cpp |  27 +++-
 .../GlobalISel/combine-integer-commuted.mir   |  23 +++
 llvm/test/CodeGen/AMDGPU/GlobalISel/and.ll    |  30 ++--
 llvm/test/CodeGen/AMDGPU/GlobalISel/andn2.ll  |  30 ++--
 .../AMDGPU/GlobalISel/cvt_f32_ubyte.ll        |  56 ++++---
 llvm/test/CodeGen/AMDGPU/GlobalISel/lshr.ll   |  15 +-
 llvm/test/CodeGen/AMDGPU/GlobalISel/orn2.ll   |  30 ++--
 .../regbankcombiner-unmerge-constant.mir      | 142 ++++++++++++++++++
 llvm/test/CodeGen/AMDGPU/GlobalISel/xnor.ll   |  89 ++++++-----
 llvm/test/CodeGen/AMDGPU/GlobalISel/xor.ll    |  32 ++--
 llvm/test/CodeGen/AMDGPU/bfi_int.ll           |  74 +++------
 llvm/test/CodeGen/AMDGPU/div_i128.ll          |  76 +++++-----
 llvm/test/CodeGen/AMDGPU/div_v2i128.ll        |   8 -
 llvm/test/CodeGen/AMDGPU/fptoi.i128.ll        | 127 ++++++++--------
 .../AMDGPU/isel-whole-wave-functions.ll       |  20 +--
 llvm/test/CodeGen/AMDGPU/itofp.i128.bf.ll     |   2 -
 llvm/test/CodeGen/AMDGPU/itofp.i128.ll        |   6 -
 llvm/test/CodeGen/AMDGPU/lround.ll            |  10 +-
 .../AMDGPU/memset-param-combinations.ll       |  24 +--
 llvm/test/CodeGen/AMDGPU/memset-pattern.ll    |  18 +--
 20 files changed, 463 insertions(+), 376 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/GlobalISel/regbankcombiner-unmerge-constant.mir

diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index c4b74aba87b875..451984a814187d 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -2387,6 +2387,13 @@ bool CombinerHelper::matchCombineUnmergeConstant(
     MachineInstr &MI, SmallVectorImpl<APInt> &Csts) const {
   unsigned SrcIdx = MI.getNumOperands() - 1;
   Register SrcReg = MI.getOperand(SrcIdx).getReg();
+  // Look through single-use copies without duplicating shared materializations.
+  Register CopySrc;
+  while (mi_match(SrcReg, MRI,
+                  m_OneNonDBGUse(m_Copy(m_OneNonDBGUse(m_Reg(CopySrc))))) &&
+         MRI.getType(CopySrc).isValid())
+    SrcReg = CopySrc;
+
   // Break down the big constant in smaller ones.
   APInt Val;
   if (!mi_match(SrcReg, MRI, m_GConstantOrFConstantBits(Val)))
@@ -8137,21 +8144,29 @@ bool CombinerHelper::matchFoldAMinusC1PlusC2(const MachineInstr &MI,
                                              BuildFnTy &MatchInfo) const {
   // fold ((A-C1)+C2) -> (A+(C2-C1))
   const GAdd *Add = cast<GAdd>(&MI);
+  // G_ADD is commutative, so the G_SUB can be either operand.
+  Register SubReg = Add->getLHSReg();
+  Register C2Reg = Add->getRHSReg();
   Register A, C1Reg;
-  if (!mi_match(Add->getLHSReg(), MRI, m_GSub(m_Reg(A), m_Reg(C1Reg))))
-    return false;
+  if (!mi_match(SubReg, MRI, m_GSub(m_Reg(A), m_Reg(C1Reg)))) {
+    std::swap(SubReg, C2Reg);
+    if (!mi_match(SubReg, MRI, m_GSub(m_Reg(A), m_Reg(C1Reg))))
+      return false;
+  }
 
-  if (!MRI.hasOneNonDBGUse(Add->getLHSReg()))
+  if (!MRI.hasOneNonDBGUse(SubReg))
     return false;
 
-  APInt C2 = getIConstantFromReg(Add->getRHSReg(), MRI);
-  APInt C1 = getIConstantFromReg(C1Reg, MRI);
+  std::optional<APInt> C2 = getIConstantVRegVal(C2Reg, MRI);
+  std::optional<APInt> C1 = getIConstantVRegVal(C1Reg, MRI);
+  if (!C1 || !C2)
+    return false;
 
   Register Dst = Add->getReg(0);
   LLT DstTy = MRI.getType(Dst);
 
   MatchInfo = [=](MachineIRBuilder &B) {
-    auto Const = B.buildConstant(DstTy, C2 - C1);
+    auto Const = B.buildConstant(DstTy, *C2 - *C1);
     B.buildAdd(Dst, A, Const);
   };
 
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/combine-integer-commuted.mir b/llvm/test/CodeGen/AArch64/GlobalISel/combine-integer-commuted.mir
index 65235212c21d5a..837f46559f0352 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/combine-integer-commuted.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/combine-integer-commuted.mir
@@ -52,3 +52,26 @@ body:             |
     RET_ReallyLR implicit $x0
 
 ...
+---
+name:   AMinusC2PlusC2_commuted
+body:             |
+  bb.0:
+    liveins: $w0, $w1
+
+    ; CHECK-LABEL: name: AMinusC2PlusC2_commuted
+    ; CHECK: liveins: $w0, $w1
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: %a:_(i64) = COPY $x0
+    ; CHECK-NEXT: [[C:%[0-9]+]]:_(i64) = G_CONSTANT i64 43
+    ; CHECK-NEXT: %add:_(i64) = G_ADD %a, [[C]]
+    ; CHECK-NEXT: $x0 = COPY %add(i64)
+    ; CHECK-NEXT: RET_ReallyLR implicit $x0
+    %a:_(i64) = COPY $x0
+    %c1:_(i64) = G_CONSTANT i64 13
+    %c2:_(i64) = G_CONSTANT i64 56
+    %sub:_(i64) = G_SUB %a, %c1
+    %add:_(i64) = G_ADD %c2, %sub
+    $x0 = COPY %add
+    RET_ReallyLR implicit $x0
+
+...
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/and.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/and.ll
index ddc1f68e8fbe01..06daa7237c8f5f 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/and.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/and.ll
@@ -687,59 +687,53 @@ define amdgpu_ps void @s_and_u64_sext_with_vregs(ptr addrspace(1) %out, ptr addr
 ; GFX7-NEXT:    s_mov_b32 s2, 0
 ; GFX7-NEXT:    s_mov_b32 s3, 0xf000
 ; GFX7-NEXT:    s_mov_b64 s[0:1], 0
-; GFX7-NEXT:    buffer_load_dword v4, v[2:3], s[0:3], 0 addr64
-; GFX7-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX7-NEXT:    buffer_load_dword v2, v[2:3], s[0:3], 0 addr64
 ; GFX7-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
-; GFX7-NEXT:    v_and_b32_e32 v2, 0x50, v4
+; GFX7-NEXT:    v_and_b32_e32 v2, 0x50, v2
 ; GFX7-NEXT:    buffer_store_dwordx2 v[2:3], v[0:1], s[0:3], 0 addr64
 ; GFX7-NEXT:    s_endpgm
 ;
 ; GFX8-LABEL: s_and_u64_sext_with_vregs:
 ; GFX8:       ; %bb.0:
-; GFX8-NEXT:    flat_load_dword v4, v[2:3]
-; GFX8-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX8-NEXT:    flat_load_dword v2, v[2:3]
 ; GFX8-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX8-NEXT:    s_waitcnt vmcnt(0)
-; GFX8-NEXT:    v_and_b32_e32 v2, 0x50, v4
+; GFX8-NEXT:    v_and_b32_e32 v2, 0x50, v2
 ; GFX8-NEXT:    flat_store_dwordx2 v[0:1], v[2:3]
 ; GFX8-NEXT:    s_endpgm
 ;
 ; GFX9-LABEL: s_and_u64_sext_with_vregs:
 ; GFX9:       ; %bb.0:
-; GFX9-NEXT:    global_load_dword v4, v[2:3], off
-; GFX9-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX9-NEXT:    global_load_dword v2, v[2:3], off
 ; GFX9-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX9-NEXT:    s_waitcnt vmcnt(0)
-; GFX9-NEXT:    v_and_b32_e32 v2, 0x50, v4
+; GFX9-NEXT:    v_and_b32_e32 v2, 0x50, v2
 ; GFX9-NEXT:    global_store_dwordx2 v[0:1], v[2:3], off
 ; GFX9-NEXT:    s_endpgm
 ;
 ; GFX10-LABEL: s_and_u64_sext_with_vregs:
 ; GFX10:       ; %bb.0:
-; GFX10-NEXT:    global_load_dword v4, v[2:3], off
-; GFX10-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX10-NEXT:    global_load_dword v2, v[2:3], off
 ; GFX10-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX10-NEXT:    s_waitcnt vmcnt(0)
-; GFX10-NEXT:    v_and_b32_e32 v2, 0x50, v4
+; GFX10-NEXT:    v_and_b32_e32 v2, 0x50, v2
 ; GFX10-NEXT:    global_store_dwordx2 v[0:1], v[2:3], off
 ; GFX10-NEXT:    s_endpgm
 ;
 ; GFX11-LABEL: s_and_u64_sext_with_vregs:
 ; GFX11:       ; %bb.0:
-; GFX11-NEXT:    global_load_b32 v4, v[2:3], off
-; GFX11-NEXT:    v_dual_mov_b32 v2, 0x50 :: v_dual_mov_b32 v3, 0
+; GFX11-NEXT:    global_load_b32 v2, v[2:3], off
 ; GFX11-NEXT:    s_waitcnt vmcnt(0)
-; GFX11-NEXT:    v_and_b32_e32 v2, 0x50, v4
+; GFX11-NEXT:    v_dual_mov_b32 v3, 0 :: v_dual_and_b32 v2, 0x50, v2
 ; GFX11-NEXT:    global_store_b64 v[0:1], v[2:3], off
 ; GFX11-NEXT:    s_endpgm
 ;
 ; GFX12-LABEL: s_and_u64_sext_with_vregs:
 ; GFX12:       ; %bb.0:
-; GFX12-NEXT:    global_load_b32 v4, v[2:3], off
-; GFX12-NEXT:    v_dual_mov_b32 v2, 0x50 :: v_dual_mov_b32 v3, 0
+; GFX12-NEXT:    global_load_b32 v2, v[2:3], off
 ; GFX12-NEXT:    s_wait_loadcnt 0x0
-; GFX12-NEXT:    v_and_b32_e32 v2, 0x50, v4
+; GFX12-NEXT:    v_dual_mov_b32 v3, 0 :: v_dual_and_b32 v2, 0x50, v2
 ; GFX12-NEXT:    global_store_b64 v[0:1], v[2:3], off
 ; GFX12-NEXT:    s_endpgm
   %val = load i32, ptr addrspace(1) %in, align 4
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/andn2.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/andn2.ll
index 29556381293419..c21e643cdf733e 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/andn2.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/andn2.ll
@@ -256,19 +256,15 @@ define i64 @v_andn2_i64(i64 %src0, i64 %src1) {
 ; GCN-LABEL: v_andn2_i64:
 ; GCN:       ; %bb.0:
 ; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GCN-NEXT:    v_xor_b32_e32 v2, -1, v2
-; GCN-NEXT:    v_xor_b32_e32 v3, -1, v3
-; GCN-NEXT:    v_and_b32_e32 v0, v0, v2
-; GCN-NEXT:    v_and_b32_e32 v1, v1, v3
+; GCN-NEXT:    v_bfi_b32 v0, v2, 0, v0
+; GCN-NEXT:    v_bfi_b32 v1, v3, 0, v1
 ; GCN-NEXT:    s_setpc_b64 s[30:31]
 ;
 ; GFX10PLUS-LABEL: v_andn2_i64:
 ; GFX10PLUS:       ; %bb.0:
 ; GFX10PLUS-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX10PLUS-NEXT:    v_xor_b32_e32 v2, -1, v2
-; GFX10PLUS-NEXT:    v_xor_b32_e32 v3, -1, v3
-; GFX10PLUS-NEXT:    v_and_b32_e32 v0, v0, v2
-; GFX10PLUS-NEXT:    v_and_b32_e32 v1, v1, v3
+; GFX10PLUS-NEXT:    v_bfi_b32 v0, v2, 0, v0
+; GFX10PLUS-NEXT:    v_bfi_b32 v1, v3, 0, v1
 ; GFX10PLUS-NEXT:    s_setpc_b64 s[30:31]
   %not.src1 = xor i64 %src1, -1
   %and = and i64 %src0, %not.src1
@@ -278,26 +274,20 @@ define i64 @v_andn2_i64(i64 %src0, i64 %src1) {
 define amdgpu_ps <2 x float> @v_andn2_i64_sv(i64 inreg %src0, i64 %src1) {
 ; GCN-LABEL: v_andn2_i64_sv:
 ; GCN:       ; %bb.0:
-; GCN-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GCN-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GCN-NEXT:    v_and_b32_e32 v0, s2, v0
-; GCN-NEXT:    v_and_b32_e32 v1, s3, v1
+; GCN-NEXT:    v_bfi_b32 v0, v0, 0, s2
+; GCN-NEXT:    v_bfi_b32 v1, v1, 0, s3
 ; GCN-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-LABEL: v_andn2_i64_sv:
 ; GFX10:       ; %bb.0:
-; GFX10-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX10-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX10-NEXT:    v_and_b32_e32 v0, s2, v0
-; GFX10-NEXT:    v_and_b32_e32 v1, s3, v1
+; GFX10-NEXT:    v_bfi_b32 v0, v0, 0, s2
+; GFX10-NEXT:    v_bfi_b32 v1, v1, 0, s3
 ; GFX10-NEXT:    ; return to shader part epilog
 ;
 ; GFX11-LABEL: v_andn2_i64_sv:
 ; GFX11:       ; %bb.0:
-; GFX11-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX11-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX11-NEXT:    v_and_b32_e32 v0, s0, v0
-; GFX11-NEXT:    v_and_b32_e32 v1, s1, v1
+; GFX11-NEXT:    v_bfi_b32 v0, v0, 0, s0
+; GFX11-NEXT:    v_bfi_b32 v1, v1, 0, s1
 ; GFX11-NEXT:    ; return to shader part epilog
   %not.src1 = xor i64 %src1, -1
   %and = and i64 %src0, %not.src1
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/cvt_f32_ubyte.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/cvt_f32_ubyte.ll
index 2b6aa12470f5c0..9a796c820506dd 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/cvt_f32_ubyte.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/cvt_f32_ubyte.ll
@@ -1432,34 +1432,32 @@ define float @v_test_sitofp_i64_byte_to_f32(i64 %arg0) {
 ; SI-LABEL: v_test_sitofp_i64_byte_to_f32:
 ; SI:       ; %bb.0:
 ; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; SI-NEXT:    v_mov_b32_e32 v1, 0xff
-; SI-NEXT:    v_and_b32_e32 v1, 0xff, v0
-; SI-NEXT:    v_ffbh_i32_e32 v0, 0
-; SI-NEXT:    v_add_i32_e32 v0, vcc, -1, v0
-; SI-NEXT:    v_mov_b32_e32 v2, 0
-; SI-NEXT:    v_min_u32_e32 v3, 32, v0
-; SI-NEXT:    v_lshl_b64 v[0:1], v[1:2], v3
+; SI-NEXT:    v_ffbh_i32_e32 v2, 0
+; SI-NEXT:    v_add_i32_e32 v2, vcc, -1, v2
+; SI-NEXT:    v_mov_b32_e32 v1, 0
+; SI-NEXT:    v_and_b32_e32 v0, 0xff, v0
+; SI-NEXT:    v_min_u32_e32 v2, 32, v2
+; SI-NEXT:    v_lshl_b64 v[0:1], v[0:1], v2
 ; SI-NEXT:    v_min_u32_e32 v0, 1, v0
 ; SI-NEXT:    v_or_b32_e32 v0, v1, v0
 ; SI-NEXT:    v_cvt_f32_i32_e32 v0, v0
-; SI-NEXT:    v_sub_i32_e32 v1, vcc, 32, v3
+; SI-NEXT:    v_sub_i32_e32 v1, vcc, 32, v2
 ; SI-NEXT:    v_ldexp_f32_e32 v0, v0, v1
 ; SI-NEXT:    s_setpc_b64 s[30:31]
 ;
 ; VI-LABEL: v_test_sitofp_i64_byte_to_f32:
 ; VI:       ; %bb.0:
 ; VI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; VI-NEXT:    v_mov_b32_e32 v1, 0xff
-; VI-NEXT:    v_and_b32_e32 v1, 0xff, v0
-; VI-NEXT:    v_ffbh_i32_e32 v0, 0
-; VI-NEXT:    v_add_u32_e32 v0, vcc, -1, v0
-; VI-NEXT:    v_mov_b32_e32 v2, 0
-; VI-NEXT:    v_min_u32_e32 v3, 32, v0
-; VI-NEXT:    v_lshlrev_b64 v[0:1], v3, v[1:2]
+; VI-NEXT:    v_ffbh_i32_e32 v2, 0
+; VI-NEXT:    v_add_u32_e32 v2, vcc, -1, v2
+; VI-NEXT:    v_mov_b32_e32 v1, 0
+; VI-NEXT:    v_and_b32_e32 v0, 0xff, v0
+; VI-NEXT:    v_min_u32_e32 v2, 32, v2
+; VI-NEXT:    v_lshlrev_b64 v[0:1], v2, v[0:1]
 ; VI-NEXT:    v_min_u32_e32 v0, 1, v0
 ; VI-NEXT:    v_or_b32_e32 v0, v1, v0
 ; VI-NEXT:    v_cvt_f32_i32_e32 v0, v0
-; VI-NEXT:    v_sub_u32_e32 v1, vcc, 32, v3
+; VI-NEXT:    v_sub_u32_e32 v1, vcc, 32, v2
 ; VI-NEXT:    v_ldexp_f32 v0, v0, v1
 ; VI-NEXT:    s_setpc_b64 s[30:31]
   %masked = and i64 %arg0, 255
@@ -1471,32 +1469,30 @@ define float @v_test_uitofp_i64_byte_to_f32(i64 %arg0) {
 ; SI-LABEL: v_test_uitofp_i64_byte_to_f32:
 ; SI:       ; %bb.0:
 ; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; SI-NEXT:    v_mov_b32_e32 v1, 0xff
-; SI-NEXT:    v_and_b32_e32 v1, 0xff, v0
-; SI-NEXT:    v_ffbh_u32_e32 v0, 0
-; SI-NEXT:    v_mov_b32_e32 v2, 0
-; SI-NEXT:    v_min_u32_e32 v3, 32, v0
-; SI-NEXT:    v_lshl_b64 v[0:1], v[1:2], v3
+; SI-NEXT:    v_ffbh_u32_e32 v2, 0
+; SI-NEXT:    v_mov_b32_e32 v1, 0
+; SI-NEXT:    v_and_b32_e32 v0, 0xff, v0
+; SI-NEXT:    v_min_u32_e32 v2, 32, v2
+; SI-NEXT:    v_lshl_b64 v[0:1], v[0:1], v2
 ; SI-NEXT:    v_min_u32_e32 v0, 1, v0
 ; SI-NEXT:    v_or_b32_e32 v0, v1, v0
 ; SI-NEXT:    v_cvt_f32_u32_e32 v0, v0
-; SI-NEXT:    v_sub_i32_e32 v1, vcc, 32, v3
+; SI-NEXT:    v_sub_i32_e32 v1, vcc, 32, v2
 ; SI-NEXT:    v_ldexp_f32_e32 v0, v0, v1
 ; SI-NEXT:    s_setpc_b64 s[30:31]
 ;
 ; VI-LABEL: v_test_uitofp_i64_byte_to_f32:
 ; VI:       ; %bb.0:
 ; VI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; VI-NEXT:    v_mov_b32_e32 v1, 0xff
-; VI-NEXT:    v_and_b32_e32 v1, 0xff, v0
-; VI-NEXT:    v_ffbh_u32_e32 v0, 0
-; VI-NEXT:    v_mov_b32_e32 v2, 0
-; VI-NEXT:    v_min_u32_e32 v3, 32, v0
-; VI-NEXT:    v_lshlrev_b64 v[0:1], v3, v[1:2]
+; VI-NEXT:    v_ffbh_u32_e32 v2, 0
+; VI-NEXT:    v_mov_b32_e32 v1, 0
+; VI-NEXT:    v_and_b32_e32 v0, 0xff, v0
+; VI-NEXT:    v_min_u32_e32 v2, 32, v2
+; VI-NEXT:    v_lshlrev_b64 v[0:1], v2, v[0:1]
 ; VI-NEXT:    v_min_u32_e32 v0, 1, v0
 ; VI-NEXT:    v_or_b32_e32 v0, v1, v0
 ; VI-NEXT:    v_cvt_f32_u32_e32 v0, v0
-; VI-NEXT:    v_sub_u32_e32 v1, vcc, 32, v3
+; VI-NEXT:    v_sub_u32_e32 v1, vcc, 32, v2
 ; VI-NEXT:    v_ldexp_f32 v0, v0, v1
 ; VI-NEXT:    s_setpc_b64 s[30:31]
   %masked = and i64 %arg0, 255
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/lshr.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/lshr.ll
index 4657695ddb6288..d4d5d340f2e6c1 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/lshr.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/lshr.ll
@@ -1688,7 +1688,6 @@ define i65 @v_lshr_i65(i65 %value, i65 %amount) {
 ; GFX6-LABEL: v_lshr_i65:
 ; GFX6:       ; %bb.0:
 ; GFX6-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX6-NEXT:    v_mov_b32_e32 v4, 1
 ; GFX6-NEXT:    v_mov_b32_e32 v5, 0
 ; GFX6-NEXT:    v_and_b32_e32 v4, 1, v2
 ; GFX6-NEXT:    v_sub_i32_e32 v8, vcc, 64, v3
@@ -1711,7 +1710,6 @@ define i65 @v_lshr_i65(i65 %value, i65 %amount) {
 ; GFX8-LABEL: v_lshr_i65:
 ; GFX8:       ; %bb.0:
 ; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX8-NEXT:    v_mov_b32_e32 v4, 1
 ; GFX8-NEXT:    v_mov_b32_e32 v5, 0
 ; GFX8-NEXT:    v_and_b32_e32 v4, 1, v2
 ; GFX8-NEXT:    v_sub_u32_e32 v8, vcc, 64, v3
@@ -1734,7 +1732,6 @@ define i65 @v_lshr_i65(i65 %value, i65 %amount) {
 ; GFX9-LABEL: v_lshr_i65:
 ; GFX9:       ; %bb.0:
 ; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX9-NEXT:    v_mov_b32_e32 v4, 1
 ; GFX9-NEXT:    v_mov_b32_e32 v5, 0
 ; GFX9-NEXT:    v_and_b32_e32 v4, 1, v2
 ; GFX9-NEXT:    v_sub_u32_e32 v8, 64, v3
@@ -1757,7 +1754,6 @@ define i65 @v_lshr_i65(i65 %value, i65 %amount) {
 ; GFX10-LABEL: v_lshr_i65:
 ; GFX10:       ; %bb.0:
 ; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX10-NEXT:    v_mov_b32_e32 v4, 1
 ; GFX10-NEXT:    v_mov_b32_e32 v5, 0
 ; GFX10-NEXT:    v_and_b32_e32 v4, 1, v2
 ; GFX10-NEXT:    v_sub_nc_u32_e32 v2, 64, v3
@@ -1780,8 +1776,7 @@ define i65 @v_lshr_i65(i65 %value, i65 %amount) {
 ; GFX11-LABEL: v_lshr_i65:
 ; GFX11:       ; %bb.0:
 ; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX11-NEXT:    v_dual_mov_b32 v4, 1 :: v_dual_mov_b32 v5, 0
-; GFX11-NEXT:    v_and_b32_e32 v4, 1, v2
+; GFX11-NEXT:    v_dual_mov_b32 v5, 0 :: v_dual_and_b32 v4, 1, v2
 ; GFX11-NEXT:    v_sub_nc_u32_e32 v2, 64, v3
 ; GFX11-NEXT:    v_lshrrev_b64 v[6:7], v3, v[0:1]
 ; GFX11-NEXT:    v_cmp_gt_u32_e32 vcc_lo, 64, v3
@@ -1806,7 +1801,6 @@ define i65 @v_lshr_i65_33(i65 %value) {
 ; GFX6-LABEL: v_lshr_i65_33:
 ; GFX6:       ; %bb.0:
 ; GFX6-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX6-NEXT:    v_mov_b32_e32 v0, 1
 ; GFX6-NEXT:    v_mov_b32_e32 v3, v1
 ; GFX6-NEXT:    v_mov_b32_e32 v1, 0
 ; GFX6-NEXT:    v_and_b32_e32 v0, 1, v2
@@ -1819,7 +1813,6 @@ define i65 @v_lshr_i65_33(i65 %value) {
 ; GFX8-LABEL: v_lshr_i65_33:
 ; GFX8:       ; %bb.0:
 ; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX8-NEXT:    v_mov_b32_e32 v0, 1
 ; GFX8-NEXT:    v_mov_b32_e32 v3, v1
 ; GFX8-NEXT:    v_mov_b32_e32 v1, 0
 ; GFX8-NEXT:    v_and_b32_e32 v0, 1, v2
@@ -1832,7 +1825,6 @@ define i65 @v_lshr_i65_33(i65 %value) {
 ; GFX9-LABEL: v_lshr_i65_33:
 ; GFX9:       ; %bb.0:
 ; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX9-NEXT:    v_mov_b32_e32 v0, 1
 ; GFX9-NEXT:    v_mov_b32_e32 v3, v1
 ; GFX9-NEXT:    v_mov_b32_e32 v1, 0
 ; GFX9-NEXT:    v_and_b32_e32 v0, 1, v2
@@ -1845,7 +1837,6 @@ define i65 @v_lshr_i65_33(i65 %value) {
 ; GFX10-LABEL: v_lshr_i65_33:
 ; GFX10:       ; %bb.0:
 ; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX10-NEXT:    v_mov_b32_e32 v0, 1
 ; GFX10-NEXT:    v_mov_b32_e32 v3, v1
 ; GFX10-NEXT:    v_mov_b32_e32 v1, 0
 ; GFX10-NEXT:    v_and_b32_e32 v0, 1, v2
@@ -1858,8 +1849,8 @@ define i65 @v_lshr_i65_33(i65 %value) {
 ; GFX11-LABEL: v_lshr_i65_33:
 ; GFX11:       ; %bb.0:
 ; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX11-NEXT:    v_dual_mov_b32 v3, v1 :: v_dual_mov_b32 v0, 1
-; GFX11-NEXT:    v_dual_mov_b32 v1, 0 :: v_dual_and_b32 v0, 1, v2
+; GFX11-NEXT:    v_dual_mov_b32 v3, v1 :: v_dual_and_b32 v0, 1, v2
+; GFX11-NEXT:    v_mov_b32_e32 v1, 0
 ; GFX11-NEXT:    v_lshrrev_b32_e32 v2, 1, v3
 ; GFX11-NEXT:    v_lshlrev_b64 v[0:1], 31, v[0:1]
 ; GFX11-NEXT:    v_or_b32_e32 v0, v0, v2
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/orn2.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/orn2.ll
index 5aa9ea8cacdcf0..b02a91ae5e10ca 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/orn2.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/orn2.ll
@@ -256,19 +256,15 @@ define i64 @v_orn2_i64(i64 %src0, i64 %src1) {
 ; GCN-LABEL: v_orn2_i64:
 ; GCN:       ; %bb.0:
 ; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GCN-NEXT:    v_xor_b32_e32 v2, -1, v2
-; GCN-NEXT:    v_xor_b32_e32 v3, -1, v3
-; GCN-NEXT:    v_or_b32_e32 v0, v0, v2
-; GCN-NEXT:    v_or_b32_e32 v1, v1, v3
+; GCN-NEXT:    v_bfi_b32 v0, v2, v0, -1
+; GCN-NEXT:    v_bfi_b32 v1, v3, v1, -1
 ; GCN-NEXT:    s_setpc_b64 s[30:31]
 ;
 ; GFX10PLUS-LABEL: v_orn2_i64:
 ; GFX10PLUS:       ; %bb.0:
 ; GFX10PLUS-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX10PLUS-NEXT:    v_xor_b32_e32 v2, -1, v2
-; GFX10PLUS-NEXT:    v_xor_b32_e32 v3, -1, v3
-; GFX10PLUS-NEXT:    v_or_b32_e32 v0, v0, v2
-; GFX10PLUS-NEXT:    v_or_b32_e32 v1, v1, v3
+; GFX10PLUS-NEXT:    v_bfi_b32 v0, v2, v0, -1
+; GFX10PLUS-NEXT:    v_bfi_b32 v1, v3, v1, -1
 ; GFX10PLUS-NEXT:    s_setpc_b64 s[30:31]
   %not.src1 = xor i64 %src1, -1
   %or = or i64 %src0, %not.src1
@@ -278,26 +274,20 @@ define i64 @v_orn2_i64(i64 %src0, i64 %src1) {
 define amdgpu_ps <2 x float> @v_orn2_i64_sv(i64 inreg %src0, i64 %src1) {
 ; GCN-LABEL: v_orn2_i64_sv:
 ; GCN:       ; %bb.0:
-; GCN-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GCN-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GCN-NEXT:    v_or_b32_e32 v0, s2, v0
-; GCN-NEXT:    v_or_b32_e32 v1, s3, v1
+; GCN-NEXT:    v_bfi_b32 v0, v0, s2, -1
+; GCN-NEXT:    v_bfi_b32 v1, v1, s3, -1
 ; GCN-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-LABEL: v_orn2_i64_sv:
 ; GFX10:       ; %bb.0:
-; GFX10-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX10-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX10-NEXT:    v_or_b32_e32 v0, s2, v0
-; GFX10-NEXT:    v_or_b32_e32 v1, s3, v1
+; GFX10-NEXT:    v_bfi_b32 v0, v0, s2, -1
+; GFX10-NEXT:    v_bfi_b32 v1, v1, s3, -1
 ; GFX10-NEXT:    ; return to shader part epilog
 ;
 ; GFX11-LABEL: v_orn2_i64_sv:
 ; GFX11:       ; %bb.0:
-; GFX11-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX11-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX11-NEXT:    v_or_b32_e32 v0, s0, v0
-; GFX11-NEXT:    v_or_b32_e32 v1, s1, v1
+; GFX11-NEXT:    v_bfi_b32 v0, v0, s0, -1
+; GFX11-NEXT:    v_bfi_b32 v1, v1, s1, -1
 ; GFX11-NEXT:    ; return to shader part epilog
   %not.src1 = xor i64 %src1, -1
   %or = or i64 %src0, %not.src1
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankcombiner-unmerge-constant.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankcombiner-unmerge-constant.mir
new file mode 100644
index 00000000000000..bd95b560e84bc9
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankcombiner-unmerge-constant.mir
@@ -0,0 +1,142 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
+# RUN: llc -mtriple=amdgpu9.00 -run-pass=amdgpu-regbank-combiner \
+# RUN:   -verify-machineinstrs %s -o - | FileCheck %s
+
+# Split constants through single-use bank copies, retaining the destination banks.
+# Shared constants and copies must not have their materializations duplicated.
+# Physical register copies and constant-fold barriers must not be folded.
+
+---
+name: integer_copy
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+    ; CHECK-LABEL: name: integer_copy
+    ; CHECK: %lo:vgpr(i32) = G_CONSTANT i32 80
+    ; CHECK-NEXT: %hi:vgpr(i32) = G_CONSTANT i32 0
+    ; CHECK-NEXT: $vgpr0 = COPY %lo(i32)
+    ; CHECK-NEXT: $vgpr1 = COPY %hi(i32)
+    ; CHECK-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+    %c:sgpr(i64) = G_CONSTANT i64 80
+    %copy0:sgpr(i64) = COPY %c
+    %copy:vgpr(i64) = COPY %copy0
+    %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    $vgpr0 = COPY %lo(i32)
+    $vgpr1 = COPY %hi(i32)
+    S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+...
+---
+name: float_copy
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+    ; CHECK-LABEL: name: float_copy
+    ; CHECK: %lo:vgpr(i32) = G_CONSTANT i32 0
+    ; CHECK-NEXT: %hi:vgpr(i32) = G_CONSTANT i32 1072693248
+    ; CHECK-NEXT: $vgpr0 = COPY %lo(i32)
+    ; CHECK-NEXT: $vgpr1 = COPY %hi(i32)
+    ; CHECK-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+    %c:sgpr(i64) = G_FCONSTANT double 1.000000e+00
+    %copy:vgpr(i64) = COPY %c
+    %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    $vgpr0 = COPY %lo(i32)
+    $vgpr1 = COPY %hi(i32)
+    S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+...
+---
+name: constant_fold_barrier
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+    ; CHECK-LABEL: name: constant_fold_barrier
+    ; CHECK: %constant:sgpr(i64) = G_CONSTANT i64 80
+    ; CHECK-NEXT: %c:sgpr(i64) = G_CONSTANT_FOLD_BARRIER %constant
+    ; CHECK-NEXT: %copy:vgpr(i64) = COPY %c(i64)
+    ; CHECK-NEXT: %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    ; CHECK-NEXT: $vgpr0 = COPY %lo(i32)
+    ; CHECK-NEXT: $vgpr1 = COPY %hi(i32)
+    ; CHECK-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+    %constant:sgpr(i64) = G_CONSTANT i64 80
+    %c:sgpr(i64) = G_CONSTANT_FOLD_BARRIER %constant
+    %copy:vgpr(i64) = COPY %c
+    %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    $vgpr0 = COPY %lo(i32)
+    $vgpr1 = COPY %hi(i32)
+    S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+...
+---
+name: physical_register_copy
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+    liveins: $sgpr0_sgpr1
+    ; CHECK-LABEL: name: physical_register_copy
+    ; CHECK: liveins: $sgpr0_sgpr1
+    ; CHECK-NEXT: {{  $}}
+    ; CHECK-NEXT: %c:sgpr(i64) = COPY $sgpr0_sgpr1
+    ; CHECK-NEXT: %copy:vgpr(i64) = COPY %c(i64)
+    ; CHECK-NEXT: %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    ; CHECK-NEXT: $vgpr0 = COPY %lo(i32)
+    ; CHECK-NEXT: $vgpr1 = COPY %hi(i32)
+    ; CHECK-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+    %c:sgpr(i64) = COPY $sgpr0_sgpr1
+    %copy:vgpr(i64) = COPY %c
+    %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    $vgpr0 = COPY %lo(i32)
+    $vgpr1 = COPY %hi(i32)
+    S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1
+...
+---
+name: shared_constant
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+    ; CHECK-LABEL: name: shared_constant
+    ; CHECK: %c:sgpr(i64) = G_CONSTANT i64 80
+    ; CHECK-NEXT: %copy:vgpr(i64) = COPY %c(i64)
+    ; CHECK-NEXT: %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    ; CHECK-NEXT: $vgpr0 = COPY %lo(i32)
+    ; CHECK-NEXT: $vgpr1 = COPY %hi(i32)
+    ; CHECK-NEXT: $sgpr0_sgpr1 = COPY %c(i64)
+    ; CHECK-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1, implicit $sgpr0_sgpr1
+    %c:sgpr(i64) = G_CONSTANT i64 80
+    %copy:vgpr(i64) = COPY %c
+    %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    $vgpr0 = COPY %lo(i32)
+    $vgpr1 = COPY %hi(i32)
+    $sgpr0_sgpr1 = COPY %c(i64)
+    S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1, implicit $sgpr0_sgpr1
+...
+---
+name: shared_copy
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+  bb.0:
+    ; CHECK-LABEL: name: shared_copy
+    ; CHECK: %c:sgpr(i64) = G_CONSTANT i64 80
+    ; CHECK-NEXT: %copy:vgpr(i64) = COPY %c(i64)
+    ; CHECK-NEXT: %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    ; CHECK-NEXT: $vgpr0 = COPY %lo(i32)
+    ; CHECK-NEXT: $vgpr1 = COPY %hi(i32)
+    ; CHECK-NEXT: $vgpr2_vgpr3 = COPY %copy(i64)
+    ; CHECK-NEXT: S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1, implicit $vgpr2_vgpr3
+    %c:sgpr(i64) = G_CONSTANT i64 80
+    %copy:vgpr(i64) = COPY %c
+    %lo:vgpr(i32), %hi:vgpr(i32) = G_UNMERGE_VALUES %copy(i64)
+    $vgpr0 = COPY %lo(i32)
+    $vgpr1 = COPY %hi(i32)
+    $vgpr2_vgpr3 = COPY %copy(i64)
+    S_ENDPGM 0, implicit $vgpr0, implicit $vgpr1, implicit $vgpr2_vgpr3
+...
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/xnor.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/xnor.ll
index e1cf6b90bab223..e416fcb25103fa 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/xnor.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/xnor.ll
@@ -209,20 +209,45 @@ entry:
 }
 
 define i64 @vector_xnor_i64_one_use(i64 %a, i64 %b) {
-; GCN-LABEL: vector_xnor_i64_one_use:
-; GCN:       ; %bb.0: ; %entry
-; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GCN-NEXT:    v_xor_b32_e32 v0, v0, v2
-; GCN-NEXT:    v_xor_b32_e32 v1, v1, v3
-; GCN-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GCN-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GCN-NEXT:    s_setpc_b64 s[30:31]
+; GFX7-LABEL: vector_xnor_i64_one_use:
+; GFX7:       ; %bb.0: ; %entry
+; GFX7-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX7-NEXT:    v_xor_b32_e32 v0, v0, v2
+; GFX7-NEXT:    v_xor_b32_e32 v1, v1, v3
+; GFX7-NEXT:    v_not_b32_e32 v0, v0
+; GFX7-NEXT:    v_not_b32_e32 v1, v1
+; GFX7-NEXT:    s_setpc_b64 s[30:31]
+;
+; GFX8-LABEL: vector_xnor_i64_one_use:
+; GFX8:       ; %bb.0: ; %entry
+; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX8-NEXT:    v_xor_b32_e32 v0, v0, v2
+; GFX8-NEXT:    v_xor_b32_e32 v1, v1, v3
+; GFX8-NEXT:    v_not_b32_e32 v0, v0
+; GFX8-NEXT:    v_not_b32_e32 v1, v1
+; GFX8-NEXT:    s_setpc_b64 s[30:31]
+;
+; GFX900-LABEL: vector_xnor_i64_one_use:
+; GFX900:       ; %bb.0: ; %entry
+; GFX900-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX900-NEXT:    v_xor_b32_e32 v0, v0, v2
+; GFX900-NEXT:    v_xor_b32_e32 v1, v1, v3
+; GFX900-NEXT:    v_not_b32_e32 v0, v0
+; GFX900-NEXT:    v_not_b32_e32 v1, v1
+; GFX900-NEXT:    s_setpc_b64 s[30:31]
+;
+; GFX906-LABEL: vector_xnor_i64_one_use:
+; GFX906:       ; %bb.0: ; %entry
+; GFX906-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX906-NEXT:    v_xnor_b32_e32 v0, v0, v2
+; GFX906-NEXT:    v_xnor_b32_e32 v1, v1, v3
+; GFX906-NEXT:    s_setpc_b64 s[30:31]
 ;
 ; GFX10-LABEL: vector_xnor_i64_one_use:
 ; GFX10:       ; %bb.0: ; %entry
 ; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX10-NEXT:    v_xor3_b32 v0, v0, v2, -1
-; GFX10-NEXT:    v_xor3_b32 v1, v1, v3, -1
+; GFX10-NEXT:    v_xnor_b32_e32 v0, v0, v2
+; GFX10-NEXT:    v_xnor_b32_e32 v1, v1, v3
 ; GFX10-NEXT:    s_setpc_b64 s[30:31]
 entry:
   %xor = xor i64 %a, %b
@@ -304,8 +329,8 @@ define amdgpu_ps <2 x float> @xnor_i64_s_v_one_use(i64 inreg %a, i64 %b64) {
 ; GFX7-NEXT:    v_lshl_b64 v[0:1], v[0:1], 29
 ; GFX7-NEXT:    v_xor_b32_e32 v0, s0, v0
 ; GFX7-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX7-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX7-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX7-NEXT:    v_not_b32_e32 v0, v0
+; GFX7-NEXT:    v_not_b32_e32 v1, v1
 ; GFX7-NEXT:    ; return to shader part epilog
 ;
 ; GFX8-LABEL: xnor_i64_s_v_one_use:
@@ -313,8 +338,8 @@ define amdgpu_ps <2 x float> @xnor_i64_s_v_one_use(i64 inreg %a, i64 %b64) {
 ; GFX8-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
 ; GFX8-NEXT:    v_xor_b32_e32 v0, s0, v0
 ; GFX8-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX8-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX8-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX8-NEXT:    v_not_b32_e32 v0, v0
+; GFX8-NEXT:    v_not_b32_e32 v1, v1
 ; GFX8-NEXT:    ; return to shader part epilog
 ;
 ; GFX900-LABEL: xnor_i64_s_v_one_use:
@@ -322,24 +347,22 @@ define amdgpu_ps <2 x float> @xnor_i64_s_v_one_use(i64 inreg %a, i64 %b64) {
 ; GFX900-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
 ; GFX900-NEXT:    v_xor_b32_e32 v0, s0, v0
 ; GFX900-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX900-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX900-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX900-NEXT:    v_not_b32_e32 v0, v0
+; GFX900-NEXT:    v_not_b32_e32 v1, v1
 ; GFX900-NEXT:    ; return to shader part epilog
 ;
 ; GFX906-LABEL: xnor_i64_s_v_one_use:
 ; GFX906:       ; %bb.0: ; %entry
 ; GFX906-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
-; GFX906-NEXT:    v_xor_b32_e32 v0, s0, v0
-; GFX906-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX906-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX906-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX906-NEXT:    v_xnor_b32_e32 v0, s0, v0
+; GFX906-NEXT:    v_xnor_b32_e32 v1, s1, v1
 ; GFX906-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-LABEL: xnor_i64_s_v_one_use:
 ; GFX10:       ; %bb.0: ; %entry
 ; GFX10-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
-; GFX10-NEXT:    v_xor3_b32 v0, s0, v0, -1
-; GFX10-NEXT:    v_xor3_b32 v1, s1, v1, -1
+; GFX10-NEXT:    v_xnor_b32_e32 v0, s0, v0
+; GFX10-NEXT:    v_xnor_b32_e32 v1, s1, v1
 ; GFX10-NEXT:    ; return to shader part epilog
 entry:
   %b = shl i64 %b64, 29
@@ -355,8 +378,8 @@ define amdgpu_ps <2 x float> @xnor_i64_v_s_one_use(i64 inreg %a, i64 %b64) {
 ; GFX7-NEXT:    v_lshl_b64 v[0:1], v[0:1], 29
 ; GFX7-NEXT:    v_xor_b32_e32 v0, s0, v0
 ; GFX7-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX7-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX7-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX7-NEXT:    v_not_b32_e32 v0, v0
+; GFX7-NEXT:    v_not_b32_e32 v1, v1
 ; GFX7-NEXT:    ; return to shader part epilog
 ;
 ; GFX8-LABEL: xnor_i64_v_s_one_use:
@@ -364,8 +387,8 @@ define amdgpu_ps <2 x float> @xnor_i64_v_s_one_use(i64 inreg %a, i64 %b64) {
 ; GFX8-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
 ; GFX8-NEXT:    v_xor_b32_e32 v0, s0, v0
 ; GFX8-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX8-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX8-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX8-NEXT:    v_not_b32_e32 v0, v0
+; GFX8-NEXT:    v_not_b32_e32 v1, v1
 ; GFX8-NEXT:    ; return to shader part epilog
 ;
 ; GFX900-LABEL: xnor_i64_v_s_one_use:
@@ -373,24 +396,22 @@ define amdgpu_ps <2 x float> @xnor_i64_v_s_one_use(i64 inreg %a, i64 %b64) {
 ; GFX900-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
 ; GFX900-NEXT:    v_xor_b32_e32 v0, s0, v0
 ; GFX900-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX900-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX900-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX900-NEXT:    v_not_b32_e32 v0, v0
+; GFX900-NEXT:    v_not_b32_e32 v1, v1
 ; GFX900-NEXT:    ; return to shader part epilog
 ;
 ; GFX906-LABEL: xnor_i64_v_s_one_use:
 ; GFX906:       ; %bb.0:
 ; GFX906-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
-; GFX906-NEXT:    v_xor_b32_e32 v0, s0, v0
-; GFX906-NEXT:    v_xor_b32_e32 v1, s1, v1
-; GFX906-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX906-NEXT:    v_xor_b32_e32 v1, -1, v1
+; GFX906-NEXT:    v_xnor_b32_e64 v0, v0, s0
+; GFX906-NEXT:    v_xnor_b32_e64 v1, v1, s1
 ; GFX906-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-LABEL: xnor_i64_v_s_one_use:
 ; GFX10:       ; %bb.0:
 ; GFX10-NEXT:    v_lshlrev_b64 v[0:1], 29, v[0:1]
-; GFX10-NEXT:    v_xor3_b32 v0, v0, s0, -1
-; GFX10-NEXT:    v_xor3_b32 v1, v1, s1, -1
+; GFX10-NEXT:    v_xnor_b32_e64 v0, v0, s0
+; GFX10-NEXT:    v_xnor_b32_e64 v1, v1, s1
 ; GFX10-NEXT:    ; return to shader part epilog
   %b = shl i64 %b64, 29
   %xor = xor i64 %b, %a
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/xor.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/xor.ll
index 945710efba7604..41e66b9122086d 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/xor.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/xor.ll
@@ -533,59 +533,55 @@ define amdgpu_ps void @s_xor_u64_zext_with_vregs(ptr addrspace(1) %out, ptr addr
 ; GFX7-NEXT:    s_mov_b32 s2, 0
 ; GFX7-NEXT:    s_mov_b32 s3, 0xf000
 ; GFX7-NEXT:    s_mov_b64 s[0:1], 0
-; GFX7-NEXT:    buffer_load_dword v4, v[2:3], s[0:3], 0 addr64
-; GFX7-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX7-NEXT:    buffer_load_dword v2, v[2:3], s[0:3], 0 addr64
 ; GFX7-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
-; GFX7-NEXT:    v_xor_b32_e32 v2, 0x50, v4
+; GFX7-NEXT:    v_xor_b32_e32 v2, 0x50, v2
 ; GFX7-NEXT:    buffer_store_dwordx2 v[2:3], v[0:1], s[0:3], 0 addr64
 ; GFX7-NEXT:    s_endpgm
 ;
 ; GFX8-LABEL: s_xor_u64_zext_with_vregs:
 ; GFX8:       ; %bb.0:
-; GFX8-NEXT:    flat_load_dword v4, v[2:3]
-; GFX8-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX8-NEXT:    flat_load_dword v2, v[2:3]
 ; GFX8-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX8-NEXT:    s_waitcnt vmcnt(0)
-; GFX8-NEXT:    v_xor_b32_e32 v2, 0x50, v4
+; GFX8-NEXT:    v_xor_b32_e32 v2, 0x50, v2
 ; GFX8-NEXT:    flat_store_dwordx2 v[0:1], v[2:3]
 ; GFX8-NEXT:    s_endpgm
 ;
 ; GFX9-LABEL: s_xor_u64_zext_with_vregs:
 ; GFX9:       ; %bb.0:
-; GFX9-NEXT:    global_load_dword v4, v[2:3], off
-; GFX9-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX9-NEXT:    global_load_dword v2, v[2:3], off
 ; GFX9-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX9-NEXT:    s_waitcnt vmcnt(0)
-; GFX9-NEXT:    v_xor_b32_e32 v2, 0x50, v4
+; GFX9-NEXT:    v_xor_b32_e32 v2, 0x50, v2
 ; GFX9-NEXT:    global_store_dwordx2 v[0:1], v[2:3], off
 ; GFX9-NEXT:    s_endpgm
 ;
 ; GFX10-LABEL: s_xor_u64_zext_with_vregs:
 ; GFX10:       ; %bb.0:
-; GFX10-NEXT:    global_load_dword v4, v[2:3], off
-; GFX10-NEXT:    v_mov_b32_e32 v2, 0x50
+; GFX10-NEXT:    global_load_dword v2, v[2:3], off
 ; GFX10-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX10-NEXT:    s_waitcnt vmcnt(0)
-; GFX10-NEXT:    v_xor_b32_e32 v2, 0x50, v4
+; GFX10-NEXT:    v_xor_b32_e32 v2, 0x50, v2
 ; GFX10-NEXT:    global_store_dwordx2 v[0:1], v[2:3], off
 ; GFX10-NEXT:    s_endpgm
 ;
 ; GFX11-LABEL: s_xor_u64_zext_with_vregs:
 ; GFX11:       ; %bb.0:
-; GFX11-NEXT:    global_load_b32 v4, v[2:3], off
-; GFX11-NEXT:    v_dual_mov_b32 v2, 0x50 :: v_dual_mov_b32 v3, 0
+; GFX11-NEXT:    global_load_b32 v2, v[2:3], off
+; GFX11-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX11-NEXT:    s_waitcnt vmcnt(0)
-; GFX11-NEXT:    v_xor_b32_e32 v2, 0x50, v4
+; GFX11-NEXT:    v_xor_b32_e32 v2, 0x50, v2
 ; GFX11-NEXT:    global_store_b64 v[0:1], v[2:3], off
 ; GFX11-NEXT:    s_endpgm
 ;
 ; GFX12-LABEL: s_xor_u64_zext_with_vregs:
 ; GFX12:       ; %bb.0:
-; GFX12-NEXT:    global_load_b32 v4, v[2:3], off
-; GFX12-NEXT:    v_dual_mov_b32 v2, 0x50 :: v_dual_mov_b32 v3, 0
+; GFX12-NEXT:    global_load_b32 v2, v[2:3], off
+; GFX12-NEXT:    v_mov_b32_e32 v3, 0
 ; GFX12-NEXT:    s_wait_loadcnt 0x0
-; GFX12-NEXT:    v_xor_b32_e32 v2, 0x50, v4
+; GFX12-NEXT:    v_xor_b32_e32 v2, 0x50, v2
 ; GFX12-NEXT:    global_store_b64 v[0:1], v[2:3], off
 ; GFX12-NEXT:    s_endpgm
   %val = load i32, ptr addrspace(1) %in, align 4
diff --git a/llvm/test/CodeGen/AMDGPU/bfi_int.ll b/llvm/test/CodeGen/AMDGPU/bfi_int.ll
index 5bde70553ea9f5..79a67ee3576a31 100644
--- a/llvm/test/CodeGen/AMDGPU/bfi_int.ll
+++ b/llvm/test/CodeGen/AMDGPU/bfi_int.ll
@@ -644,25 +644,15 @@ define i64 @v_bitselect_i64_pat_0(i64 %a, i64 %b, i64 %mask) {
 ; GFX8-GISEL-LABEL: v_bitselect_i64_pat_0:
 ; GFX8-GISEL:       ; %bb.0:
 ; GFX8-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v2, v0, v2
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v3, v1, v3
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v0, v0, v4
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v1, v1, v5
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v0, v2, v0
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v1, v3, v1
+; GFX8-GISEL-NEXT:    v_bfi_b32 v0, v0, v2, v4
+; GFX8-GISEL-NEXT:    v_bfi_b32 v1, v1, v3, v5
 ; GFX8-GISEL-NEXT:    s_setpc_b64 s[30:31]
 ;
 ; GFX10-GISEL-LABEL: v_bitselect_i64_pat_0:
 ; GFX10-GISEL:       ; %bb.0:
 ; GFX10-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v6, -1, v0
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v7, -1, v1
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v4, v6, v4
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v5, v7, v5
-; GFX10-GISEL-NEXT:    v_and_or_b32 v0, v0, v2, v4
-; GFX10-GISEL-NEXT:    v_and_or_b32 v1, v1, v3, v5
+; GFX10-GISEL-NEXT:    v_bfi_b32 v0, v0, v2, v4
+; GFX10-GISEL-NEXT:    v_bfi_b32 v1, v1, v3, v5
 ; GFX10-GISEL-NEXT:    s_setpc_b64 s[30:31]
   %and0 = and i64 %a, %b
   %not.a = xor i64 %a, -1
@@ -696,24 +686,16 @@ define amdgpu_ps <2 x float> @v_s_s_bitselect_i64_pat_0(i64 %a, i64 inreg %b, i6
 ;
 ; GFX8-GISEL-LABEL: v_s_s_bitselect_i64_pat_0:
 ; GFX8-GISEL:       ; %bb.0:
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v2, s0, v0
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v3, s1, v1
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v0, s2, v0
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v1, s3, v1
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v0, v2, v0
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v1, v3, v1
+; GFX8-GISEL-NEXT:    v_mov_b32_e32 v2, s2
+; GFX8-GISEL-NEXT:    v_mov_b32_e32 v3, s3
+; GFX8-GISEL-NEXT:    v_bfi_b32 v0, v0, s0, v2
+; GFX8-GISEL-NEXT:    v_bfi_b32 v1, v1, s1, v3
 ; GFX8-GISEL-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-GISEL-LABEL: v_s_s_bitselect_i64_pat_0:
 ; GFX10-GISEL:       ; %bb.0:
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v2, -1, v0
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v3, -1, v1
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v2, s2, v2
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v3, s3, v3
-; GFX10-GISEL-NEXT:    v_and_or_b32 v0, v0, s0, v2
-; GFX10-GISEL-NEXT:    v_and_or_b32 v1, v1, s1, v3
+; GFX10-GISEL-NEXT:    v_bfi_b32 v0, v0, s0, s2
+; GFX10-GISEL-NEXT:    v_bfi_b32 v1, v1, s1, s3
 ; GFX10-GISEL-NEXT:    ; return to shader part epilog
   %and0 = and i64 %a, %b
   %not.a = xor i64 %a, -1
@@ -850,24 +832,14 @@ define amdgpu_ps <2 x float> @v_v_s_bitselect_i64_pat_0(i64 %a, i64 %b, i64 inre
 ;
 ; GFX8-GISEL-LABEL: v_v_s_bitselect_i64_pat_0:
 ; GFX8-GISEL:       ; %bb.0:
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v2, v0, v2
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v3, v1, v3
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v0, s0, v0
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v1, s1, v1
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v0, v2, v0
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v1, v3, v1
+; GFX8-GISEL-NEXT:    v_bfi_b32 v0, v0, v2, s0
+; GFX8-GISEL-NEXT:    v_bfi_b32 v1, v1, v3, s1
 ; GFX8-GISEL-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-GISEL-LABEL: v_v_s_bitselect_i64_pat_0:
 ; GFX10-GISEL:       ; %bb.0:
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v4, -1, v0
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v5, -1, v1
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v4, s0, v4
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v5, s1, v5
-; GFX10-GISEL-NEXT:    v_and_or_b32 v0, v0, v2, v4
-; GFX10-GISEL-NEXT:    v_and_or_b32 v1, v1, v3, v5
+; GFX10-GISEL-NEXT:    v_bfi_b32 v0, v0, v2, s0
+; GFX10-GISEL-NEXT:    v_bfi_b32 v1, v1, v3, s1
 ; GFX10-GISEL-NEXT:    ; return to shader part epilog
   %and0 = and i64 %a, %b
   %not.a = xor i64 %a, -1
@@ -898,24 +870,14 @@ define amdgpu_ps <2 x float> @v_s_v_bitselect_i64_pat_0(i64 %a, i64 inreg %b, i6
 ;
 ; GFX8-GISEL-LABEL: v_s_v_bitselect_i64_pat_0:
 ; GFX8-GISEL:       ; %bb.0:
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v4, s0, v0
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v5, s1, v1
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v0, -1, v0
-; GFX8-GISEL-NEXT:    v_xor_b32_e32 v1, -1, v1
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v0, v0, v2
-; GFX8-GISEL-NEXT:    v_and_b32_e32 v1, v1, v3
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v0, v4, v0
-; GFX8-GISEL-NEXT:    v_or_b32_e32 v1, v5, v1
+; GFX8-GISEL-NEXT:    v_bfi_b32 v0, v0, s0, v2
+; GFX8-GISEL-NEXT:    v_bfi_b32 v1, v1, s1, v3
 ; GFX8-GISEL-NEXT:    ; return to shader part epilog
 ;
 ; GFX10-GISEL-LABEL: v_s_v_bitselect_i64_pat_0:
 ; GFX10-GISEL:       ; %bb.0:
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v4, -1, v0
-; GFX10-GISEL-NEXT:    v_xor_b32_e32 v5, -1, v1
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v2, v4, v2
-; GFX10-GISEL-NEXT:    v_and_b32_e32 v3, v5, v3
-; GFX10-GISEL-NEXT:    v_and_or_b32 v0, v0, s0, v2
-; GFX10-GISEL-NEXT:    v_and_or_b32 v1, v1, s1, v3
+; GFX10-GISEL-NEXT:    v_bfi_b32 v0, v0, s0, v2
+; GFX10-GISEL-NEXT:    v_bfi_b32 v1, v1, s1, v3
 ; GFX10-GISEL-NEXT:    ; return to shader part epilog
   %and0 = and i64 %a, %b
   %not.a = xor i64 %a, -1
diff --git a/llvm/test/CodeGen/AMDGPU/div_i128.ll b/llvm/test/CodeGen/AMDGPU/div_i128.ll
index ce6a6f596efd35..8be7a88c34701d 100644
--- a/llvm/test/CodeGen/AMDGPU/div_i128.ll
+++ b/llvm/test/CodeGen/AMDGPU/div_i128.ll
@@ -1303,7 +1303,6 @@ define i128 @v_sdiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-NEXT:    v_mov_b32_e32 v9, 0
 ; GFX9-G-NEXT:    v_mov_b32_e32 v0, s8
 ; GFX9-G-NEXT:    v_mov_b32_e32 v1, s9
-; GFX9-G-NEXT:    v_mov_b32_e32 v8, 1
 ; GFX9-G-NEXT:    v_mov_b32_e32 v2, s10
 ; GFX9-G-NEXT:    v_mov_b32_e32 v3, s11
 ; GFX9-G-NEXT:  .LBB0_3: ; %udiv-do-while
@@ -1770,7 +1769,6 @@ define i128 @v_sdiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    buffer_load_dword v10, off, s[0:3], s32 offset:280 ; 4-byte Folded Reload
 ; GFX9-G-O0-NEXT:    buffer_load_dword v12, off, s[0:3], s32 offset:284 ; 4-byte Folded Reload
 ; GFX9-G-O0-NEXT:    buffer_load_dword v13, off, s[0:3], s32 offset:288 ; 4-byte Folded Reload
-; GFX9-G-O0-NEXT:    s_mov_b64 s[8:9], 1
 ; GFX9-G-O0-NEXT:    s_mov_b64 s[4:5], 0
 ; GFX9-G-O0-NEXT:    s_waitcnt vmcnt(18)
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v2
@@ -1778,14 +1776,14 @@ define i128 @v_sdiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    s_waitcnt vmcnt(16)
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v15, v5
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v14, v4
-; GFX9-G-O0-NEXT:    s_mov_b32 s11, 1
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s11
+; GFX9-G-O0-NEXT:    s_mov_b32 s9, 1
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[2:3], v2, v[0:1]
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v4, s11
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v4, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[4:5], v4, v[14:15]
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr1 killed $vgpr1 killed $vgpr0_vgpr1 killed $exec
-; GFX9-G-O0-NEXT:    s_mov_b32 s10, 31
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s10
+; GFX9-G-O0-NEXT:    s_mov_b32 s8, 31
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s8
 ; GFX9-G-O0-NEXT:    v_lshrrev_b32_e64 v1, v0, v1
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v4
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr5 killed $vgpr5 killed $vgpr4_vgpr5 killed $exec
@@ -1793,7 +1791,7 @@ define i128 @v_sdiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v24
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v1, v25
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr1 killed $vgpr1 killed $vgpr0_vgpr1 killed $exec
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s10
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s8
 ; GFX9-G-O0-NEXT:    v_lshrrev_b32_e64 v1, v0, v1
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v2
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v9, v3
@@ -1802,12 +1800,12 @@ define i128 @v_sdiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v3, v23
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v14, v24
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v15, v25
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s11
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[25:26], v0, v[2:3]
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s11
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[0:1], v0, v[14:15]
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr3 killed $vgpr3 killed $vgpr2_vgpr3 killed $exec
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s10
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s8
 ; GFX9-G-O0-NEXT:    v_lshrrev_b32_e64 v15, v2, v3
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v14, v0
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v3, v1
@@ -1840,18 +1838,16 @@ define i128 @v_sdiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    buffer_store_dword v2, off, s[0:3], s32 offset:156 ; 4-byte Folded Spill
 ; GFX9-G-O0-NEXT:    buffer_store_dword v3, off, s[0:3], s32 offset:160 ; 4-byte Folded Spill
 ; GFX9-G-O0-NEXT:    s_waitcnt vmcnt(4)
-; GFX9-G-O0-NEXT:    v_sub_co_u32_e64 v13, s[12:13], v13, v4
-; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v12, s[12:13], v12, v9, s[12:13]
-; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v10, s[12:13], v10, v7, s[12:13]
-; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v12, s[12:13], v6, v5, s[12:13]
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s10
+; GFX9-G-O0-NEXT:    v_sub_co_u32_e64 v13, s[10:11], v13, v4
+; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v12, s[10:11], v12, v9, s[10:11]
+; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v10, s[10:11], v10, v7, s[10:11]
+; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v12, s[10:11], v6, v5, s[10:11]
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s8
 ; GFX9-G-O0-NEXT:    v_ashrrev_i32_e64 v10, v6, v12
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s10
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s8
 ; GFX9-G-O0-NEXT:    v_ashrrev_i32_e64 v6, v6, v12
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v14, s9
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v13, s8
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v12, v13
-; GFX9-G-O0-NEXT:    ; kill: def $vgpr14 killed $vgpr14 killed $vgpr13_vgpr14 killed $exec
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v12, 1
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v14, 0
 ; GFX9-G-O0-NEXT:    v_and_b32_e64 v12, v10, v12
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr12 killed $vgpr12 def $vgpr12_vgpr13 killed $exec
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v13, v14
@@ -3356,7 +3352,6 @@ define i128 @v_udiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-NEXT:    v_mov_b32_e32 v1, 0
 ; GFX9-G-NEXT:    v_mov_b32_e32 v11, s9
 ; GFX9-G-NEXT:    v_mov_b32_e32 v10, s8
-; GFX9-G-NEXT:    v_mov_b32_e32 v0, 1
 ; GFX9-G-NEXT:    v_mov_b32_e32 v13, s11
 ; GFX9-G-NEXT:    v_mov_b32_e32 v12, s10
 ; GFX9-G-NEXT:  .LBB1_3: ; %udiv-do-while
@@ -3787,7 +3782,6 @@ define i128 @v_udiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    buffer_load_dword v8, off, s[0:3], s32 offset:248 ; 4-byte Folded Reload
 ; GFX9-G-O0-NEXT:    buffer_load_dword v10, off, s[0:3], s32 offset:252 ; 4-byte Folded Reload
 ; GFX9-G-O0-NEXT:    buffer_load_dword v11, off, s[0:3], s32 offset:256 ; 4-byte Folded Reload
-; GFX9-G-O0-NEXT:    s_mov_b64 s[8:9], 1
 ; GFX9-G-O0-NEXT:    s_mov_b64 s[4:5], 0
 ; GFX9-G-O0-NEXT:    s_waitcnt vmcnt(18)
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v2
@@ -3795,14 +3789,14 @@ define i128 @v_udiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    s_waitcnt vmcnt(16)
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v21, v5
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v20, v4
-; GFX9-G-O0-NEXT:    s_mov_b32 s11, 1
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s11
+; GFX9-G-O0-NEXT:    s_mov_b32 s9, 1
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[2:3], v2, v[0:1]
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v4, s11
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v4, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[4:5], v4, v[20:21]
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr1 killed $vgpr1 killed $vgpr0_vgpr1 killed $exec
-; GFX9-G-O0-NEXT:    s_mov_b32 s10, 31
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s10
+; GFX9-G-O0-NEXT:    s_mov_b32 s8, 31
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s8
 ; GFX9-G-O0-NEXT:    v_lshrrev_b32_e64 v1, v0, v1
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v4
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr5 killed $vgpr5 killed $vgpr4_vgpr5 killed $exec
@@ -3810,7 +3804,7 @@ define i128 @v_udiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v14
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v1, v15
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr1 killed $vgpr1 killed $vgpr0_vgpr1 killed $exec
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s10
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s8
 ; GFX9-G-O0-NEXT:    v_lshrrev_b32_e64 v1, v0, v1
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, v2
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v9, v3
@@ -3819,12 +3813,12 @@ define i128 @v_udiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v3, v13
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v12, v14
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v13, v15
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s11
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[22:23], v0, v[2:3]
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s11
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v0, s9
 ; GFX9-G-O0-NEXT:    v_lshlrev_b64 v[0:1], v0, v[12:13]
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr3 killed $vgpr3 killed $vgpr2_vgpr3 killed $exec
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s10
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v2, s8
 ; GFX9-G-O0-NEXT:    v_lshrrev_b32_e64 v13, v2, v3
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v12, v0
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v3, v1
@@ -3857,18 +3851,16 @@ define i128 @v_udiv_i128_vv(i128 %lhs, i128 %rhs) {
 ; GFX9-G-O0-NEXT:    buffer_store_dword v2, off, s[0:3], s32 offset:124 ; 4-byte Folded Spill
 ; GFX9-G-O0-NEXT:    buffer_store_dword v3, off, s[0:3], s32 offset:128 ; 4-byte Folded Spill
 ; GFX9-G-O0-NEXT:    s_waitcnt vmcnt(4)
-; GFX9-G-O0-NEXT:    v_sub_co_u32_e64 v11, s[12:13], v11, v4
-; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v10, s[12:13], v10, v9, s[12:13]
-; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v8, s[12:13], v8, v7, s[12:13]
-; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v10, s[12:13], v6, v5, s[12:13]
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s10
+; GFX9-G-O0-NEXT:    v_sub_co_u32_e64 v11, s[10:11], v11, v4
+; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v10, s[10:11], v10, v9, s[10:11]
+; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v8, s[10:11], v8, v7, s[10:11]
+; GFX9-G-O0-NEXT:    v_subb_co_u32_e64 v10, s[10:11], v6, v5, s[10:11]
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s8
 ; GFX9-G-O0-NEXT:    v_ashrrev_i32_e64 v8, v6, v10
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s10
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v6, s8
 ; GFX9-G-O0-NEXT:    v_ashrrev_i32_e64 v6, v6, v10
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v13, s9
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v12, s8
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v11, v12
-; GFX9-G-O0-NEXT:    v_mov_b32_e32 v10, v13
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v11, 1
+; GFX9-G-O0-NEXT:    v_mov_b32_e32 v10, 0
 ; GFX9-G-O0-NEXT:    v_and_b32_e64 v12, v8, v11
 ; GFX9-G-O0-NEXT:    ; kill: def $vgpr12 killed $vgpr12 def $vgpr12_vgpr13 killed $exec
 ; GFX9-G-O0-NEXT:    v_mov_b32_e32 v13, v10
diff --git a/llvm/test/CodeGen/AMDGPU/div_v2i128.ll b/llvm/test/CodeGen/AMDGPU/div_v2i128.ll
index 14b58cc3ab050f..d1170c45d84e4b 100644
--- a/llvm/test/CodeGen/AMDGPU/div_v2i128.ll
+++ b/llvm/test/CodeGen/AMDGPU/div_v2i128.ll
@@ -537,7 +537,6 @@ define <2 x i128> @v_sdiv_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_mov_b32_e32 v17, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v0, s8
 ; GISEL-NEXT:    v_mov_b32_e32 v1, s9
-; GISEL-NEXT:    v_mov_b32_e32 v16, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v2, s10
 ; GISEL-NEXT:    v_mov_b32_e32 v3, s11
 ; GISEL-NEXT:  .LBB0_3: ; %udiv-do-while3
@@ -726,7 +725,6 @@ define <2 x i128> @v_sdiv_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_mov_b32_e32 v7, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v0, s8
 ; GISEL-NEXT:    v_mov_b32_e32 v1, s9
-; GISEL-NEXT:    v_mov_b32_e32 v6, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v2, s10
 ; GISEL-NEXT:    v_mov_b32_e32 v3, s11
 ; GISEL-NEXT:  .LBB0_9: ; %udiv-do-while
@@ -1337,7 +1335,6 @@ define <2 x i128> @v_udiv_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_mov_b32_e32 v1, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v19, s9
 ; GISEL-NEXT:    v_mov_b32_e32 v18, s8
-; GISEL-NEXT:    v_mov_b32_e32 v0, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v21, s11
 ; GISEL-NEXT:    v_mov_b32_e32 v20, s10
 ; GISEL-NEXT:  .LBB2_3: ; %udiv-do-while3
@@ -1508,7 +1505,6 @@ define <2 x i128> @v_udiv_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_mov_b32_e32 v5, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v21, s9
 ; GISEL-NEXT:    v_mov_b32_e32 v20, s8
-; GISEL-NEXT:    v_mov_b32_e32 v4, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v23, s11
 ; GISEL-NEXT:    v_mov_b32_e32 v22, s10
 ; GISEL-NEXT:  .LBB2_9: ; %udiv-do-while
@@ -2190,7 +2186,6 @@ define <2 x i128> @v_srem_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_mov_b32_e32 v24, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v0, s8
 ; GISEL-NEXT:    v_mov_b32_e32 v1, s9
-; GISEL-NEXT:    v_mov_b32_e32 v23, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v2, s10
 ; GISEL-NEXT:    v_mov_b32_e32 v3, s11
 ; GISEL-NEXT:  .LBB4_3: ; %udiv-do-while3
@@ -2379,7 +2374,6 @@ define <2 x i128> @v_srem_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_mov_b32_e32 v23, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v0, s8
 ; GISEL-NEXT:    v_mov_b32_e32 v1, s9
-; GISEL-NEXT:    v_mov_b32_e32 v22, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v2, s10
 ; GISEL-NEXT:    v_mov_b32_e32 v3, s11
 ; GISEL-NEXT:  .LBB4_9: ; %udiv-do-while
@@ -2994,7 +2988,6 @@ define <2 x i128> @v_urem_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_cndmask_b32_e64 v26, v17, v1, s[4:5]
 ; GISEL-NEXT:    v_addc_u32_e32 v36, vcc, -1, v11, vcc
 ; GISEL-NEXT:    s_mov_b64 s[10:11], s[8:9]
-; GISEL-NEXT:    v_mov_b32_e32 v19, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v20, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v17, s9
 ; GISEL-NEXT:    v_mov_b32_e32 v16, s8
@@ -3168,7 +3161,6 @@ define <2 x i128> @v_urem_v2i128_vv(<2 x i128> %lhs, <2 x i128> %rhs) {
 ; GISEL-NEXT:    v_mov_b32_e32 v27, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v17, s9
 ; GISEL-NEXT:    v_mov_b32_e32 v16, s8
-; GISEL-NEXT:    v_mov_b32_e32 v26, 1
 ; GISEL-NEXT:    v_mov_b32_e32 v19, s11
 ; GISEL-NEXT:    v_mov_b32_e32 v18, s10
 ; GISEL-NEXT:  .LBB5_9: ; %udiv-do-while
diff --git a/llvm/test/CodeGen/AMDGPU/fptoi.i128.ll b/llvm/test/CodeGen/AMDGPU/fptoi.i128.ll
index 457b9eb6d2df14..8e7243fb0d8ae7 100644
--- a/llvm/test/CodeGen/AMDGPU/fptoi.i128.ll
+++ b/llvm/test/CodeGen/AMDGPU/fptoi.i128.ll
@@ -162,9 +162,8 @@ define i128 @fptosi_f64_to_i128(double %x) {
 ; GISEL-NEXT:    v_and_b32_e32 v0, 0xffff, v0
 ; GISEL-NEXT:    v_and_b32_e32 v1, 0xffff, v1
 ; GISEL-NEXT:    v_lshlrev_b32_e32 v2, 16, v0
-; GISEL-NEXT:    v_lshl_or_b32 v10, v0, 16, v0
+; GISEL-NEXT:    v_lshl_or_b32 v9, v0, 16, v0
 ; GISEL-NEXT:    v_or3_b32 v8, v1, v2, 1
-; GISEL-NEXT:    v_or3_b32 v9, v0, v2, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v0, 0x433
 ; GISEL-NEXT:    v_mov_b32_e32 v1, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v2, 0xfffff
@@ -176,27 +175,27 @@ define i128 @fptosi_f64_to_i128(double %x) {
 ; GISEL-NEXT:    s_xor_b64 s[12:13], exec, s[4:5]
 ; GISEL-NEXT:    s_cbranch_execz .LBB0_3
 ; GISEL-NEXT:  ; %bb.2: ; %fp-to-i-if-exp.large
-; GISEL-NEXT:    v_add_u32_e32 v13, 0xfffffbcd, v6
-; GISEL-NEXT:    v_lshlrev_b64 v[0:1], v13, v[4:5]
-; GISEL-NEXT:    v_cmp_gt_u32_e32 vcc, 64, v13
-; GISEL-NEXT:    v_sub_u32_e32 v2, 64, v13
-; GISEL-NEXT:    v_cndmask_b32_e32 v14, 0, v0, vcc
-; GISEL-NEXT:    v_add_u32_e32 v11, 0xfffffb8d, v6
+; GISEL-NEXT:    v_add_u32_e32 v12, 0xfffffbcd, v6
+; GISEL-NEXT:    v_lshlrev_b64 v[0:1], v12, v[4:5]
+; GISEL-NEXT:    v_cmp_gt_u32_e32 vcc, 64, v12
+; GISEL-NEXT:    v_sub_u32_e32 v2, 64, v12
+; GISEL-NEXT:    v_cndmask_b32_e32 v13, 0, v0, vcc
+; GISEL-NEXT:    v_add_u32_e32 v10, 0xfffffb8d, v6
 ; GISEL-NEXT:    v_lshrrev_b64 v[6:7], v2, v[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v14, v10, 0
-; GISEL-NEXT:    v_cndmask_b32_e32 v15, 0, v1, vcc
-; GISEL-NEXT:    v_lshlrev_b64 v[4:5], v11, v[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[4:5], v15, v9, v[2:3]
+; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v13, v9, 0
+; GISEL-NEXT:    v_cndmask_b32_e32 v14, 0, v1, vcc
+; GISEL-NEXT:    v_lshlrev_b64 v[4:5], v10, v[4:5]
+; GISEL-NEXT:    v_mad_u64_u32 v[10:11], s[4:5], v14, v9, v[2:3]
 ; GISEL-NEXT:    v_cndmask_b32_e32 v0, v4, v6, vcc
-; GISEL-NEXT:    v_cmp_eq_u32_e64 s[4:5], 0, v13
+; GISEL-NEXT:    v_cmp_eq_u32_e64 s[4:5], 0, v12
 ; GISEL-NEXT:    v_cndmask_b32_e64 v4, v0, 0, s[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[6:7], v14, v8, 0
-; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[6:7], v4, v8, v[11:12]
-; GISEL-NEXT:    v_mul_lo_u32 v6, v15, v10
-; GISEL-NEXT:    v_mul_lo_u32 v10, v14, v10
-; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[6:7], v14, v9, v[1:2]
-; GISEL-NEXT:    v_mad_u64_u32 v[1:2], s[8:9], v15, v8, v[11:12]
-; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[8:9], v3, v10, s[8:9]
+; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[6:7], v13, v8, 0
+; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[6:7], v4, v8, v[10:11]
+; GISEL-NEXT:    v_mul_lo_u32 v12, v13, v9
+; GISEL-NEXT:    v_mul_lo_u32 v6, v14, v9
+; GISEL-NEXT:    v_mad_u64_u32 v[10:11], s[6:7], v13, v9, v[1:2]
+; GISEL-NEXT:    v_mad_u64_u32 v[1:2], s[8:9], v14, v8, v[10:11]
+; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[8:9], v3, v12, s[8:9]
 ; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[6:7], v3, v6, s[6:7]
 ; GISEL-NEXT:    v_mad_u64_u32 v[10:11], s[6:7], v4, v9, v[3:4]
 ; GISEL-NEXT:    v_cndmask_b32_e32 v3, v5, v7, vcc
@@ -206,22 +205,21 @@ define i128 @fptosi_f64_to_i128(double %x) {
 ; GISEL-NEXT:    v_mad_u64_u32 v[3:4], s[4:5], v5, v8, v[10:11]
 ; GISEL-NEXT:    ; implicit-def: $vgpr4_vgpr5
 ; GISEL-NEXT:    ; implicit-def: $vgpr8
-; GISEL-NEXT:    ; implicit-def: $vgpr10
 ; GISEL-NEXT:  .LBB0_3: ; %Flow
 ; GISEL-NEXT:    s_andn2_saveexec_b64 s[6:7], s[12:13]
 ; GISEL-NEXT:    s_cbranch_execz .LBB0_5
 ; GISEL-NEXT:  ; %bb.4: ; %fp-to-i-if-exp.small
 ; GISEL-NEXT:    v_sub_co_u32_e32 v0, vcc, 0x433, v6
 ; GISEL-NEXT:    v_lshrrev_b64 v[4:5], v0, v[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[6:7], s[4:5], v4, v10, 0
+; GISEL-NEXT:    v_mad_u64_u32 v[6:7], s[4:5], v4, v9, 0
 ; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[4:5], v4, v8, 0
-; GISEL-NEXT:    v_mul_lo_u32 v11, v5, v10
+; GISEL-NEXT:    v_mul_lo_u32 v10, v5, v9
 ; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v5, v9, v[6:7]
 ; GISEL-NEXT:    v_mad_u64_u32 v[6:7], vcc, v4, v9, v[1:2]
-; GISEL-NEXT:    v_mul_lo_u32 v4, v4, v10
+; GISEL-NEXT:    v_mul_lo_u32 v4, v4, v9
 ; GISEL-NEXT:    v_mad_u64_u32 v[1:2], s[4:5], v5, v8, v[6:7]
 ; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[4:5], v3, v4, s[4:5]
-; GISEL-NEXT:    v_addc_co_u32_e32 v3, vcc, v3, v11, vcc
+; GISEL-NEXT:    v_addc_co_u32_e32 v3, vcc, v3, v10, vcc
 ; GISEL-NEXT:  .LBB0_5: ; %Flow1
 ; GISEL-NEXT:    s_or_b64 exec, exec, s[6:7]
 ; GISEL-NEXT:  .LBB0_6: ; %fp-to-i-cleanup
@@ -498,9 +496,8 @@ define i128 @fptosi_f32_to_i128(float %x) {
 ; GISEL-NEXT:    v_and_b32_e32 v0, 0xffff, v0
 ; GISEL-NEXT:    v_and_b32_e32 v1, 0xffff, v1
 ; GISEL-NEXT:    v_lshlrev_b32_e32 v2, 16, v0
-; GISEL-NEXT:    v_lshl_or_b32 v9, v0, 16, v0
+; GISEL-NEXT:    v_lshl_or_b32 v7, v0, 16, v0
 ; GISEL-NEXT:    v_or3_b32 v8, v1, v2, 1
-; GISEL-NEXT:    v_or3_b32 v7, v0, v2, 0
 ; GISEL-NEXT:    v_mov_b32_e32 v0, 0x7fffff
 ; GISEL-NEXT:    v_mov_b32_e32 v1, 0x800000
 ; GISEL-NEXT:    v_and_or_b32 v4, v4, v0, v1
@@ -512,37 +509,36 @@ define i128 @fptosi_f32_to_i128(float %x) {
 ; GISEL-NEXT:    s_xor_b64 s[12:13], exec, s[4:5]
 ; GISEL-NEXT:    s_cbranch_execz .LBB2_3
 ; GISEL-NEXT:  ; %bb.2: ; %fp-to-i-if-exp.large
-; GISEL-NEXT:    v_add_u32_e32 v14, 0xffffff6a, v6
-; GISEL-NEXT:    v_lshlrev_b64 v[0:1], v14, v[4:5]
-; GISEL-NEXT:    v_cmp_gt_u32_e32 vcc, 64, v14
-; GISEL-NEXT:    v_sub_u32_e32 v2, 64, v14
-; GISEL-NEXT:    v_cndmask_b32_e32 v15, 0, v0, vcc
-; GISEL-NEXT:    v_lshrrev_b64 v[10:11], v2, v[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v15, v9, 0
+; GISEL-NEXT:    v_add_u32_e32 v13, 0xffffff6a, v6
+; GISEL-NEXT:    v_lshlrev_b64 v[0:1], v13, v[4:5]
+; GISEL-NEXT:    v_cmp_gt_u32_e32 vcc, 64, v13
+; GISEL-NEXT:    v_sub_u32_e32 v2, 64, v13
+; GISEL-NEXT:    v_cndmask_b32_e32 v14, 0, v0, vcc
+; GISEL-NEXT:    v_lshrrev_b64 v[9:10], v2, v[4:5]
+; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v14, v7, 0
 ; GISEL-NEXT:    v_add_u32_e32 v6, 0xffffff2a, v6
 ; GISEL-NEXT:    v_lshlrev_b64 v[4:5], v6, v[4:5]
 ; GISEL-NEXT:    v_cndmask_b32_e32 v6, 0, v1, vcc
-; GISEL-NEXT:    v_mad_u64_u32 v[12:13], s[4:5], v6, v7, v[2:3]
-; GISEL-NEXT:    v_cndmask_b32_e32 v0, v4, v10, vcc
-; GISEL-NEXT:    v_cmp_eq_u32_e64 s[4:5], 0, v14
+; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[4:5], v6, v7, v[2:3]
+; GISEL-NEXT:    v_cndmask_b32_e32 v0, v4, v9, vcc
+; GISEL-NEXT:    v_cmp_eq_u32_e64 s[4:5], 0, v13
 ; GISEL-NEXT:    v_cndmask_b32_e64 v4, v0, 0, s[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[6:7], v15, v8, 0
-; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[6:7], v4, v8, v[12:13]
-; GISEL-NEXT:    v_mul_lo_u32 v10, v6, v9
-; GISEL-NEXT:    v_mul_lo_u32 v9, v15, v9
-; GISEL-NEXT:    v_mad_u64_u32 v[12:13], s[6:7], v15, v7, v[1:2]
-; GISEL-NEXT:    v_mad_u64_u32 v[1:2], s[8:9], v6, v8, v[12:13]
-; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[8:9], v3, v9, s[8:9]
-; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[6:7], v3, v10, s[6:7]
-; GISEL-NEXT:    v_mad_u64_u32 v[9:10], s[6:7], v4, v7, v[3:4]
-; GISEL-NEXT:    v_cndmask_b32_e32 v3, v5, v11, vcc
+; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[6:7], v14, v8, 0
+; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[6:7], v4, v8, v[11:12]
+; GISEL-NEXT:    v_mul_lo_u32 v13, v14, v7
+; GISEL-NEXT:    v_mul_lo_u32 v9, v6, v7
+; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[6:7], v14, v7, v[1:2]
+; GISEL-NEXT:    v_mad_u64_u32 v[1:2], s[8:9], v6, v8, v[11:12]
+; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[8:9], v3, v13, s[8:9]
+; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[6:7], v3, v9, s[6:7]
+; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[6:7], v4, v7, v[3:4]
+; GISEL-NEXT:    v_cndmask_b32_e32 v3, v5, v10, vcc
 ; GISEL-NEXT:    v_cndmask_b32_e64 v5, v3, 0, s[4:5]
 ; GISEL-NEXT:    ; implicit-def: $vgpr6
 ; GISEL-NEXT:    ; implicit-def: $vgpr7
-; GISEL-NEXT:    v_mad_u64_u32 v[3:4], s[4:5], v5, v8, v[9:10]
+; GISEL-NEXT:    v_mad_u64_u32 v[3:4], s[4:5], v5, v8, v[11:12]
 ; GISEL-NEXT:    ; implicit-def: $vgpr4
 ; GISEL-NEXT:    ; implicit-def: $vgpr8
-; GISEL-NEXT:    ; implicit-def: $vgpr9
 ; GISEL-NEXT:  .LBB2_3: ; %Flow
 ; GISEL-NEXT:    s_andn2_saveexec_b64 s[4:5], s[12:13]
 ; GISEL-NEXT:    s_cbranch_execz .LBB2_5
@@ -550,8 +546,8 @@ define i128 @fptosi_f32_to_i128(float %x) {
 ; GISEL-NEXT:    v_sub_u32_e32 v0, 0x96, v6
 ; GISEL-NEXT:    v_lshrrev_b32_e32 v6, v0, v4
 ; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[6:7], v6, v8, 0
-; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[6:7], v6, v9, 0
-; GISEL-NEXT:    v_mul_lo_u32 v8, v6, v9
+; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[6:7], v6, v7, 0
+; GISEL-NEXT:    v_mul_lo_u32 v8, v6, v7
 ; GISEL-NEXT:    v_mad_u64_u32 v[4:5], vcc, v6, v7, v[1:2]
 ; GISEL-NEXT:    v_addc_co_u32_e32 v3, vcc, v3, v8, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v1, v4
@@ -856,15 +852,15 @@ define i128 @fptosi_bf16_to_i128(bfloat %x) {
 ; GISEL-NEXT:    v_or_b32_e32 v2, v3, v2
 ; GISEL-NEXT:    v_or_b32_e32 v1, v1, v0
 ; GISEL-NEXT:    v_or_b32_e32 v0, v2, v0
-; GISEL-NEXT:    v_and_b32_e32 v9, 0xffff, v0
-; GISEL-NEXT:    v_and_b32_e32 v1, 0xffff, v1
-; GISEL-NEXT:    v_lshlrev_b32_e32 v0, 16, v9
-; GISEL-NEXT:    v_or3_b32 v7, v1, v0, 1
-; GISEL-NEXT:    v_or3_b32 v8, v9, v0, 0
+; GISEL-NEXT:    v_and_b32_e32 v0, 0xffff, v0
+; GISEL-NEXT:    v_lshlrev_b32_e32 v2, 16, v0
+; GISEL-NEXT:    v_lshl_or_b32 v8, v0, 16, v0
 ; GISEL-NEXT:    v_and_b32_e32 v0, 0x7f, v4
+; GISEL-NEXT:    v_and_b32_e32 v1, 0xffff, v1
 ; GISEL-NEXT:    v_or_b32_e32 v4, 0x80, v0
 ; GISEL-NEXT:    v_mov_b32_e32 v0, 0x86
 ; GISEL-NEXT:    v_mov_b32_e32 v5, 0
+; GISEL-NEXT:    v_or3_b32 v7, v1, v2, 1
 ; GISEL-NEXT:    v_cmp_ge_u16_sdwa s[4:5], v6, v0 src0_sel:BYTE_0 src1_sel:DWORD
 ; GISEL-NEXT:    ; implicit-def: $vgpr0_vgpr1_vgpr2_vgpr3
 ; GISEL-NEXT:    s_and_saveexec_b64 s[6:7], s[4:5]
@@ -876,24 +872,23 @@ define i128 @fptosi_bf16_to_i128(bfloat %x) {
 ; GISEL-NEXT:    v_and_b32_e32 v4, 0xffff, v4
 ; GISEL-NEXT:    v_lshlrev_b64 v[0:1], v6, v[4:5]
 ; GISEL-NEXT:    v_cmp_gt_u32_e32 vcc, 64, v6
-; GISEL-NEXT:    v_lshl_or_b32 v13, v9, 16, v9
 ; GISEL-NEXT:    v_sub_u32_e32 v2, 64, v6
-; GISEL-NEXT:    v_cndmask_b32_e32 v14, 0, v0, vcc
+; GISEL-NEXT:    v_cndmask_b32_e32 v13, 0, v0, vcc
 ; GISEL-NEXT:    v_lshrrev_b64 v[9:10], v2, v[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v14, v13, 0
+; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[4:5], v13, v8, 0
 ; GISEL-NEXT:    v_add_u32_e32 v11, 0xffffffc0, v6
-; GISEL-NEXT:    v_cndmask_b32_e32 v15, 0, v1, vcc
+; GISEL-NEXT:    v_cndmask_b32_e32 v14, 0, v1, vcc
 ; GISEL-NEXT:    v_lshlrev_b64 v[4:5], v11, v[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[4:5], v15, v8, v[2:3]
+; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[4:5], v14, v8, v[2:3]
 ; GISEL-NEXT:    v_cndmask_b32_e32 v0, v4, v9, vcc
 ; GISEL-NEXT:    v_cmp_eq_u32_e64 s[4:5], 0, v6
 ; GISEL-NEXT:    v_cndmask_b32_e64 v4, v0, 0, s[4:5]
-; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[6:7], v14, v7, 0
+; GISEL-NEXT:    v_mad_u64_u32 v[0:1], s[6:7], v13, v7, 0
 ; GISEL-NEXT:    v_mad_u64_u32 v[2:3], s[6:7], v4, v7, v[11:12]
-; GISEL-NEXT:    v_mul_lo_u32 v9, v14, v13
-; GISEL-NEXT:    v_mul_lo_u32 v6, v15, v13
-; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[6:7], v14, v8, v[1:2]
-; GISEL-NEXT:    v_mad_u64_u32 v[1:2], s[8:9], v15, v7, v[11:12]
+; GISEL-NEXT:    v_mul_lo_u32 v9, v13, v8
+; GISEL-NEXT:    v_mul_lo_u32 v6, v14, v8
+; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[6:7], v13, v8, v[1:2]
+; GISEL-NEXT:    v_mad_u64_u32 v[1:2], s[8:9], v14, v7, v[11:12]
 ; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[8:9], v3, v9, s[8:9]
 ; GISEL-NEXT:    v_addc_co_u32_e64 v3, s[6:7], v3, v6, s[6:7]
 ; GISEL-NEXT:    v_mad_u64_u32 v[11:12], s[6:7], v4, v8, v[3:4]
diff --git a/llvm/test/CodeGen/AMDGPU/isel-whole-wave-functions.ll b/llvm/test/CodeGen/AMDGPU/isel-whole-wave-functions.ll
index 4c8021a878dfa7..00a3b02b2c02c7 100644
--- a/llvm/test/CodeGen/AMDGPU/isel-whole-wave-functions.ll
+++ b/llvm/test/CodeGen/AMDGPU/isel-whole-wave-functions.ll
@@ -167,18 +167,14 @@ define amdgpu_gfx_whole_wave i64 @ret_64(i1 %active, i64 %a, i64 %b) {
   ; GISEL-NEXT:   [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr2
   ; GISEL-NEXT:   [[COPY3:%[0-9]+]]:vgpr_32 = COPY $vgpr3
   ; GISEL-NEXT:   [[SI_WHOLE_WAVE_FUNC_SETUP:%[0-9]+]]:sreg_32_xm0_xexec = SI_WHOLE_WAVE_FUNC_SETUP implicit-def dead $exec, implicit $exec
-  ; GISEL-NEXT:   [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 5
-  ; GISEL-NEXT:   [[COPY4:%[0-9]+]]:vreg_64 = COPY [[S_MOV_B64_]]
-  ; GISEL-NEXT:   [[COPY5:%[0-9]+]]:vgpr_32 = COPY [[COPY4]].sub0
-  ; GISEL-NEXT:   [[COPY6:%[0-9]+]]:vgpr_32 = COPY [[COPY4]].sub1
-  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY5]], 0, [[COPY]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
-  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_1:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY6]], 0, [[COPY1]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
-  ; GISEL-NEXT:   [[S_MOV_B64_1:%[0-9]+]]:sreg_64 = S_MOV_B64 3
-  ; GISEL-NEXT:   [[COPY7:%[0-9]+]]:vreg_64 = COPY [[S_MOV_B64_1]]
-  ; GISEL-NEXT:   [[COPY8:%[0-9]+]]:vgpr_32 = COPY [[COPY7]].sub0
-  ; GISEL-NEXT:   [[COPY9:%[0-9]+]]:vgpr_32 = COPY [[COPY7]].sub1
-  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_2:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY8]], 0, [[COPY2]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
-  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_3:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[COPY9]], 0, [[COPY3]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
+  ; GISEL-NEXT:   [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 5, implicit $exec
+  ; GISEL-NEXT:   [[V_MOV_B32_e32_1:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
+  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_MOV_B32_e32_]], 0, [[COPY]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
+  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_1:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_MOV_B32_e32_1]], 0, [[COPY1]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
+  ; GISEL-NEXT:   [[V_MOV_B32_e32_2:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 3, implicit $exec
+  ; GISEL-NEXT:   [[V_MOV_B32_e32_3:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
+  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_2:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_MOV_B32_e32_2]], 0, [[COPY2]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
+  ; GISEL-NEXT:   [[V_CNDMASK_B32_e64_3:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, [[V_MOV_B32_e32_3]], 0, [[COPY3]], [[SI_WHOLE_WAVE_FUNC_SETUP]], implicit $exec
   ; GISEL-NEXT:   [[V_MOV_B32_dpp:%[0-9]+]]:vgpr_32 = V_MOV_B32_dpp [[V_CNDMASK_B32_e64_]], [[V_CNDMASK_B32_e64_2]], 1, 1, 1, 0, implicit $exec
   ; GISEL-NEXT:   [[V_MOV_B32_dpp1:%[0-9]+]]:vgpr_32 = V_MOV_B32_dpp [[V_CNDMASK_B32_e64_1]], [[V_CNDMASK_B32_e64_3]], 1, 1, 1, 0, implicit $exec
   ; GISEL-NEXT:   $vgpr0 = COPY [[V_MOV_B32_dpp]]
diff --git a/llvm/test/CodeGen/AMDGPU/itofp.i128.bf.ll b/llvm/test/CodeGen/AMDGPU/itofp.i128.bf.ll
index 4d9a7fc63331c8..e23c5757cc8b56 100644
--- a/llvm/test/CodeGen/AMDGPU/itofp.i128.bf.ll
+++ b/llvm/test/CodeGen/AMDGPU/itofp.i128.bf.ll
@@ -245,7 +245,6 @@ define bfloat @sitofp_i128_to_bf16(i128 %x) {
 ; GISEL-NEXT:    v_bfe_u32 v2, v0, 2, 1
 ; GISEL-NEXT:    v_or_b32_e32 v0, v0, v2
 ; GISEL-NEXT:    v_add_co_u32_e32 v0, vcc, 1, v0
-; GISEL-NEXT:    v_bfrev_b32_e32 v2, 32
 ; GISEL-NEXT:    v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v3, 0
 ; GISEL-NEXT:    v_and_b32_e32 v2, 0x4000000, v0
@@ -513,7 +512,6 @@ define bfloat @uitofp_i128_to_bf16(i128 %x) {
 ; GISEL-NEXT:    v_bfe_u32 v2, v0, 2, 1
 ; GISEL-NEXT:    v_or_b32_e32 v0, v0, v2
 ; GISEL-NEXT:    v_add_co_u32_e32 v0, vcc, 1, v0
-; GISEL-NEXT:    v_bfrev_b32_e32 v2, 32
 ; GISEL-NEXT:    v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v3, 0
 ; GISEL-NEXT:    v_and_b32_e32 v2, 0x4000000, v0
diff --git a/llvm/test/CodeGen/AMDGPU/itofp.i128.ll b/llvm/test/CodeGen/AMDGPU/itofp.i128.ll
index 54f16e2a586ca4..aef1ca0fb66f8f 100644
--- a/llvm/test/CodeGen/AMDGPU/itofp.i128.ll
+++ b/llvm/test/CodeGen/AMDGPU/itofp.i128.ll
@@ -238,7 +238,6 @@ define float @sitofp_i128_to_f32(i128 %x) {
 ; GISEL-NEXT:    v_bfe_u32 v2, v0, 2, 1
 ; GISEL-NEXT:    v_or_b32_e32 v0, v0, v2
 ; GISEL-NEXT:    v_add_co_u32_e32 v0, vcc, 1, v0
-; GISEL-NEXT:    v_bfrev_b32_e32 v2, 32
 ; GISEL-NEXT:    v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v3, 0
 ; GISEL-NEXT:    v_and_b32_e32 v2, 0x4000000, v0
@@ -492,7 +491,6 @@ define float @uitofp_i128_to_f32(i128 %x) {
 ; GISEL-NEXT:    v_bfe_u32 v2, v0, 2, 1
 ; GISEL-NEXT:    v_or_b32_e32 v0, v0, v2
 ; GISEL-NEXT:    v_add_co_u32_e32 v0, vcc, 1, v0
-; GISEL-NEXT:    v_bfrev_b32_e32 v2, 32
 ; GISEL-NEXT:    v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v3, 0
 ; GISEL-NEXT:    v_and_b32_e32 v2, 0x4000000, v0
@@ -795,7 +793,6 @@ define double @sitofp_i128_to_f64(i128 %x) {
 ; GISEL-NEXT:    v_or_b32_e32 v0, v2, v0
 ; GISEL-NEXT:    v_add_co_u32_e32 v2, vcc, 1, v0
 ; GISEL-NEXT:    v_addc_co_u32_e32 v3, vcc, 0, v3, vcc
-; GISEL-NEXT:    v_mov_b32_e32 v10, 0x800000
 ; GISEL-NEXT:    v_addc_co_u32_e32 v4, vcc, 0, v4, vcc
 ; GISEL-NEXT:    v_lshrrev_b64 v[0:1], 2, v[2:3]
 ; GISEL-NEXT:    v_mov_b32_e32 v9, 0
@@ -1080,7 +1077,6 @@ define double @uitofp_i128_to_f64(i128 %x) {
 ; GISEL-NEXT:    v_add_co_u32_e32 v0, vcc, 1, v0
 ; GISEL-NEXT:    v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
 ; GISEL-NEXT:    v_addc_co_u32_e32 v2, vcc, 0, v2, vcc
-; GISEL-NEXT:    v_mov_b32_e32 v9, 0x800000
 ; GISEL-NEXT:    v_addc_co_u32_e32 v3, vcc, 0, v3, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v8, 0
 ; GISEL-NEXT:    v_and_b32_e32 v9, 0x800000, v1
@@ -1361,7 +1357,6 @@ define half @sitofp_i128_to_f16(i128 %x) {
 ; GISEL-NEXT:    v_bfe_u32 v2, v0, 2, 1
 ; GISEL-NEXT:    v_or_b32_e32 v0, v0, v2
 ; GISEL-NEXT:    v_add_co_u32_e32 v0, vcc, 1, v0
-; GISEL-NEXT:    v_bfrev_b32_e32 v2, 32
 ; GISEL-NEXT:    v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v3, 0
 ; GISEL-NEXT:    v_and_b32_e32 v2, 0x4000000, v0
@@ -1617,7 +1612,6 @@ define half @uitofp_i128_to_f16(i128 %x) {
 ; GISEL-NEXT:    v_bfe_u32 v2, v0, 2, 1
 ; GISEL-NEXT:    v_or_b32_e32 v0, v0, v2
 ; GISEL-NEXT:    v_add_co_u32_e32 v0, vcc, 1, v0
-; GISEL-NEXT:    v_bfrev_b32_e32 v2, 32
 ; GISEL-NEXT:    v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
 ; GISEL-NEXT:    v_mov_b32_e32 v3, 0
 ; GISEL-NEXT:    v_and_b32_e32 v2, 0x4000000, v0
diff --git a/llvm/test/CodeGen/AMDGPU/lround.ll b/llvm/test/CodeGen/AMDGPU/lround.ll
index b2245e6904759c..15a318bfe42a8e 100644
--- a/llvm/test/CodeGen/AMDGPU/lround.ll
+++ b/llvm/test/CodeGen/AMDGPU/lround.ll
@@ -116,14 +116,14 @@ define i32 @intrinsic_lround_i32_f64(double %arg) {
 ; GFX9-GISEL:       ; %bb.0: ; %entry
 ; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; GFX9-GISEL-NEXT:    v_trunc_f64_e32 v[2:3], v[0:1]
-; GFX9-GISEL-NEXT:    v_bfrev_b32_e32 v6, -2
+; GFX9-GISEL-NEXT:    v_mov_b32_e32 v6, 0x3ff00000
+; GFX9-GISEL-NEXT:    v_bfrev_b32_e32 v7, -2
 ; GFX9-GISEL-NEXT:    v_add_f64 v[4:5], v[0:1], -v[2:3]
-; GFX9-GISEL-NEXT:    v_mov_b32_e32 v0, 0x3ff00000
 ; GFX9-GISEL-NEXT:    v_and_b32_e32 v1, 0x80000000, v1
-; GFX9-GISEL-NEXT:    v_cmp_ge_f64_e64 vcc, |v[4:5]|, 0.5
-; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v4, 0, v0, vcc
 ; GFX9-GISEL-NEXT:    v_mov_b32_e32 v0, 0
-; GFX9-GISEL-NEXT:    v_and_or_b32 v1, v4, v6, v1
+; GFX9-GISEL-NEXT:    v_cmp_ge_f64_e64 vcc, |v[4:5]|, 0.5
+; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v4, 0, v6, vcc
+; GFX9-GISEL-NEXT:    v_and_or_b32 v1, v4, v7, v1
 ; GFX9-GISEL-NEXT:    v_add_f64 v[0:1], v[2:3], v[0:1]
 ; GFX9-GISEL-NEXT:    v_cvt_i32_f64_e32 v0, v[0:1]
 ; GFX9-GISEL-NEXT:    s_setpc_b64 s[30:31]
diff --git a/llvm/test/CodeGen/AMDGPU/memset-param-combinations.ll b/llvm/test/CodeGen/AMDGPU/memset-param-combinations.ll
index b3488a1291ae81..85b2360d799695 100644
--- a/llvm/test/CodeGen/AMDGPU/memset-param-combinations.ll
+++ b/llvm/test/CodeGen/AMDGPU/memset-param-combinations.ll
@@ -59,12 +59,12 @@ define void @memset_p0_varsize_align_4_varsetval(ptr addrspace(0) align 4 %dst,
 ; GFX942-GISEL-LABEL: memset_p0_varsize_align_4_varsetval:
 ; GFX942-GISEL:       ; %bb.0: ; %entry
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[10:11], 15
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v10, 15, v3
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v12, vcc, v3, v10
-; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v11, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v13, vcc, 0, v4, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[12:13]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[2:3], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB0_3
@@ -181,12 +181,12 @@ define void @memset_p1_varsize_align_4_varsetval(ptr addrspace(1) align 4 %dst,
 ; GFX942-GISEL-LABEL: memset_p1_varsize_align_4_varsetval:
 ; GFX942-GISEL:       ; %bb.0: ; %entry
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[10:11], 15
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v10, 15, v3
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v12, vcc, v3, v10
-; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v11, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v13, vcc, 0, v4, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[12:13]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[2:3], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB1_3
@@ -301,12 +301,12 @@ define void @memset_p3_varsize_align_4_varsetval(ptr addrspace(3) align 4 %dst,
 ; GFX942-GISEL-LABEL: memset_p3_varsize_align_4_varsetval:
 ; GFX942-GISEL:       ; %bb.0: ; %entry
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[4:5], 15
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v4, 15, v2
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v6, vcc, v2, v4
-; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v5, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v7, vcc, 0, v3, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[6:7]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[2:3], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB2_3
@@ -417,12 +417,12 @@ define void @memset_p5_varsize_align_4_varsetval(ptr addrspace(5) align 4 %dst,
 ; GFX942-GISEL-LABEL: memset_p5_varsize_align_4_varsetval:
 ; GFX942-GISEL:       ; %bb.0: ; %entry
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[8:9], 15
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v8, 15, v2
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v10, vcc, v2, v8
-; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v9, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v11, vcc, 0, v3, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[10:11]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[2:3], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB3_3
@@ -1396,12 +1396,12 @@ define void @memset_p1_varsz_align_4_set40(ptr addrspace(1) align 4 %dst, i64 %s
 ; GFX942-GISEL-LABEL: memset_p1_varsz_align_4_set40:
 ; GFX942-GISEL:       ; %bb.0: ; %entry
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[8:9], 15
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v8, 15, v2
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v10, vcc, v2, v8
-; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v9, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v11, vcc, 0, v3, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[10:11]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[2:3], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB12_3
@@ -1516,12 +1516,12 @@ define void @memset_p1_varsz_align_4_set0(ptr addrspace(1) align 4 %dst, i64 %si
 ; GFX942-GISEL-LABEL: memset_p1_varsz_align_4_set0:
 ; GFX942-GISEL:       ; %bb.0: ; %entry
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[8:9], 15
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v8, 15, v2
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v10, vcc, v2, v8
-; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v9, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v11, vcc, 0, v3, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[0:1], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[10:11]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[2:3], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB13_3
diff --git a/llvm/test/CodeGen/AMDGPU/memset-pattern.ll b/llvm/test/CodeGen/AMDGPU/memset-pattern.ll
index b05ea728b8ddf1..2cf0f05c845b1f 100644
--- a/llvm/test/CodeGen/AMDGPU/memset-pattern.ll
+++ b/llvm/test/CodeGen/AMDGPU/memset-pattern.ll
@@ -494,12 +494,12 @@ define void @memset_pattern_i32_dynlen(ptr addrspace(1) align 16 %a, i64 %len) {
 ; GFX942-GISEL-LABEL: memset_pattern_i32_dynlen:
 ; GFX942-GISEL:       ; %bb.0:
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[8:9], 3
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v8, 3, v2
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v10, vcc, v2, v8
-; GFX942-GISEL-NEXT:    s_mov_b64 s[2:3], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v9, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v11, vcc, 0, v3, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[2:3], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[10:11]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[4:5], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB9_3
@@ -613,13 +613,13 @@ define void @memset_pattern_i32_dynval_dynlen(ptr addrspace(1) align 16 %a, i32
 ; GFX942-GISEL:       ; %bb.0:
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; GFX942-GISEL-NEXT:    v_mov_b32_e32 v8, v3
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[6:7], 3
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v6, 3, v8
 ; GFX942-GISEL-NEXT:    v_mov_b32_e32 v9, v4
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v10, vcc, v8, v6
-; GFX942-GISEL-NEXT:    s_mov_b64 s[2:3], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v7, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v11, vcc, 0, v9, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[2:3], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[10:11]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[4:5], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB10_3
@@ -789,13 +789,13 @@ define void @memset_pattern_i64_as7_dynlen(ptr addrspace(7) inreg align 16 %a, i
 ; GFX942-GISEL:       ; %bb.0:
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; GFX942-GISEL-NEXT:    v_mov_b32_e32 v8, v1
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[6:7], 1
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v6, 1, v8
 ; GFX942-GISEL-NEXT:    v_mov_b32_e32 v9, v2
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v10, vcc, v8, v6
-; GFX942-GISEL-NEXT:    s_mov_b64 s[4:5], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v7, 0
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v11, vcc, 0, v9, vcc
+; GFX942-GISEL-NEXT:    s_mov_b64 s[4:5], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[10:11]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[6:7], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB12_3
@@ -909,14 +909,14 @@ define void @memset_pattern_i64_as7_dynlen_dynval(ptr addrspace(7) inreg align 1
 ; GFX942-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; GFX942-GISEL-NEXT:    v_mov_b32_e32 v6, v1
 ; GFX942-GISEL-NEXT:    v_mov_b32_e32 v7, v2
-; GFX942-GISEL-NEXT:    v_mov_b32_e32 v8, v3
-; GFX942-GISEL-NEXT:    v_mov_b64_e32 v[2:3], 1
 ; GFX942-GISEL-NEXT:    v_and_b32_e32 v2, 1, v6
 ; GFX942-GISEL-NEXT:    v_mov_b32_e32 v9, v4
 ; GFX942-GISEL-NEXT:    v_sub_co_u32_e32 v4, vcc, v6, v2
-; GFX942-GISEL-NEXT:    s_mov_b64 s[4:5], 0
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v8, v3
 ; GFX942-GISEL-NEXT:    s_nop 0
 ; GFX942-GISEL-NEXT:    v_subbrev_co_u32_e32 v5, vcc, 0, v7, vcc
+; GFX942-GISEL-NEXT:    v_mov_b32_e32 v3, 0
+; GFX942-GISEL-NEXT:    s_mov_b64 s[4:5], 0
 ; GFX942-GISEL-NEXT:    v_cmp_ne_u64_e32 vcc, 0, v[4:5]
 ; GFX942-GISEL-NEXT:    s_and_saveexec_b64 s[6:7], vcc
 ; GFX942-GISEL-NEXT:    s_cbranch_execz .LBB13_3



More information about the llvm-branch-commits mailing list