Index: llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp @@ -1138,6 +1138,9 @@ Value *AMDGPUCodeGenPrepare::shrinkDivRem64(IRBuilder<> &Builder, BinaryOperator &I, Value *Num, Value *Den) const { + if (!ExpandDiv64InIR && divHasSpecialOptimization(I, Num, Den)) + return nullptr; // Keep it for later optimization. + Instruction::BinaryOps Opc = I.getOpcode(); bool IsDiv = Opc == Instruction::SDiv || Opc == Instruction::UDiv; Index: llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-idiv.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-idiv.ll +++ llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-idiv.ll @@ -5505,8 +5505,13 @@ define amdgpu_kernel void @udiv_v2i64_pow2k_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x) { ; CHECK-LABEL: @udiv_v2i64_pow2k_denom( -; CHECK-NEXT: [[R:%.*]] = udiv <2 x i64> [[X:%.*]], -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = udiv i64 [[TMP1]], 4096 +; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> undef, i64 [[TMP2]], i64 0 +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP5:%.*]] = udiv i64 [[TMP4]], 4096 +; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: udiv_v2i64_pow2k_denom: @@ -5516,8 +5521,8 @@ ; GCN-NEXT: s_mov_b32 s7, 0xf000 ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_lshr_b64 s[2:3], s[2:3], 12 ; GCN-NEXT: s_lshr_b64 s[0:1], s[0:1], 12 +; GCN-NEXT: s_lshr_b64 s[2:3], s[2:3], 12 ; GCN-NEXT: v_mov_b32_e32 v0, s0 ; GCN-NEXT: v_mov_b32_e32 v1, s1 ; GCN-NEXT: v_mov_b32_e32 v2, s2 @@ -5531,8 +5536,13 @@ define amdgpu_kernel void @udiv_v2i64_mixed_pow2k_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x) { ; CHECK-LABEL: @udiv_v2i64_mixed_pow2k_denom( -; CHECK-NEXT: [[R:%.*]] = udiv <2 x i64> [[X:%.*]], -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = udiv i64 [[TMP1]], 4096 +; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> undef, i64 [[TMP2]], i64 0 +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP5:%.*]] = udiv i64 [[TMP4]], 4095 +; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: udiv_v2i64_mixed_pow2k_denom: @@ -5540,7 +5550,7 @@ ; GCN-NEXT: v_mov_b32_e32 v0, 0x4f800000 ; GCN-NEXT: v_madak_f32 v0, 0, v0, 0x457ff000 ; GCN-NEXT: v_rcp_f32_e32 v0, v0 -; GCN-NEXT: s_movk_i32 s4, 0xf001 +; GCN-NEXT: s_movk_i32 s6, 0xf001 ; GCN-NEXT: v_mov_b32_e32 v7, 0 ; GCN-NEXT: v_mov_b32_e32 v2, 0 ; GCN-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0 @@ -5549,11 +5559,13 @@ ; GCN-NEXT: v_mac_f32_e32 v0, 0xcf800000, v1 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1 +; GCN-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9 +; GCN-NEXT: s_load_dwordx4 s[8:11], s[0:1], 0xd +; GCN-NEXT: s_movk_i32 s0, 0xfff +; GCN-NEXT: v_mul_hi_u32 v3, v0, s6 +; GCN-NEXT: v_mul_lo_u32 v5, v1, s6 +; GCN-NEXT: v_mul_lo_u32 v4, v0, s6 ; GCN-NEXT: s_mov_b32 s7, 0xf000 -; GCN-NEXT: s_mov_b32 s6, -1 -; GCN-NEXT: v_mul_hi_u32 v3, v0, s4 -; GCN-NEXT: v_mul_lo_u32 v5, v1, s4 -; GCN-NEXT: v_mul_lo_u32 v4, v0, s4 ; GCN-NEXT: v_subrev_i32_e32 v3, vcc, v0, v3 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v5, v3 ; GCN-NEXT: v_mul_hi_u32 v6, v0, v4 @@ -5571,19 +5583,17 @@ ; GCN-NEXT: v_add_i32_e32 v3, vcc, v4, v3 ; GCN-NEXT: v_add_i32_e64 v0, s[2:3], v0, v3 ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v7, v5, vcc -; GCN-NEXT: v_mul_hi_u32 v5, v0, s4 +; GCN-NEXT: v_mul_hi_u32 v5, v0, s6 ; GCN-NEXT: v_addc_u32_e64 v3, vcc, v1, v4, s[2:3] -; GCN-NEXT: v_mul_lo_u32 v6, v3, s4 -; GCN-NEXT: v_mul_lo_u32 v8, v0, s4 +; GCN-NEXT: v_mul_lo_u32 v6, v3, s6 +; GCN-NEXT: v_mul_lo_u32 v8, v0, s6 ; GCN-NEXT: v_subrev_i32_e32 v5, vcc, v0, v5 -; GCN-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9 -; GCN-NEXT: s_load_dwordx4 s[8:11], s[0:1], 0xd +; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v5, v6 ; GCN-NEXT: v_mul_lo_u32 v6, v0, v5 ; GCN-NEXT: v_mul_hi_u32 v9, v0, v8 ; GCN-NEXT: v_mul_hi_u32 v10, v0, v5 ; GCN-NEXT: v_mul_hi_u32 v11, v3, v5 -; GCN-NEXT: s_movk_i32 s0, 0xfff ; GCN-NEXT: v_add_i32_e32 v6, vcc, v9, v6 ; GCN-NEXT: v_addc_u32_e32 v9, vcc, v7, v10, vcc ; GCN-NEXT: v_mul_lo_u32 v10, v3, v8 @@ -5608,6 +5618,7 @@ ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v7, v5, vcc ; GCN-NEXT: v_mul_lo_u32 v5, s11, v0 ; GCN-NEXT: v_mul_hi_u32 v0, s11, v0 +; GCN-NEXT: s_lshr_b64 s[2:3], s[8:9], 12 ; GCN-NEXT: v_add_i32_e32 v3, vcc, v5, v3 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, v4, v0, vcc ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v6, v2, vcc @@ -5641,9 +5652,8 @@ ; GCN-NEXT: v_cndmask_b32_e64 v3, v1, v3, s[0:1] ; GCN-NEXT: v_cndmask_b32_e32 v1, v7, v5, vcc ; GCN-NEXT: v_cndmask_b32_e64 v2, v0, v1, s[0:1] -; GCN-NEXT: s_lshr_b64 s[0:1], s[8:9], 12 -; GCN-NEXT: v_mov_b32_e32 v0, s0 -; GCN-NEXT: v_mov_b32_e32 v1, s1 +; GCN-NEXT: v_mov_b32_e32 v0, s2 +; GCN-NEXT: v_mov_b32_e32 v1, s3 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0 ; GCN-NEXT: s_endpgm %r = udiv <2 x i64> %x, @@ -5654,8 +5664,15 @@ define amdgpu_kernel void @udiv_v2i64_pow2_shl_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x, <2 x i64> %y) { ; CHECK-LABEL: @udiv_v2i64_pow2_shl_denom( ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> , [[Y:%.*]] -; CHECK-NEXT: [[R:%.*]] = udiv <2 x i64> [[X:%.*]], [[SHL_Y]] -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0 +; CHECK-NEXT: [[TMP3:%.*]] = udiv i64 [[TMP1]], [[TMP2]] +; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> undef, i64 [[TMP3]], i64 0 +; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1 +; CHECK-NEXT: [[TMP7:%.*]] = udiv i64 [[TMP5]], [[TMP6]] +; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP8]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: udiv_v2i64_pow2_shl_denom: @@ -5666,10 +5683,10 @@ ; GCN-NEXT: s_mov_b32 s7, 0xf000 ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_add_i32 s1, s2, 12 ; GCN-NEXT: s_add_i32 s0, s0, 12 -; GCN-NEXT: s_lshr_b64 s[2:3], s[10:11], s1 +; GCN-NEXT: s_add_i32 s2, s2, 12 ; GCN-NEXT: s_lshr_b64 s[0:1], s[8:9], s0 +; GCN-NEXT: s_lshr_b64 s[2:3], s[10:11], s2 ; GCN-NEXT: v_mov_b32_e32 v0, s0 ; GCN-NEXT: v_mov_b32_e32 v1, s1 ; GCN-NEXT: v_mov_b32_e32 v2, s2 @@ -5874,8 +5891,13 @@ define amdgpu_kernel void @urem_v2i64_pow2k_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x) { ; CHECK-LABEL: @urem_v2i64_pow2k_denom( -; CHECK-NEXT: [[R:%.*]] = urem <2 x i64> [[X:%.*]], -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = urem i64 [[TMP1]], 4096 +; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> undef, i64 [[TMP2]], i64 0 +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP5:%.*]] = urem i64 [[TMP4]], 4096 +; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: urem_v2i64_pow2k_denom: @@ -5887,8 +5909,8 @@ ; GCN-NEXT: s_mov_b32 s7, 0xf000 ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_and_b32 s1, s2, s8 ; GCN-NEXT: s_and_b32 s0, s0, s8 +; GCN-NEXT: s_and_b32 s1, s2, s8 ; GCN-NEXT: v_mov_b32_e32 v0, s0 ; GCN-NEXT: v_mov_b32_e32 v2, s1 ; GCN-NEXT: v_mov_b32_e32 v3, v1 @@ -5902,8 +5924,15 @@ define amdgpu_kernel void @urem_v2i64_pow2_shl_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x, <2 x i64> %y) { ; CHECK-LABEL: @urem_v2i64_pow2_shl_denom( ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> , [[Y:%.*]] -; CHECK-NEXT: [[R:%.*]] = urem <2 x i64> [[X:%.*]], [[SHL_Y]] -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0 +; CHECK-NEXT: [[TMP3:%.*]] = urem i64 [[TMP1]], [[TMP2]] +; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> undef, i64 [[TMP3]], i64 0 +; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1 +; CHECK-NEXT: [[TMP7:%.*]] = urem i64 [[TMP5]], [[TMP6]] +; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP8]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: urem_v2i64_pow2_shl_denom: @@ -5916,14 +5945,14 @@ ; GCN-NEXT: s_mov_b32 s7, 0xf000 ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_lshl_b64 s[0:1], s[12:13], s0 ; GCN-NEXT: s_lshl_b64 s[2:3], s[12:13], s2 -; GCN-NEXT: s_add_u32 s2, s2, -1 -; GCN-NEXT: s_addc_u32 s3, s3, -1 -; GCN-NEXT: s_and_b64 s[2:3], s[10:11], s[2:3] +; GCN-NEXT: s_lshl_b64 s[0:1], s[12:13], s0 ; GCN-NEXT: s_add_u32 s0, s0, -1 ; GCN-NEXT: s_addc_u32 s1, s1, -1 ; GCN-NEXT: s_and_b64 s[0:1], s[8:9], s[0:1] +; GCN-NEXT: s_add_u32 s2, s2, -1 +; GCN-NEXT: s_addc_u32 s3, s3, -1 +; GCN-NEXT: s_and_b64 s[2:3], s[10:11], s[2:3] ; GCN-NEXT: v_mov_b32_e32 v0, s0 ; GCN-NEXT: v_mov_b32_e32 v1, s1 ; GCN-NEXT: v_mov_b32_e32 v2, s2 @@ -6249,8 +6278,13 @@ define amdgpu_kernel void @sdiv_v2i64_pow2k_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x) { ; CHECK-LABEL: @sdiv_v2i64_pow2k_denom( -; CHECK-NEXT: [[R:%.*]] = sdiv <2 x i64> [[X:%.*]], -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = sdiv i64 [[TMP1]], 4096 +; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> undef, i64 [[TMP2]], i64 0 +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP5:%.*]] = sdiv i64 [[TMP4]], 4096 +; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: sdiv_v2i64_pow2k_denom: @@ -6260,16 +6294,16 @@ ; GCN-NEXT: s_mov_b32 s7, 0xf000 ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_ashr_i32 s8, s3, 31 -; GCN-NEXT: s_lshr_b32 s8, s8, 20 -; GCN-NEXT: s_add_u32 s2, s2, s8 -; GCN-NEXT: s_addc_u32 s3, s3, 0 ; GCN-NEXT: s_ashr_i32 s8, s1, 31 -; GCN-NEXT: s_ashr_i64 s[2:3], s[2:3], 12 ; GCN-NEXT: s_lshr_b32 s8, s8, 20 ; GCN-NEXT: s_add_u32 s0, s0, s8 ; GCN-NEXT: s_addc_u32 s1, s1, 0 +; GCN-NEXT: s_ashr_i32 s8, s3, 31 ; GCN-NEXT: s_ashr_i64 s[0:1], s[0:1], 12 +; GCN-NEXT: s_lshr_b32 s8, s8, 20 +; GCN-NEXT: s_add_u32 s2, s2, s8 +; GCN-NEXT: s_addc_u32 s3, s3, 0 +; GCN-NEXT: s_ashr_i64 s[2:3], s[2:3], 12 ; GCN-NEXT: v_mov_b32_e32 v0, s0 ; GCN-NEXT: v_mov_b32_e32 v1, s1 ; GCN-NEXT: v_mov_b32_e32 v2, s2 @@ -6283,101 +6317,112 @@ define amdgpu_kernel void @ssdiv_v2i64_mixed_pow2k_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x) { ; CHECK-LABEL: @ssdiv_v2i64_mixed_pow2k_denom( -; CHECK-NEXT: [[R:%.*]] = sdiv <2 x i64> [[X:%.*]], -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = sdiv i64 [[TMP1]], 4096 +; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> undef, i64 [[TMP2]], i64 0 +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP5:%.*]] = sdiv i64 [[TMP4]], 4095 +; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: ssdiv_v2i64_mixed_pow2k_denom: ; GCN: ; %bb.0: -; GCN-NEXT: v_mov_b32_e32 v0, 0x4f800000 -; GCN-NEXT: v_madak_f32 v0, 0, v0, 0x457ff000 +; GCN-NEXT: v_mov_b32_e32 v0, 0x457ff000 +; GCN-NEXT: v_mov_b32_e32 v1, 0x4f800000 +; GCN-NEXT: v_mac_f32_e32 v0, 0, v1 ; GCN-NEXT: v_rcp_f32_e32 v0, v0 ; GCN-NEXT: s_movk_i32 s6, 0xf001 -; GCN-NEXT: v_mov_b32_e32 v7, 0 -; GCN-NEXT: v_mov_b32_e32 v5, 0 +; GCN-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9 +; GCN-NEXT: s_load_dwordx4 s[8:11], s[0:1], 0xd +; GCN-NEXT: s_mov_b32 s7, 0xf000 ; GCN-NEXT: v_mul_f32_e32 v0, 0x5f7ffffc, v0 ; GCN-NEXT: v_mul_f32_e32 v1, 0x2f800000, v0 ; GCN-NEXT: v_trunc_f32_e32 v1, v1 ; GCN-NEXT: v_mac_f32_e32 v0, 0xcf800000, v1 ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1 -; GCN-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9 -; GCN-NEXT: s_load_dwordx4 s[8:11], s[0:1], 0xd -; GCN-NEXT: s_mov_b32 s7, 0xf000 -; GCN-NEXT: v_mul_hi_u32 v3, s6, v0 -; GCN-NEXT: v_mul_lo_u32 v2, v1, s6 -; GCN-NEXT: v_mul_lo_u32 v4, v0, s6 -; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 +; GCN-NEXT: s_waitcnt lgkmcnt(0) +; GCN-NEXT: s_ashr_i32 s0, s9, 31 +; GCN-NEXT: s_lshr_b32 s0, s0, 20 +; GCN-NEXT: v_mul_hi_u32 v2, s6, v0 +; GCN-NEXT: v_mul_lo_u32 v3, v1, s6 +; GCN-NEXT: s_add_u32 s2, s8, s0 +; GCN-NEXT: s_addc_u32 s3, s9, 0 +; GCN-NEXT: s_ashr_i32 s8, s11, 31 +; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3 +; GCN-NEXT: v_mul_lo_u32 v3, v0, s6 ; GCN-NEXT: v_subrev_i32_e32 v2, vcc, v0, v2 -; GCN-NEXT: v_mul_hi_u32 v3, v0, v4 -; GCN-NEXT: v_mul_lo_u32 v6, v0, v2 -; GCN-NEXT: v_mul_hi_u32 v8, v0, v2 -; GCN-NEXT: v_mul_hi_u32 v9, v1, v2 +; GCN-NEXT: v_mul_lo_u32 v4, v0, v2 +; GCN-NEXT: v_mul_hi_u32 v6, v0, v2 +; GCN-NEXT: v_mul_hi_u32 v5, v0, v3 +; GCN-NEXT: v_mul_hi_u32 v7, v1, v2 ; GCN-NEXT: v_mul_lo_u32 v2, v1, v2 -; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v6 -; GCN-NEXT: v_addc_u32_e32 v6, vcc, v7, v8, vcc -; GCN-NEXT: v_mul_lo_u32 v8, v1, v4 -; GCN-NEXT: v_mul_hi_u32 v4, v1, v4 -; GCN-NEXT: v_add_i32_e32 v3, vcc, v8, v3 -; GCN-NEXT: v_addc_u32_e32 v3, vcc, v6, v4, vcc -; GCN-NEXT: v_addc_u32_e32 v4, vcc, v9, v5, vcc -; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 -; GCN-NEXT: v_add_i32_e64 v0, s[2:3], v0, v2 -; GCN-NEXT: v_addc_u32_e32 v3, vcc, v7, v4, vcc -; GCN-NEXT: v_addc_u32_e64 v2, vcc, v1, v3, s[2:3] -; GCN-NEXT: v_mul_lo_u32 v4, v2, s6 -; GCN-NEXT: v_mul_hi_u32 v6, s6, v0 +; GCN-NEXT: s_ashr_i64 s[2:3], s[2:3], 12 +; GCN-NEXT: v_add_i32_e32 v4, vcc, v5, v4 +; GCN-NEXT: v_addc_u32_e32 v5, vcc, 0, v6, vcc +; GCN-NEXT: v_mul_lo_u32 v6, v1, v3 +; GCN-NEXT: v_mul_hi_u32 v3, v1, v3 +; GCN-NEXT: s_mov_b32 s9, s8 ; GCN-NEXT: v_add_i32_e32 v4, vcc, v6, v4 -; GCN-NEXT: v_mul_lo_u32 v6, v0, s6 -; GCN-NEXT: v_subrev_i32_e32 v4, vcc, v0, v4 -; GCN-NEXT: v_mul_lo_u32 v10, v0, v4 -; GCN-NEXT: v_mul_hi_u32 v12, v0, v4 -; GCN-NEXT: v_mul_hi_u32 v11, v0, v6 -; GCN-NEXT: v_mul_hi_u32 v9, v2, v6 -; GCN-NEXT: v_mul_lo_u32 v6, v2, v6 -; GCN-NEXT: v_mul_hi_u32 v8, v2, v4 +; GCN-NEXT: v_addc_u32_e32 v3, vcc, v5, v3, vcc +; GCN-NEXT: v_mov_b32_e32 v4, 0 +; GCN-NEXT: v_addc_u32_e32 v5, vcc, v7, v4, vcc +; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 +; GCN-NEXT: v_mov_b32_e32 v6, 0 +; GCN-NEXT: v_add_i32_e64 v0, s[0:1], v0, v2 +; GCN-NEXT: v_addc_u32_e32 v3, vcc, v6, v5, vcc +; GCN-NEXT: v_addc_u32_e64 v2, vcc, v1, v3, s[0:1] +; GCN-NEXT: v_mul_lo_u32 v5, v2, s6 +; GCN-NEXT: v_mul_hi_u32 v7, s6, v0 +; GCN-NEXT: v_add_i32_e32 v5, vcc, v7, v5 +; GCN-NEXT: v_mul_lo_u32 v7, v0, s6 +; GCN-NEXT: v_subrev_i32_e32 v5, vcc, v0, v5 +; GCN-NEXT: v_mul_lo_u32 v10, v0, v5 +; GCN-NEXT: v_mul_hi_u32 v12, v0, v5 +; GCN-NEXT: v_mul_hi_u32 v11, v0, v7 +; GCN-NEXT: v_mul_hi_u32 v9, v2, v7 +; GCN-NEXT: v_mul_lo_u32 v7, v2, v7 +; GCN-NEXT: v_mul_hi_u32 v8, v2, v5 ; GCN-NEXT: v_add_i32_e32 v10, vcc, v11, v10 -; GCN-NEXT: v_addc_u32_e32 v11, vcc, v7, v12, vcc -; GCN-NEXT: v_mul_lo_u32 v2, v2, v4 -; GCN-NEXT: v_add_i32_e32 v6, vcc, v6, v10 -; GCN-NEXT: v_addc_u32_e32 v6, vcc, v11, v9, vcc -; GCN-NEXT: v_addc_u32_e32 v4, vcc, v8, v5, vcc -; GCN-NEXT: v_add_i32_e32 v2, vcc, v6, v2 -; GCN-NEXT: v_addc_u32_e32 v4, vcc, v7, v4, vcc +; GCN-NEXT: v_addc_u32_e32 v11, vcc, 0, v12, vcc +; GCN-NEXT: v_mul_lo_u32 v2, v2, v5 +; GCN-NEXT: v_add_i32_e32 v7, vcc, v7, v10 +; GCN-NEXT: v_addc_u32_e32 v7, vcc, v11, v9, vcc +; GCN-NEXT: v_addc_u32_e32 v5, vcc, v8, v4, vcc +; GCN-NEXT: v_add_i32_e32 v2, vcc, v7, v2 +; GCN-NEXT: v_addc_u32_e32 v5, vcc, v6, v5, vcc ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v3 -; GCN-NEXT: v_addc_u32_e64 v1, vcc, v1, v4, s[2:3] -; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_ashr_i32 s2, s11, 31 -; GCN-NEXT: s_add_u32 s0, s10, s2 +; GCN-NEXT: v_addc_u32_e64 v1, vcc, v1, v5, s[0:1] +; GCN-NEXT: s_add_u32 s0, s10, s8 +; GCN-NEXT: s_addc_u32 s1, s11, s8 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2 -; GCN-NEXT: s_mov_b32 s3, s2 -; GCN-NEXT: s_addc_u32 s1, s11, s2 -; GCN-NEXT: s_xor_b64 s[0:1], s[0:1], s[2:3] +; GCN-NEXT: s_xor_b64 s[0:1], s[0:1], s[8:9] ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc ; GCN-NEXT: v_mul_lo_u32 v2, s0, v1 ; GCN-NEXT: v_mul_hi_u32 v3, s0, v0 -; GCN-NEXT: v_mul_hi_u32 v4, s0, v1 -; GCN-NEXT: v_mul_hi_u32 v6, s1, v1 +; GCN-NEXT: v_mul_hi_u32 v5, s0, v1 +; GCN-NEXT: v_mul_hi_u32 v7, s1, v1 ; GCN-NEXT: v_mul_lo_u32 v1, s1, v1 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 -; GCN-NEXT: v_addc_u32_e32 v3, vcc, v7, v4, vcc -; GCN-NEXT: v_mul_lo_u32 v4, s1, v0 +; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v5, vcc +; GCN-NEXT: v_mul_lo_u32 v5, s1, v0 ; GCN-NEXT: v_mul_hi_u32 v0, s1, v0 -; GCN-NEXT: s_movk_i32 s3, 0xfff +; GCN-NEXT: s_movk_i32 s9, 0xfff ; GCN-NEXT: s_mov_b32 s6, -1 -; GCN-NEXT: v_add_i32_e32 v2, vcc, v4, v2 +; GCN-NEXT: v_add_i32_e32 v2, vcc, v5, v2 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc -; GCN-NEXT: v_addc_u32_e32 v2, vcc, v6, v5, vcc +; GCN-NEXT: v_addc_u32_e32 v2, vcc, v7, v4, vcc ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v1 -; GCN-NEXT: v_addc_u32_e32 v1, vcc, v7, v2, vcc -; GCN-NEXT: v_mul_lo_u32 v2, v1, s3 -; GCN-NEXT: v_mul_hi_u32 v3, s3, v0 -; GCN-NEXT: v_mul_lo_u32 v4, v0, s3 +; GCN-NEXT: v_addc_u32_e32 v1, vcc, v6, v2, vcc +; GCN-NEXT: v_mul_lo_u32 v2, v1, s9 +; GCN-NEXT: v_mul_hi_u32 v3, s9, v0 +; GCN-NEXT: v_mul_lo_u32 v4, v0, s9 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 ; GCN-NEXT: v_sub_i32_e32 v4, vcc, s0, v4 ; GCN-NEXT: v_mov_b32_e32 v3, s1 ; GCN-NEXT: v_subb_u32_e32 v2, vcc, v3, v2, vcc -; GCN-NEXT: v_subrev_i32_e32 v3, vcc, s3, v4 +; GCN-NEXT: v_subrev_i32_e32 v3, vcc, s9, v4 ; GCN-NEXT: v_subbrev_u32_e32 v5, vcc, 0, v2, vcc ; GCN-NEXT: s_movk_i32 s0, 0xffe ; GCN-NEXT: v_cmp_lt_u32_e32 vcc, s0, v3 @@ -6394,22 +6439,17 @@ ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3 ; GCN-NEXT: v_cndmask_b32_e64 v2, -1, v4, s[0:1] ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v2 -; GCN-NEXT: v_cndmask_b32_e32 v3, v8, v6, vcc ; GCN-NEXT: v_cndmask_b32_e32 v2, v7, v5, vcc -; GCN-NEXT: v_cndmask_b32_e64 v1, v1, v3, s[0:1] ; GCN-NEXT: v_cndmask_b32_e64 v0, v0, v2, s[0:1] -; GCN-NEXT: s_ashr_i32 s0, s9, 31 -; GCN-NEXT: s_lshr_b32 s0, s0, 20 -; GCN-NEXT: s_add_u32 s0, s8, s0 -; GCN-NEXT: s_addc_u32 s1, s9, 0 -; GCN-NEXT: v_xor_b32_e32 v0, s2, v0 -; GCN-NEXT: v_xor_b32_e32 v1, s2, v1 -; GCN-NEXT: v_mov_b32_e32 v3, s2 -; GCN-NEXT: v_subrev_i32_e32 v2, vcc, s2, v0 -; GCN-NEXT: s_ashr_i64 s[0:1], s[0:1], 12 +; GCN-NEXT: v_cndmask_b32_e32 v3, v8, v6, vcc +; GCN-NEXT: v_cndmask_b32_e64 v1, v1, v3, s[0:1] +; GCN-NEXT: v_xor_b32_e32 v0, s8, v0 +; GCN-NEXT: v_subrev_i32_e32 v2, vcc, s8, v0 +; GCN-NEXT: v_xor_b32_e32 v1, s8, v1 +; GCN-NEXT: v_mov_b32_e32 v3, s8 ; GCN-NEXT: v_subb_u32_e32 v3, vcc, v1, v3, vcc -; GCN-NEXT: v_mov_b32_e32 v0, s0 -; GCN-NEXT: v_mov_b32_e32 v1, s1 +; GCN-NEXT: v_mov_b32_e32 v0, s2 +; GCN-NEXT: v_mov_b32_e32 v1, s3 ; GCN-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0 ; GCN-NEXT: s_endpgm %r = sdiv <2 x i64> %x, @@ -6420,8 +6460,15 @@ define amdgpu_kernel void @sdiv_v2i64_pow2_shl_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x, <2 x i64> %y) { ; CHECK-LABEL: @sdiv_v2i64_pow2_shl_denom( ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> , [[Y:%.*]] -; CHECK-NEXT: [[R:%.*]] = sdiv <2 x i64> [[X:%.*]], [[SHL_Y]] -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0 +; CHECK-NEXT: [[TMP3:%.*]] = sdiv i64 [[TMP1]], [[TMP2]] +; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> undef, i64 [[TMP3]], i64 0 +; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1 +; CHECK-NEXT: [[TMP7:%.*]] = sdiv i64 [[TMP5]], [[TMP6]] +; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP8]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: sdiv_v2i64_pow2_shl_denom: @@ -6432,8 +6479,8 @@ ; GCN-NEXT: s_mov_b32 s18, 0x4f800000 ; GCN-NEXT: s_mov_b32 s19, 0x5f7ffffc ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_lshl_b64 s[12:13], s[2:3], s4 -; GCN-NEXT: s_lshl_b64 s[2:3], s[2:3], s6 +; GCN-NEXT: s_lshl_b64 s[12:13], s[2:3], s6 +; GCN-NEXT: s_lshl_b64 s[2:3], s[2:3], s4 ; GCN-NEXT: s_ashr_i32 s16, s3, 31 ; GCN-NEXT: s_add_u32 s2, s2, s16 ; GCN-NEXT: s_mov_b32 s17, s16 @@ -6503,22 +6550,22 @@ ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v3 ; GCN-NEXT: v_addc_u32_e64 v1, vcc, v1, v5, s[2:3] ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_ashr_i32 s2, s11, 31 -; GCN-NEXT: s_add_u32 s0, s10, s2 +; GCN-NEXT: s_ashr_i32 s2, s9, 31 +; GCN-NEXT: s_add_u32 s0, s8, s2 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2 ; GCN-NEXT: s_mov_b32 s3, s2 -; GCN-NEXT: s_addc_u32 s1, s11, s2 -; GCN-NEXT: s_xor_b64 s[10:11], s[0:1], s[2:3] +; GCN-NEXT: s_addc_u32 s1, s9, s2 +; GCN-NEXT: s_xor_b64 s[8:9], s[0:1], s[2:3] ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc -; GCN-NEXT: v_mul_lo_u32 v2, s10, v1 -; GCN-NEXT: v_mul_hi_u32 v3, s10, v0 -; GCN-NEXT: v_mul_hi_u32 v5, s10, v1 -; GCN-NEXT: v_mul_hi_u32 v7, s11, v1 -; GCN-NEXT: v_mul_lo_u32 v1, s11, v1 +; GCN-NEXT: v_mul_lo_u32 v2, s8, v1 +; GCN-NEXT: v_mul_hi_u32 v3, s8, v0 +; GCN-NEXT: v_mul_hi_u32 v5, s8, v1 +; GCN-NEXT: v_mul_hi_u32 v7, s9, v1 +; GCN-NEXT: v_mul_lo_u32 v1, s9, v1 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v5, vcc -; GCN-NEXT: v_mul_lo_u32 v5, s11, v0 -; GCN-NEXT: v_mul_hi_u32 v0, s11, v0 +; GCN-NEXT: v_mul_lo_u32 v5, s9, v0 +; GCN-NEXT: v_mul_hi_u32 v0, s9, v0 ; GCN-NEXT: s_xor_b64 s[2:3], s[2:3], s[16:17] ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v5, v2 @@ -6533,8 +6580,8 @@ ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 ; GCN-NEXT: v_mul_lo_u32 v3, s14, v0 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v5 -; GCN-NEXT: v_sub_i32_e32 v5, vcc, s11, v2 -; GCN-NEXT: v_sub_i32_e32 v3, vcc, s10, v3 +; GCN-NEXT: v_sub_i32_e32 v5, vcc, s9, v2 +; GCN-NEXT: v_sub_i32_e32 v3, vcc, s8, v3 ; GCN-NEXT: v_subb_u32_e64 v5, s[0:1], v5, v7, vcc ; GCN-NEXT: v_subrev_i32_e64 v7, s[0:1], s14, v3 ; GCN-NEXT: v_subbrev_u32_e64 v5, s[0:1], 0, v5, s[0:1] @@ -6548,14 +6595,14 @@ ; GCN-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v1, s[0:1] ; GCN-NEXT: v_add_i32_e64 v9, s[0:1], 1, v0 ; GCN-NEXT: v_addc_u32_e64 v10, s[0:1], 0, v1, s[0:1] -; GCN-NEXT: s_ashr_i32 s10, s13, 31 +; GCN-NEXT: s_ashr_i32 s8, s13, 31 ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v5 -; GCN-NEXT: s_add_u32 s12, s12, s10 +; GCN-NEXT: s_add_u32 s12, s12, s8 ; GCN-NEXT: v_cndmask_b32_e64 v5, v10, v8, s[0:1] -; GCN-NEXT: v_mov_b32_e32 v8, s11 -; GCN-NEXT: s_mov_b32 s11, s10 -; GCN-NEXT: s_addc_u32 s13, s13, s10 -; GCN-NEXT: s_xor_b64 s[12:13], s[12:13], s[10:11] +; GCN-NEXT: v_mov_b32_e32 v8, s9 +; GCN-NEXT: s_mov_b32 s9, s8 +; GCN-NEXT: s_addc_u32 s13, s13, s8 +; GCN-NEXT: s_xor_b64 s[12:13], s[12:13], s[8:9] ; GCN-NEXT: v_cvt_f32_u32_e32 v10, s12 ; GCN-NEXT: v_cvt_f32_u32_e32 v11, s13 ; GCN-NEXT: v_subb_u32_e32 v2, vcc, v8, v2, vcc @@ -6624,42 +6671,42 @@ ; GCN-NEXT: v_add_i32_e32 v3, vcc, v9, v3 ; GCN-NEXT: v_addc_u32_e32 v8, vcc, v6, v8, vcc ; GCN-NEXT: v_add_i32_e32 v5, vcc, v5, v7 -; GCN-NEXT: s_ashr_i32 s14, s9, 31 +; GCN-NEXT: s_ashr_i32 s14, s11, 31 ; GCN-NEXT: v_addc_u32_e64 v5, vcc, v5, v8, s[0:1] -; GCN-NEXT: s_add_u32 s0, s8, s14 +; GCN-NEXT: s_add_u32 s0, s10, s14 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3 ; GCN-NEXT: s_mov_b32 s15, s14 -; GCN-NEXT: s_addc_u32 s1, s9, s14 -; GCN-NEXT: s_xor_b64 s[8:9], s[0:1], s[14:15] +; GCN-NEXT: s_addc_u32 s1, s11, s14 +; GCN-NEXT: s_xor_b64 s[10:11], s[0:1], s[14:15] ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v5, vcc -; GCN-NEXT: v_mul_lo_u32 v5, s8, v3 -; GCN-NEXT: v_mul_hi_u32 v7, s8, v2 -; GCN-NEXT: v_mul_hi_u32 v9, s8, v3 -; GCN-NEXT: v_mul_hi_u32 v10, s9, v3 -; GCN-NEXT: v_mul_lo_u32 v3, s9, v3 +; GCN-NEXT: v_mul_lo_u32 v5, s10, v3 +; GCN-NEXT: v_mul_hi_u32 v7, s10, v2 +; GCN-NEXT: v_mul_hi_u32 v9, s10, v3 +; GCN-NEXT: v_mul_hi_u32 v10, s11, v3 +; GCN-NEXT: v_mul_lo_u32 v3, s11, v3 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v7, v5 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v9, vcc -; GCN-NEXT: v_mul_lo_u32 v9, s9, v2 -; GCN-NEXT: v_mul_hi_u32 v2, s9, v2 +; GCN-NEXT: v_mul_lo_u32 v9, s11, v2 +; GCN-NEXT: v_mul_hi_u32 v2, s11, v2 ; GCN-NEXT: v_mov_b32_e32 v8, s3 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v9, v5 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v7, v2, vcc ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v10, v4, vcc -; GCN-NEXT: v_add_i32_e32 v5, vcc, v2, v3 -; GCN-NEXT: v_addc_u32_e32 v4, vcc, v6, v4, vcc -; GCN-NEXT: v_mul_lo_u32 v6, s12, v4 -; GCN-NEXT: v_mul_hi_u32 v7, s12, v5 -; GCN-NEXT: v_subrev_i32_e32 v2, vcc, s2, v0 -; GCN-NEXT: v_mul_lo_u32 v0, s13, v5 -; GCN-NEXT: v_subb_u32_e32 v3, vcc, v1, v8, vcc -; GCN-NEXT: v_add_i32_e32 v1, vcc, v7, v6 +; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3 +; GCN-NEXT: v_addc_u32_e32 v3, vcc, v6, v4, vcc +; GCN-NEXT: v_mul_lo_u32 v4, s12, v3 +; GCN-NEXT: v_mul_hi_u32 v5, s12, v2 +; GCN-NEXT: v_mul_lo_u32 v6, s13, v2 +; GCN-NEXT: v_subrev_i32_e32 v0, vcc, s2, v0 +; GCN-NEXT: v_subb_u32_e32 v1, vcc, v1, v8, vcc +; GCN-NEXT: v_add_i32_e32 v4, vcc, v5, v4 +; GCN-NEXT: v_mul_lo_u32 v5, s12, v2 +; GCN-NEXT: v_add_i32_e32 v4, vcc, v4, v6 +; GCN-NEXT: v_sub_i32_e32 v6, vcc, s11, v4 ; GCN-NEXT: v_mov_b32_e32 v7, s13 -; GCN-NEXT: v_add_i32_e32 v0, vcc, v1, v0 -; GCN-NEXT: v_mul_lo_u32 v1, s12, v5 -; GCN-NEXT: v_sub_i32_e32 v6, vcc, s9, v0 -; GCN-NEXT: v_sub_i32_e32 v1, vcc, s8, v1 +; GCN-NEXT: v_sub_i32_e32 v5, vcc, s10, v5 ; GCN-NEXT: v_subb_u32_e64 v6, s[0:1], v6, v7, vcc -; GCN-NEXT: v_subrev_i32_e64 v7, s[0:1], s12, v1 +; GCN-NEXT: v_subrev_i32_e64 v7, s[0:1], s12, v5 ; GCN-NEXT: v_subbrev_u32_e64 v6, s[0:1], 0, v6, s[0:1] ; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s13, v6 ; GCN-NEXT: v_cndmask_b32_e64 v8, 0, -1, s[0:1] @@ -6667,30 +6714,30 @@ ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[0:1] ; GCN-NEXT: v_cmp_eq_u32_e64 s[0:1], s13, v6 ; GCN-NEXT: v_cndmask_b32_e64 v6, v8, v7, s[0:1] -; GCN-NEXT: v_add_i32_e64 v7, s[0:1], 2, v5 -; GCN-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v4, s[0:1] -; GCN-NEXT: v_add_i32_e64 v9, s[0:1], 1, v5 -; GCN-NEXT: v_addc_u32_e64 v10, s[0:1], 0, v4, s[0:1] +; GCN-NEXT: v_add_i32_e64 v7, s[0:1], 2, v2 +; GCN-NEXT: v_addc_u32_e64 v8, s[0:1], 0, v3, s[0:1] +; GCN-NEXT: v_add_i32_e64 v9, s[0:1], 1, v2 +; GCN-NEXT: v_addc_u32_e64 v10, s[0:1], 0, v3, s[0:1] ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v6 ; GCN-NEXT: v_cndmask_b32_e64 v6, v10, v8, s[0:1] -; GCN-NEXT: v_mov_b32_e32 v8, s9 -; GCN-NEXT: v_subb_u32_e32 v0, vcc, v8, v0, vcc -; GCN-NEXT: v_cmp_le_u32_e32 vcc, s13, v0 +; GCN-NEXT: v_mov_b32_e32 v8, s11 +; GCN-NEXT: v_subb_u32_e32 v4, vcc, v8, v4, vcc +; GCN-NEXT: v_cmp_le_u32_e32 vcc, s13, v4 ; GCN-NEXT: v_cndmask_b32_e64 v8, 0, -1, vcc -; GCN-NEXT: v_cmp_le_u32_e32 vcc, s12, v1 -; GCN-NEXT: v_cndmask_b32_e64 v1, 0, -1, vcc -; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s13, v0 -; GCN-NEXT: v_cndmask_b32_e32 v0, v8, v1, vcc -; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0 -; GCN-NEXT: v_cndmask_b32_e64 v1, v9, v7, s[0:1] -; GCN-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc -; GCN-NEXT: s_xor_b64 s[0:1], s[14:15], s[10:11] -; GCN-NEXT: v_cndmask_b32_e32 v0, v4, v6, vcc -; GCN-NEXT: v_xor_b32_e32 v1, s0, v1 -; GCN-NEXT: v_xor_b32_e32 v4, s1, v0 -; GCN-NEXT: v_mov_b32_e32 v5, s1 -; GCN-NEXT: v_subrev_i32_e32 v0, vcc, s0, v1 -; GCN-NEXT: v_subb_u32_e32 v1, vcc, v4, v5, vcc +; GCN-NEXT: v_cmp_le_u32_e32 vcc, s12, v5 +; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc +; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s13, v4 +; GCN-NEXT: v_cndmask_b32_e32 v4, v8, v5, vcc +; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4 +; GCN-NEXT: v_cndmask_b32_e64 v4, v9, v7, s[0:1] +; GCN-NEXT: v_cndmask_b32_e32 v2, v2, v4, vcc +; GCN-NEXT: s_xor_b64 s[0:1], s[14:15], s[8:9] +; GCN-NEXT: v_cndmask_b32_e32 v3, v3, v6, vcc +; GCN-NEXT: v_xor_b32_e32 v2, s0, v2 +; GCN-NEXT: v_xor_b32_e32 v3, s1, v3 +; GCN-NEXT: v_mov_b32_e32 v4, s1 +; GCN-NEXT: v_subrev_i32_e32 v2, vcc, s0, v2 +; GCN-NEXT: v_subb_u32_e32 v3, vcc, v3, v4, vcc ; GCN-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0 ; GCN-NEXT: s_endpgm %shl.y = shl <2 x i64> , %y @@ -7010,8 +7057,13 @@ define amdgpu_kernel void @srem_v2i64_pow2k_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x) { ; CHECK-LABEL: @srem_v2i64_pow2k_denom( -; CHECK-NEXT: [[R:%.*]] = srem <2 x i64> [[X:%.*]], -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = srem i64 [[TMP1]], 4096 +; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x i64> undef, i64 [[TMP2]], i64 0 +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP5:%.*]] = srem i64 [[TMP4]], 4096 +; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x i64> [[TMP3]], i64 [[TMP5]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: srem_v2i64_pow2k_denom: @@ -7022,20 +7074,20 @@ ; GCN-NEXT: s_mov_b32 s7, 0xf000 ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_ashr_i32 s9, s3, 31 -; GCN-NEXT: s_lshr_b32 s9, s9, 20 -; GCN-NEXT: s_add_u32 s9, s2, s9 -; GCN-NEXT: s_addc_u32 s10, s3, 0 -; GCN-NEXT: s_and_b32 s9, s9, s8 -; GCN-NEXT: s_sub_u32 s2, s2, s9 -; GCN-NEXT: s_subb_u32 s3, s3, s10 ; GCN-NEXT: s_ashr_i32 s9, s1, 31 ; GCN-NEXT: s_lshr_b32 s9, s9, 20 ; GCN-NEXT: s_add_u32 s9, s0, s9 ; GCN-NEXT: s_addc_u32 s10, s1, 0 -; GCN-NEXT: s_and_b32 s8, s9, s8 -; GCN-NEXT: s_sub_u32 s0, s0, s8 +; GCN-NEXT: s_and_b32 s9, s9, s8 +; GCN-NEXT: s_sub_u32 s0, s0, s9 ; GCN-NEXT: s_subb_u32 s1, s1, s10 +; GCN-NEXT: s_ashr_i32 s9, s3, 31 +; GCN-NEXT: s_lshr_b32 s9, s9, 20 +; GCN-NEXT: s_add_u32 s9, s2, s9 +; GCN-NEXT: s_addc_u32 s10, s3, 0 +; GCN-NEXT: s_and_b32 s8, s9, s8 +; GCN-NEXT: s_sub_u32 s2, s2, s8 +; GCN-NEXT: s_subb_u32 s3, s3, s10 ; GCN-NEXT: v_mov_b32_e32 v0, s0 ; GCN-NEXT: v_mov_b32_e32 v1, s1 ; GCN-NEXT: v_mov_b32_e32 v2, s2 @@ -7050,8 +7102,15 @@ define amdgpu_kernel void @srem_v2i64_pow2_shl_denom(<2 x i64> addrspace(1)* %out, <2 x i64> %x, <2 x i64> %y) { ; CHECK-LABEL: @srem_v2i64_pow2_shl_denom( ; CHECK-NEXT: [[SHL_Y:%.*]] = shl <2 x i64> , [[Y:%.*]] -; CHECK-NEXT: [[R:%.*]] = srem <2 x i64> [[X:%.*]], [[SHL_Y]] -; CHECK-NEXT: store <2 x i64> [[R]], <2 x i64> addrspace(1)* [[OUT:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i64> [[X:%.*]], i64 0 +; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 0 +; CHECK-NEXT: [[TMP3:%.*]] = srem i64 [[TMP1]], [[TMP2]] +; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> undef, i64 [[TMP3]], i64 0 +; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x i64> [[X]], i64 1 +; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i64> [[SHL_Y]], i64 1 +; CHECK-NEXT: [[TMP7:%.*]] = srem i64 [[TMP5]], [[TMP6]] +; CHECK-NEXT: [[TMP8:%.*]] = insertelement <2 x i64> [[TMP4]], i64 [[TMP7]], i64 1 +; CHECK-NEXT: store <2 x i64> [[TMP8]], <2 x i64> addrspace(1)* [[OUT:%.*]] ; CHECK-NEXT: ret void ; ; GCN-LABEL: srem_v2i64_pow2_shl_denom: @@ -7062,8 +7121,8 @@ ; GCN-NEXT: s_mov_b32 s18, 0x4f800000 ; GCN-NEXT: s_mov_b32 s19, 0x5f7ffffc ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_lshl_b64 s[14:15], s[2:3], s4 -; GCN-NEXT: s_lshl_b64 s[2:3], s[2:3], s6 +; GCN-NEXT: s_lshl_b64 s[14:15], s[2:3], s6 +; GCN-NEXT: s_lshl_b64 s[2:3], s[2:3], s4 ; GCN-NEXT: s_ashr_i32 s4, s3, 31 ; GCN-NEXT: s_add_u32 s2, s2, s4 ; GCN-NEXT: s_mov_b32 s5, s4 @@ -7086,8 +7145,8 @@ ; GCN-NEXT: v_cvt_u32_f32_e32 v0, v0 ; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1 ; GCN-NEXT: s_waitcnt lgkmcnt(0) -; GCN-NEXT: s_ashr_i32 s12, s11, 31 -; GCN-NEXT: s_add_u32 s0, s10, s12 +; GCN-NEXT: s_ashr_i32 s12, s9, 31 +; GCN-NEXT: s_add_u32 s0, s8, s12 ; GCN-NEXT: v_mul_hi_u32 v3, s6, v0 ; GCN-NEXT: v_mul_lo_u32 v2, s6, v1 ; GCN-NEXT: v_mul_lo_u32 v4, s7, v0 @@ -7104,8 +7163,8 @@ ; GCN-NEXT: v_addc_u32_e32 v4, vcc, 0, v6, vcc ; GCN-NEXT: v_mul_lo_u32 v6, v1, v5 ; GCN-NEXT: v_mul_hi_u32 v5, v1, v5 -; GCN-NEXT: s_addc_u32 s1, s11, s12 -; GCN-NEXT: s_xor_b64 s[10:11], s[0:1], s[12:13] +; GCN-NEXT: s_addc_u32 s1, s9, s12 +; GCN-NEXT: s_xor_b64 s[8:9], s[0:1], s[12:13] ; GCN-NEXT: v_add_i32_e32 v3, vcc, v6, v3 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, v4, v5, vcc ; GCN-NEXT: v_mov_b32_e32 v4, 0 @@ -7140,15 +7199,15 @@ ; GCN-NEXT: v_addc_u32_e64 v1, vcc, v1, v5, s[2:3] ; GCN-NEXT: v_add_i32_e32 v0, vcc, v0, v2 ; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc -; GCN-NEXT: v_mul_lo_u32 v2, s10, v1 -; GCN-NEXT: v_mul_hi_u32 v3, s10, v0 -; GCN-NEXT: v_mul_hi_u32 v5, s10, v1 -; GCN-NEXT: v_mul_hi_u32 v7, s11, v1 -; GCN-NEXT: v_mul_lo_u32 v1, s11, v1 +; GCN-NEXT: v_mul_lo_u32 v2, s8, v1 +; GCN-NEXT: v_mul_hi_u32 v3, s8, v0 +; GCN-NEXT: v_mul_hi_u32 v5, s8, v1 +; GCN-NEXT: v_mul_hi_u32 v7, s9, v1 +; GCN-NEXT: v_mul_lo_u32 v1, s9, v1 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v3, v2 ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v5, vcc -; GCN-NEXT: v_mul_lo_u32 v5, s11, v0 -; GCN-NEXT: v_mul_hi_u32 v0, s11, v0 +; GCN-NEXT: v_mul_lo_u32 v5, s9, v0 +; GCN-NEXT: v_mul_hi_u32 v0, s9, v0 ; GCN-NEXT: s_mov_b32 s6, -1 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v5, v2 ; GCN-NEXT: v_addc_u32_e32 v0, vcc, v3, v0, vcc @@ -7161,9 +7220,9 @@ ; GCN-NEXT: v_mul_lo_u32 v0, s16, v0 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v2, v1 ; GCN-NEXT: v_add_i32_e32 v1, vcc, v1, v3 -; GCN-NEXT: v_sub_i32_e32 v2, vcc, s11, v1 +; GCN-NEXT: v_sub_i32_e32 v2, vcc, s9, v1 ; GCN-NEXT: v_mov_b32_e32 v3, s17 -; GCN-NEXT: v_sub_i32_e32 v0, vcc, s10, v0 +; GCN-NEXT: v_sub_i32_e32 v0, vcc, s8, v0 ; GCN-NEXT: v_subb_u32_e64 v2, s[0:1], v2, v3, vcc ; GCN-NEXT: v_subrev_i32_e64 v5, s[0:1], s16, v0 ; GCN-NEXT: v_subb_u32_e64 v3, s[2:3], v2, v3, s[0:1] @@ -7178,14 +7237,14 @@ ; GCN-NEXT: s_ashr_i32 s2, s15, 31 ; GCN-NEXT: v_subbrev_u32_e64 v3, s[0:1], 0, v3, s[0:1] ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v7 -; GCN-NEXT: s_add_u32 s10, s14, s2 +; GCN-NEXT: s_add_u32 s8, s14, s2 ; GCN-NEXT: v_cndmask_b32_e64 v2, v2, v3, s[0:1] -; GCN-NEXT: v_mov_b32_e32 v3, s11 +; GCN-NEXT: v_mov_b32_e32 v3, s9 ; GCN-NEXT: s_mov_b32 s3, s2 -; GCN-NEXT: s_addc_u32 s11, s15, s2 -; GCN-NEXT: s_xor_b64 s[10:11], s[10:11], s[2:3] -; GCN-NEXT: v_cvt_f32_u32_e32 v7, s10 -; GCN-NEXT: v_cvt_f32_u32_e32 v9, s11 +; GCN-NEXT: s_addc_u32 s9, s15, s2 +; GCN-NEXT: s_xor_b64 s[8:9], s[8:9], s[2:3] +; GCN-NEXT: v_cvt_f32_u32_e32 v7, s8 +; GCN-NEXT: v_cvt_f32_u32_e32 v9, s9 ; GCN-NEXT: v_subb_u32_e32 v1, vcc, v3, v1, vcc ; GCN-NEXT: v_cmp_le_u32_e32 vcc, s17, v1 ; GCN-NEXT: v_cndmask_b32_e64 v3, 0, -1, vcc @@ -7204,13 +7263,13 @@ ; GCN-NEXT: v_mac_f32_e32 v3, s21, v5 ; GCN-NEXT: v_cvt_u32_f32_e32 v3, v3 ; GCN-NEXT: v_cvt_u32_f32_e32 v5, v5 -; GCN-NEXT: s_sub_u32 s2, 0, s10 +; GCN-NEXT: s_sub_u32 s2, 0, s8 ; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc ; GCN-NEXT: v_mul_hi_u32 v2, s2, v3 ; GCN-NEXT: v_mul_lo_u32 v7, s2, v5 -; GCN-NEXT: s_subb_u32 s3, 0, s11 +; GCN-NEXT: s_subb_u32 s3, 0, s9 ; GCN-NEXT: v_mul_lo_u32 v8, s3, v3 -; GCN-NEXT: s_ashr_i32 s14, s9, 31 +; GCN-NEXT: s_ashr_i32 s14, s11, 31 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v7 ; GCN-NEXT: v_mul_lo_u32 v7, s2, v3 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v8 @@ -7255,68 +7314,68 @@ ; GCN-NEXT: v_addc_u32_e32 v8, vcc, v6, v8, vcc ; GCN-NEXT: v_add_i32_e32 v5, vcc, v5, v7 ; GCN-NEXT: v_addc_u32_e64 v5, vcc, v5, v8, s[0:1] -; GCN-NEXT: s_add_u32 s0, s8, s14 +; GCN-NEXT: s_add_u32 s0, s10, s14 ; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3 -; GCN-NEXT: s_addc_u32 s1, s9, s14 -; GCN-NEXT: s_xor_b64 s[8:9], s[0:1], s[14:15] +; GCN-NEXT: s_addc_u32 s1, s11, s14 +; GCN-NEXT: s_xor_b64 s[10:11], s[0:1], s[14:15] ; GCN-NEXT: v_addc_u32_e32 v3, vcc, 0, v5, vcc -; GCN-NEXT: v_mul_lo_u32 v5, s8, v3 -; GCN-NEXT: v_mul_hi_u32 v7, s8, v2 -; GCN-NEXT: v_mul_hi_u32 v9, s8, v3 -; GCN-NEXT: v_mul_hi_u32 v10, s9, v3 -; GCN-NEXT: v_mul_lo_u32 v3, s9, v3 +; GCN-NEXT: v_mul_lo_u32 v5, s10, v3 +; GCN-NEXT: v_mul_hi_u32 v7, s10, v2 +; GCN-NEXT: v_mul_hi_u32 v9, s10, v3 +; GCN-NEXT: v_mul_hi_u32 v10, s11, v3 +; GCN-NEXT: v_mul_lo_u32 v3, s11, v3 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v7, v5 ; GCN-NEXT: v_addc_u32_e32 v7, vcc, 0, v9, vcc -; GCN-NEXT: v_mul_lo_u32 v9, s9, v2 -; GCN-NEXT: v_mul_hi_u32 v2, s9, v2 +; GCN-NEXT: v_mul_lo_u32 v9, s11, v2 +; GCN-NEXT: v_mul_hi_u32 v2, s11, v2 ; GCN-NEXT: v_mov_b32_e32 v8, s12 ; GCN-NEXT: v_add_i32_e32 v5, vcc, v9, v5 ; GCN-NEXT: v_addc_u32_e32 v2, vcc, v7, v2, vcc ; GCN-NEXT: v_addc_u32_e32 v4, vcc, v10, v4, vcc -; GCN-NEXT: v_add_i32_e32 v5, vcc, v2, v3 -; GCN-NEXT: v_addc_u32_e32 v2, vcc, v6, v4, vcc -; GCN-NEXT: v_mul_lo_u32 v4, s10, v2 -; GCN-NEXT: v_mul_hi_u32 v6, s10, v5 -; GCN-NEXT: v_subrev_i32_e32 v2, vcc, s12, v0 -; GCN-NEXT: v_mul_lo_u32 v0, s11, v5 -; GCN-NEXT: v_subb_u32_e32 v3, vcc, v1, v8, vcc -; GCN-NEXT: v_add_i32_e32 v1, vcc, v6, v4 -; GCN-NEXT: v_add_i32_e32 v0, vcc, v1, v0 -; GCN-NEXT: v_mul_lo_u32 v1, s10, v5 -; GCN-NEXT: v_sub_i32_e32 v4, vcc, s9, v0 -; GCN-NEXT: v_mov_b32_e32 v5, s11 -; GCN-NEXT: v_sub_i32_e32 v1, vcc, s8, v1 +; GCN-NEXT: v_add_i32_e32 v2, vcc, v2, v3 +; GCN-NEXT: v_addc_u32_e32 v3, vcc, v6, v4, vcc +; GCN-NEXT: v_mul_lo_u32 v3, s8, v3 +; GCN-NEXT: v_mul_hi_u32 v4, s8, v2 +; GCN-NEXT: v_mul_lo_u32 v5, s9, v2 +; GCN-NEXT: v_subrev_i32_e32 v0, vcc, s12, v0 +; GCN-NEXT: v_mul_lo_u32 v2, s8, v2 +; GCN-NEXT: v_subb_u32_e32 v1, vcc, v1, v8, vcc +; GCN-NEXT: v_add_i32_e32 v3, vcc, v4, v3 +; GCN-NEXT: v_add_i32_e32 v3, vcc, v3, v5 +; GCN-NEXT: v_sub_i32_e32 v4, vcc, s11, v3 +; GCN-NEXT: v_mov_b32_e32 v5, s9 +; GCN-NEXT: v_sub_i32_e32 v2, vcc, s10, v2 ; GCN-NEXT: v_subb_u32_e64 v4, s[0:1], v4, v5, vcc -; GCN-NEXT: v_subrev_i32_e64 v6, s[0:1], s10, v1 +; GCN-NEXT: v_subrev_i32_e64 v6, s[0:1], s8, v2 ; GCN-NEXT: v_subb_u32_e64 v5, s[2:3], v4, v5, s[0:1] ; GCN-NEXT: v_subbrev_u32_e64 v4, s[0:1], 0, v4, s[0:1] -; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s11, v4 +; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s9, v4 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, s[0:1] -; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s10, v6 +; GCN-NEXT: v_cmp_le_u32_e64 s[0:1], s8, v6 ; GCN-NEXT: v_cndmask_b32_e64 v8, 0, -1, s[0:1] -; GCN-NEXT: v_cmp_eq_u32_e64 s[0:1], s11, v4 +; GCN-NEXT: v_cmp_eq_u32_e64 s[0:1], s9, v4 ; GCN-NEXT: v_cndmask_b32_e64 v7, v7, v8, s[0:1] -; GCN-NEXT: v_subrev_i32_e64 v8, s[0:1], s10, v6 +; GCN-NEXT: v_subrev_i32_e64 v8, s[0:1], s8, v6 ; GCN-NEXT: v_subbrev_u32_e64 v5, s[0:1], 0, v5, s[0:1] ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v7 ; GCN-NEXT: v_cndmask_b32_e64 v4, v4, v5, s[0:1] -; GCN-NEXT: v_mov_b32_e32 v5, s9 -; GCN-NEXT: v_subb_u32_e32 v0, vcc, v5, v0, vcc -; GCN-NEXT: v_cmp_le_u32_e32 vcc, s11, v0 +; GCN-NEXT: v_mov_b32_e32 v5, s11 +; GCN-NEXT: v_subb_u32_e32 v3, vcc, v5, v3, vcc +; GCN-NEXT: v_cmp_le_u32_e32 vcc, s9, v3 ; GCN-NEXT: v_cndmask_b32_e64 v5, 0, -1, vcc -; GCN-NEXT: v_cmp_le_u32_e32 vcc, s10, v1 +; GCN-NEXT: v_cmp_le_u32_e32 vcc, s8, v2 ; GCN-NEXT: v_cndmask_b32_e64 v7, 0, -1, vcc -; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s11, v0 +; GCN-NEXT: v_cmp_eq_u32_e32 vcc, s9, v3 ; GCN-NEXT: v_cndmask_b32_e32 v5, v5, v7, vcc ; GCN-NEXT: v_cmp_ne_u32_e32 vcc, 0, v5 -; GCN-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc +; GCN-NEXT: v_cndmask_b32_e32 v3, v3, v4, vcc ; GCN-NEXT: v_cndmask_b32_e64 v4, v6, v8, s[0:1] -; GCN-NEXT: v_cndmask_b32_e32 v1, v1, v4, vcc -; GCN-NEXT: v_xor_b32_e32 v1, s14, v1 -; GCN-NEXT: v_xor_b32_e32 v4, s14, v0 -; GCN-NEXT: v_mov_b32_e32 v5, s14 -; GCN-NEXT: v_subrev_i32_e32 v0, vcc, s14, v1 -; GCN-NEXT: v_subb_u32_e32 v1, vcc, v4, v5, vcc +; GCN-NEXT: v_cndmask_b32_e32 v2, v2, v4, vcc +; GCN-NEXT: v_xor_b32_e32 v2, s14, v2 +; GCN-NEXT: v_xor_b32_e32 v3, s14, v3 +; GCN-NEXT: v_mov_b32_e32 v4, s14 +; GCN-NEXT: v_subrev_i32_e32 v2, vcc, s14, v2 +; GCN-NEXT: v_subb_u32_e32 v3, vcc, v3, v4, vcc ; GCN-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0 ; GCN-NEXT: s_endpgm %shl.y = shl <2 x i64> , %y Index: llvm/test/CodeGen/AMDGPU/sdiv64.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/sdiv64.ll +++ llvm/test/CodeGen/AMDGPU/sdiv64.ll @@ -424,9 +424,9 @@ ; GCN-IR-NEXT: v_sub_i32_e32 v10, vcc, 63, v8 ; GCN-IR-NEXT: s_mov_b64 s[8:9], 0 ; GCN-IR-NEXT: v_cmp_ge_u64_e32 vcc, v[2:3], v[8:9] -; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[12:13], v10 -; GCN-IR-NEXT: v_mov_b32_e32 v10, 0 -; GCN-IR-NEXT: v_mov_b32_e32 v11, 0 +; GCN-IR-NEXT: v_lshl_b64 v[10:11], v[12:13], v10 +; GCN-IR-NEXT: v_mov_b32_e32 v8, 0 +; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc ; GCN-IR-NEXT: s_xor_b64 s[10:11], exec, s[4:5] ; GCN-IR-NEXT: s_cbranch_execz BB1_5 @@ -439,35 +439,35 @@ ; GCN-IR-NEXT: BB1_3: ; %udiv-do-while ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1 ; GCN-IR-NEXT: v_lshl_b64 v[16:17], v[16:17], 1 -; GCN-IR-NEXT: v_lshrrev_b32_e32 v10, 31, v9 -; GCN-IR-NEXT: v_mov_b32_e32 v11, 0 -; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1 +; GCN-IR-NEXT: v_lshrrev_b32_e32 v8, 31, v11 +; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 +; GCN-IR-NEXT: v_lshl_b64 v[10:11], v[10:11], 1 ; GCN-IR-NEXT: v_add_i32_e32 v2, vcc, -1, v2 ; GCN-IR-NEXT: v_addc_u32_e32 v3, vcc, -1, v3, vcc -; GCN-IR-NEXT: v_or_b32_e32 v16, v16, v10 -; GCN-IR-NEXT: v_or_b32_e32 v9, v15, v9 -; GCN-IR-NEXT: v_or_b32_e32 v8, v14, v8 +; GCN-IR-NEXT: v_or_b32_e32 v16, v16, v8 +; GCN-IR-NEXT: v_or_b32_e32 v11, v15, v11 +; GCN-IR-NEXT: v_or_b32_e32 v10, v14, v10 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[2:3] -; GCN-IR-NEXT: v_sub_i32_e64 v10, s[4:5], v12, v16 -; GCN-IR-NEXT: v_subb_u32_e64 v10, s[4:5], v13, v17, s[4:5] +; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v12, v16 +; GCN-IR-NEXT: v_subb_u32_e64 v8, s[4:5], v13, v17, s[4:5] ; GCN-IR-NEXT: s_or_b64 s[8:9], vcc, s[8:9] -; GCN-IR-NEXT: v_ashrrev_i32_e32 v14, 31, v10 -; GCN-IR-NEXT: v_and_b32_e32 v10, 1, v14 +; GCN-IR-NEXT: v_ashrrev_i32_e32 v14, 31, v8 +; GCN-IR-NEXT: v_and_b32_e32 v8, 1, v14 ; GCN-IR-NEXT: v_and_b32_e32 v15, v14, v1 ; GCN-IR-NEXT: v_and_b32_e32 v14, v14, v0 ; GCN-IR-NEXT: v_sub_i32_e32 v16, vcc, v16, v14 ; GCN-IR-NEXT: v_subb_u32_e32 v17, vcc, v17, v15, vcc -; GCN-IR-NEXT: v_mov_b32_e32 v15, v11 -; GCN-IR-NEXT: v_mov_b32_e32 v14, v10 +; GCN-IR-NEXT: v_mov_b32_e32 v15, v9 +; GCN-IR-NEXT: v_mov_b32_e32 v14, v8 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: s_cbranch_execnz BB1_3 ; GCN-IR-NEXT: ; %bb.4: ; %Flow ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: BB1_5: ; %Flow1 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11] -; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[8:9], 1 -; GCN-IR-NEXT: v_or_b32_e32 v2, v11, v1 -; GCN-IR-NEXT: v_or_b32_e32 v3, v10, v0 +; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[10:11], 1 +; GCN-IR-NEXT: v_or_b32_e32 v2, v9, v1 +; GCN-IR-NEXT: v_or_b32_e32 v3, v8, v0 ; GCN-IR-NEXT: BB1_6: ; %Flow2 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7] ; GCN-IR-NEXT: v_xor_b32_e32 v1, v7, v6 @@ -1478,9 +1478,9 @@ ; GCN-IR-NEXT: v_sub_i32_e32 v8, vcc, 63, v6 ; GCN-IR-NEXT: s_mov_b64 s[8:9], 0 ; GCN-IR-NEXT: v_cmp_ge_u64_e32 vcc, v[4:5], v[6:7] -; GCN-IR-NEXT: v_lshl_b64 v[6:7], 24, v8 -; GCN-IR-NEXT: v_mov_b32_e32 v8, 0 -; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 +; GCN-IR-NEXT: v_lshl_b64 v[8:9], 24, v8 +; GCN-IR-NEXT: v_mov_b32_e32 v6, 0 +; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc ; GCN-IR-NEXT: s_xor_b64 s[10:11], exec, s[4:5] ; GCN-IR-NEXT: s_cbranch_execz BB11_5 @@ -1493,35 +1493,35 @@ ; GCN-IR-NEXT: BB11_3: ; %udiv-do-while ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1 ; GCN-IR-NEXT: v_lshl_b64 v[14:15], v[14:15], 1 -; GCN-IR-NEXT: v_lshrrev_b32_e32 v8, 31, v7 -; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 -; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[6:7], 1 +; GCN-IR-NEXT: v_lshrrev_b32_e32 v6, 31, v9 +; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 +; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1 ; GCN-IR-NEXT: v_add_i32_e32 v4, vcc, -1, v4 ; GCN-IR-NEXT: v_addc_u32_e32 v5, vcc, -1, v5, vcc -; GCN-IR-NEXT: v_or_b32_e32 v14, v14, v8 -; GCN-IR-NEXT: v_or_b32_e32 v7, v13, v7 -; GCN-IR-NEXT: v_or_b32_e32 v6, v12, v6 +; GCN-IR-NEXT: v_or_b32_e32 v14, v14, v6 +; GCN-IR-NEXT: v_or_b32_e32 v9, v13, v9 +; GCN-IR-NEXT: v_or_b32_e32 v8, v12, v8 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[4:5] -; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v10, v14 -; GCN-IR-NEXT: v_subb_u32_e64 v8, s[4:5], v11, v15, s[4:5] +; GCN-IR-NEXT: v_sub_i32_e64 v6, s[4:5], v10, v14 +; GCN-IR-NEXT: v_subb_u32_e64 v6, s[4:5], v11, v15, s[4:5] ; GCN-IR-NEXT: s_or_b64 s[8:9], vcc, s[8:9] -; GCN-IR-NEXT: v_ashrrev_i32_e32 v12, 31, v8 -; GCN-IR-NEXT: v_and_b32_e32 v8, 1, v12 +; GCN-IR-NEXT: v_ashrrev_i32_e32 v12, 31, v6 +; GCN-IR-NEXT: v_and_b32_e32 v6, 1, v12 ; GCN-IR-NEXT: v_and_b32_e32 v13, v12, v1 ; GCN-IR-NEXT: v_and_b32_e32 v12, v12, v0 ; GCN-IR-NEXT: v_sub_i32_e32 v14, vcc, v14, v12 ; GCN-IR-NEXT: v_subb_u32_e32 v15, vcc, v15, v13, vcc -; GCN-IR-NEXT: v_mov_b32_e32 v13, v9 -; GCN-IR-NEXT: v_mov_b32_e32 v12, v8 +; GCN-IR-NEXT: v_mov_b32_e32 v13, v7 +; GCN-IR-NEXT: v_mov_b32_e32 v12, v6 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: s_cbranch_execnz BB11_3 ; GCN-IR-NEXT: ; %bb.4: ; %Flow ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: BB11_5: ; %Flow1 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11] -; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[6:7], 1 -; GCN-IR-NEXT: v_or_b32_e32 v5, v9, v1 -; GCN-IR-NEXT: v_or_b32_e32 v4, v8, v0 +; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[8:9], 1 +; GCN-IR-NEXT: v_or_b32_e32 v5, v7, v1 +; GCN-IR-NEXT: v_or_b32_e32 v4, v6, v0 ; GCN-IR-NEXT: BB11_6: ; %Flow2 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7] ; GCN-IR-NEXT: v_xor_b32_e32 v1, v5, v3 Index: llvm/test/CodeGen/AMDGPU/srem64.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/srem64.ll +++ llvm/test/CodeGen/AMDGPU/srem64.ll @@ -399,9 +399,9 @@ ; GCN-IR-NEXT: v_sub_i32_e32 v10, vcc, 63, v8 ; GCN-IR-NEXT: s_mov_b64 s[8:9], 0 ; GCN-IR-NEXT: v_cmp_ge_u64_e32 vcc, v[6:7], v[8:9] -; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[0:1], v10 -; GCN-IR-NEXT: v_mov_b32_e32 v10, 0 -; GCN-IR-NEXT: v_mov_b32_e32 v11, 0 +; GCN-IR-NEXT: v_lshl_b64 v[10:11], v[0:1], v10 +; GCN-IR-NEXT: v_mov_b32_e32 v8, 0 +; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc ; GCN-IR-NEXT: s_xor_b64 s[10:11], exec, s[4:5] ; GCN-IR-NEXT: s_cbranch_execz BB1_5 @@ -414,35 +414,35 @@ ; GCN-IR-NEXT: BB1_3: ; %udiv-do-while ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1 ; GCN-IR-NEXT: v_lshl_b64 v[16:17], v[16:17], 1 -; GCN-IR-NEXT: v_lshrrev_b32_e32 v10, 31, v9 -; GCN-IR-NEXT: v_mov_b32_e32 v11, 0 -; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1 +; GCN-IR-NEXT: v_lshrrev_b32_e32 v8, 31, v11 +; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 +; GCN-IR-NEXT: v_lshl_b64 v[10:11], v[10:11], 1 ; GCN-IR-NEXT: v_add_i32_e32 v6, vcc, -1, v6 ; GCN-IR-NEXT: v_addc_u32_e32 v7, vcc, -1, v7, vcc -; GCN-IR-NEXT: v_or_b32_e32 v16, v16, v10 -; GCN-IR-NEXT: v_or_b32_e32 v9, v15, v9 -; GCN-IR-NEXT: v_or_b32_e32 v8, v14, v8 +; GCN-IR-NEXT: v_or_b32_e32 v16, v16, v8 +; GCN-IR-NEXT: v_or_b32_e32 v11, v15, v11 +; GCN-IR-NEXT: v_or_b32_e32 v10, v14, v10 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[6:7] -; GCN-IR-NEXT: v_sub_i32_e64 v10, s[4:5], v12, v16 -; GCN-IR-NEXT: v_subb_u32_e64 v10, s[4:5], v13, v17, s[4:5] +; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v12, v16 +; GCN-IR-NEXT: v_subb_u32_e64 v8, s[4:5], v13, v17, s[4:5] ; GCN-IR-NEXT: s_or_b64 s[8:9], vcc, s[8:9] -; GCN-IR-NEXT: v_ashrrev_i32_e32 v14, 31, v10 -; GCN-IR-NEXT: v_and_b32_e32 v10, 1, v14 +; GCN-IR-NEXT: v_ashrrev_i32_e32 v14, 31, v8 +; GCN-IR-NEXT: v_and_b32_e32 v8, 1, v14 ; GCN-IR-NEXT: v_and_b32_e32 v15, v14, v3 ; GCN-IR-NEXT: v_and_b32_e32 v14, v14, v2 ; GCN-IR-NEXT: v_sub_i32_e32 v16, vcc, v16, v14 ; GCN-IR-NEXT: v_subb_u32_e32 v17, vcc, v17, v15, vcc -; GCN-IR-NEXT: v_mov_b32_e32 v15, v11 -; GCN-IR-NEXT: v_mov_b32_e32 v14, v10 +; GCN-IR-NEXT: v_mov_b32_e32 v15, v9 +; GCN-IR-NEXT: v_mov_b32_e32 v14, v8 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: s_cbranch_execnz BB1_3 ; GCN-IR-NEXT: ; %bb.4: ; %Flow ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: BB1_5: ; %Flow1 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11] -; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[8:9], 1 -; GCN-IR-NEXT: v_or_b32_e32 v7, v11, v7 -; GCN-IR-NEXT: v_or_b32_e32 v6, v10, v6 +; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[10:11], 1 +; GCN-IR-NEXT: v_or_b32_e32 v7, v9, v7 +; GCN-IR-NEXT: v_or_b32_e32 v6, v8, v6 ; GCN-IR-NEXT: BB1_6: ; %Flow2 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7] ; GCN-IR-NEXT: v_mul_lo_u32 v7, v2, v7 @@ -1653,9 +1653,9 @@ ; GCN-IR-NEXT: v_sub_i32_e32 v6, vcc, 63, v4 ; GCN-IR-NEXT: s_mov_b64 s[8:9], 0 ; GCN-IR-NEXT: v_cmp_ge_u64_e32 vcc, v[2:3], v[4:5] -; GCN-IR-NEXT: v_lshl_b64 v[4:5], 24, v6 -; GCN-IR-NEXT: v_mov_b32_e32 v6, 0 -; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 +; GCN-IR-NEXT: v_lshl_b64 v[6:7], 24, v6 +; GCN-IR-NEXT: v_mov_b32_e32 v4, 0 +; GCN-IR-NEXT: v_mov_b32_e32 v5, 0 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc ; GCN-IR-NEXT: s_xor_b64 s[10:11], exec, s[4:5] ; GCN-IR-NEXT: s_cbranch_execz BB11_5 @@ -1668,35 +1668,35 @@ ; GCN-IR-NEXT: BB11_3: ; %udiv-do-while ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1 ; GCN-IR-NEXT: v_lshl_b64 v[12:13], v[12:13], 1 -; GCN-IR-NEXT: v_lshrrev_b32_e32 v6, 31, v5 -; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 -; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[4:5], 1 +; GCN-IR-NEXT: v_lshrrev_b32_e32 v4, 31, v7 +; GCN-IR-NEXT: v_mov_b32_e32 v5, 0 +; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[6:7], 1 ; GCN-IR-NEXT: v_add_i32_e32 v2, vcc, -1, v2 ; GCN-IR-NEXT: v_addc_u32_e32 v3, vcc, -1, v3, vcc -; GCN-IR-NEXT: v_or_b32_e32 v12, v12, v6 -; GCN-IR-NEXT: v_or_b32_e32 v5, v11, v5 -; GCN-IR-NEXT: v_or_b32_e32 v4, v10, v4 +; GCN-IR-NEXT: v_or_b32_e32 v12, v12, v4 +; GCN-IR-NEXT: v_or_b32_e32 v7, v11, v7 +; GCN-IR-NEXT: v_or_b32_e32 v6, v10, v6 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[2:3] -; GCN-IR-NEXT: v_sub_i32_e64 v6, s[4:5], v8, v12 -; GCN-IR-NEXT: v_subb_u32_e64 v6, s[4:5], v9, v13, s[4:5] +; GCN-IR-NEXT: v_sub_i32_e64 v4, s[4:5], v8, v12 +; GCN-IR-NEXT: v_subb_u32_e64 v4, s[4:5], v9, v13, s[4:5] ; GCN-IR-NEXT: s_or_b64 s[8:9], vcc, s[8:9] -; GCN-IR-NEXT: v_ashrrev_i32_e32 v10, 31, v6 -; GCN-IR-NEXT: v_and_b32_e32 v6, 1, v10 +; GCN-IR-NEXT: v_ashrrev_i32_e32 v10, 31, v4 +; GCN-IR-NEXT: v_and_b32_e32 v4, 1, v10 ; GCN-IR-NEXT: v_and_b32_e32 v11, v10, v1 ; GCN-IR-NEXT: v_and_b32_e32 v10, v10, v0 ; GCN-IR-NEXT: v_sub_i32_e32 v12, vcc, v12, v10 ; GCN-IR-NEXT: v_subb_u32_e32 v13, vcc, v13, v11, vcc -; GCN-IR-NEXT: v_mov_b32_e32 v11, v7 -; GCN-IR-NEXT: v_mov_b32_e32 v10, v6 +; GCN-IR-NEXT: v_mov_b32_e32 v11, v5 +; GCN-IR-NEXT: v_mov_b32_e32 v10, v4 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: s_cbranch_execnz BB11_3 ; GCN-IR-NEXT: ; %bb.4: ; %Flow ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: BB11_5: ; %Flow1 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11] -; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[4:5], 1 -; GCN-IR-NEXT: v_or_b32_e32 v3, v7, v3 -; GCN-IR-NEXT: v_or_b32_e32 v2, v6, v2 +; GCN-IR-NEXT: v_lshl_b64 v[2:3], v[6:7], 1 +; GCN-IR-NEXT: v_or_b32_e32 v3, v5, v3 +; GCN-IR-NEXT: v_or_b32_e32 v2, v4, v2 ; GCN-IR-NEXT: BB11_6: ; %Flow2 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7] ; GCN-IR-NEXT: v_mul_lo_u32 v3, v0, v3 Index: llvm/test/CodeGen/AMDGPU/udiv64.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/udiv64.ll +++ llvm/test/CodeGen/AMDGPU/udiv64.ll @@ -365,9 +365,9 @@ ; GCN-IR-NEXT: v_sub_i32_e32 v8, vcc, 63, v6 ; GCN-IR-NEXT: s_mov_b64 s[8:9], 0 ; GCN-IR-NEXT: v_cmp_ge_u64_e32 vcc, v[4:5], v[6:7] -; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[0:1], v8 -; GCN-IR-NEXT: v_mov_b32_e32 v8, 0 -; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 +; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[0:1], v8 +; GCN-IR-NEXT: v_mov_b32_e32 v6, 0 +; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc ; GCN-IR-NEXT: s_xor_b64 s[10:11], exec, s[4:5] ; GCN-IR-NEXT: s_cbranch_execz BB1_5 @@ -380,35 +380,35 @@ ; GCN-IR-NEXT: BB1_3: ; %udiv-do-while ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1 ; GCN-IR-NEXT: v_lshl_b64 v[12:13], v[12:13], 1 -; GCN-IR-NEXT: v_lshrrev_b32_e32 v8, 31, v7 -; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 -; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[6:7], 1 +; GCN-IR-NEXT: v_lshrrev_b32_e32 v6, 31, v9 +; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 +; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1 ; GCN-IR-NEXT: v_add_i32_e32 v4, vcc, -1, v4 ; GCN-IR-NEXT: v_addc_u32_e32 v5, vcc, -1, v5, vcc -; GCN-IR-NEXT: v_or_b32_e32 v12, v12, v8 -; GCN-IR-NEXT: v_or_b32_e32 v7, v11, v7 -; GCN-IR-NEXT: v_or_b32_e32 v6, v10, v6 +; GCN-IR-NEXT: v_or_b32_e32 v12, v12, v6 +; GCN-IR-NEXT: v_or_b32_e32 v9, v11, v9 +; GCN-IR-NEXT: v_or_b32_e32 v8, v10, v8 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[4:5] -; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v0, v12 -; GCN-IR-NEXT: v_subb_u32_e64 v8, s[4:5], v1, v13, s[4:5] +; GCN-IR-NEXT: v_sub_i32_e64 v6, s[4:5], v0, v12 +; GCN-IR-NEXT: v_subb_u32_e64 v6, s[4:5], v1, v13, s[4:5] ; GCN-IR-NEXT: s_or_b64 s[8:9], vcc, s[8:9] -; GCN-IR-NEXT: v_ashrrev_i32_e32 v10, 31, v8 -; GCN-IR-NEXT: v_and_b32_e32 v8, 1, v10 +; GCN-IR-NEXT: v_ashrrev_i32_e32 v10, 31, v6 +; GCN-IR-NEXT: v_and_b32_e32 v6, 1, v10 ; GCN-IR-NEXT: v_and_b32_e32 v11, v10, v3 ; GCN-IR-NEXT: v_and_b32_e32 v10, v10, v2 ; GCN-IR-NEXT: v_sub_i32_e32 v12, vcc, v12, v10 ; GCN-IR-NEXT: v_subb_u32_e32 v13, vcc, v13, v11, vcc -; GCN-IR-NEXT: v_mov_b32_e32 v11, v9 -; GCN-IR-NEXT: v_mov_b32_e32 v10, v8 +; GCN-IR-NEXT: v_mov_b32_e32 v11, v7 +; GCN-IR-NEXT: v_mov_b32_e32 v10, v6 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: s_cbranch_execnz BB1_3 ; GCN-IR-NEXT: ; %bb.4: ; %Flow ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: BB1_5: ; %Flow1 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11] -; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[6:7], 1 -; GCN-IR-NEXT: v_or_b32_e32 v4, v9, v1 -; GCN-IR-NEXT: v_or_b32_e32 v5, v8, v0 +; GCN-IR-NEXT: v_lshl_b64 v[0:1], v[8:9], 1 +; GCN-IR-NEXT: v_or_b32_e32 v4, v7, v1 +; GCN-IR-NEXT: v_or_b32_e32 v5, v6, v0 ; GCN-IR-NEXT: BB1_6: ; %Flow2 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7] ; GCN-IR-NEXT: v_mov_b32_e32 v0, v5 @@ -1934,16 +1934,7 @@ ; GCN-LABEL: v_test_udiv24_pow2_k_den_i64: ; GCN: ; %bb.0: ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) -; GCN-NEXT: v_lshrrev_b32_e32 v0, 8, v1 -; GCN-NEXT: s_mov_b32 s4, 0x47000000 -; GCN-NEXT: v_cvt_f32_u32_e32 v0, v0 -; GCN-NEXT: v_mul_f32_e32 v1, 0x38000000, v0 -; GCN-NEXT: v_trunc_f32_e32 v1, v1 -; GCN-NEXT: v_mad_f32 v0, -v1, s4, v0 -; GCN-NEXT: v_cvt_u32_f32_e32 v1, v1 -; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v0|, s4 -; GCN-NEXT: v_addc_u32_e32 v0, vcc, 0, v1, vcc -; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0 +; GCN-NEXT: v_lshrrev_b32_e32 v0, 23, v1 ; GCN-NEXT: v_mov_b32_e32 v1, 0 ; GCN-NEXT: s_setpc_b64 s[30:31] ; Index: llvm/test/CodeGen/AMDGPU/urem64.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/urem64.ll +++ llvm/test/CodeGen/AMDGPU/urem64.ll @@ -374,9 +374,9 @@ ; GCN-IR-NEXT: v_sub_i32_e32 v8, vcc, 63, v6 ; GCN-IR-NEXT: s_mov_b64 s[8:9], 0 ; GCN-IR-NEXT: v_cmp_ge_u64_e32 vcc, v[4:5], v[6:7] -; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[0:1], v8 -; GCN-IR-NEXT: v_mov_b32_e32 v8, 0 -; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 +; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[0:1], v8 +; GCN-IR-NEXT: v_mov_b32_e32 v6, 0 +; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 ; GCN-IR-NEXT: s_and_saveexec_b64 s[4:5], vcc ; GCN-IR-NEXT: s_xor_b64 s[10:11], exec, s[4:5] ; GCN-IR-NEXT: s_cbranch_execz BB1_5 @@ -389,35 +389,35 @@ ; GCN-IR-NEXT: BB1_3: ; %udiv-do-while ; GCN-IR-NEXT: ; =>This Inner Loop Header: Depth=1 ; GCN-IR-NEXT: v_lshl_b64 v[14:15], v[14:15], 1 -; GCN-IR-NEXT: v_lshrrev_b32_e32 v8, 31, v7 -; GCN-IR-NEXT: v_mov_b32_e32 v9, 0 -; GCN-IR-NEXT: v_lshl_b64 v[6:7], v[6:7], 1 +; GCN-IR-NEXT: v_lshrrev_b32_e32 v6, 31, v9 +; GCN-IR-NEXT: v_mov_b32_e32 v7, 0 +; GCN-IR-NEXT: v_lshl_b64 v[8:9], v[8:9], 1 ; GCN-IR-NEXT: v_add_i32_e32 v4, vcc, -1, v4 ; GCN-IR-NEXT: v_addc_u32_e32 v5, vcc, -1, v5, vcc -; GCN-IR-NEXT: v_or_b32_e32 v14, v14, v8 -; GCN-IR-NEXT: v_or_b32_e32 v7, v13, v7 -; GCN-IR-NEXT: v_or_b32_e32 v6, v12, v6 +; GCN-IR-NEXT: v_or_b32_e32 v14, v14, v6 +; GCN-IR-NEXT: v_or_b32_e32 v9, v13, v9 +; GCN-IR-NEXT: v_or_b32_e32 v8, v12, v8 ; GCN-IR-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[4:5] -; GCN-IR-NEXT: v_sub_i32_e64 v8, s[4:5], v10, v14 -; GCN-IR-NEXT: v_subb_u32_e64 v8, s[4:5], v11, v15, s[4:5] +; GCN-IR-NEXT: v_sub_i32_e64 v6, s[4:5], v10, v14 +; GCN-IR-NEXT: v_subb_u32_e64 v6, s[4:5], v11, v15, s[4:5] ; GCN-IR-NEXT: s_or_b64 s[8:9], vcc, s[8:9] -; GCN-IR-NEXT: v_ashrrev_i32_e32 v12, 31, v8 -; GCN-IR-NEXT: v_and_b32_e32 v8, 1, v12 +; GCN-IR-NEXT: v_ashrrev_i32_e32 v12, 31, v6 +; GCN-IR-NEXT: v_and_b32_e32 v6, 1, v12 ; GCN-IR-NEXT: v_and_b32_e32 v13, v12, v3 ; GCN-IR-NEXT: v_and_b32_e32 v12, v12, v2 ; GCN-IR-NEXT: v_sub_i32_e32 v14, vcc, v14, v12 ; GCN-IR-NEXT: v_subb_u32_e32 v15, vcc, v15, v13, vcc -; GCN-IR-NEXT: v_mov_b32_e32 v13, v9 -; GCN-IR-NEXT: v_mov_b32_e32 v12, v8 +; GCN-IR-NEXT: v_mov_b32_e32 v13, v7 +; GCN-IR-NEXT: v_mov_b32_e32 v12, v6 ; GCN-IR-NEXT: s_andn2_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: s_cbranch_execnz BB1_3 ; GCN-IR-NEXT: ; %bb.4: ; %Flow ; GCN-IR-NEXT: s_or_b64 exec, exec, s[8:9] ; GCN-IR-NEXT: BB1_5: ; %Flow1 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[10:11] -; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[6:7], 1 -; GCN-IR-NEXT: v_or_b32_e32 v5, v9, v5 -; GCN-IR-NEXT: v_or_b32_e32 v4, v8, v4 +; GCN-IR-NEXT: v_lshl_b64 v[4:5], v[8:9], 1 +; GCN-IR-NEXT: v_or_b32_e32 v5, v7, v5 +; GCN-IR-NEXT: v_or_b32_e32 v4, v6, v4 ; GCN-IR-NEXT: BB1_6: ; %Flow2 ; GCN-IR-NEXT: s_or_b64 exec, exec, s[6:7] ; GCN-IR-NEXT: v_mul_lo_u32 v5, v2, v5 @@ -1620,18 +1620,7 @@ ; GCN-LABEL: v_test_urem24_pow2_k_den_i64: ; GCN: ; %bb.0: ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) -; GCN-NEXT: v_lshrrev_b32_e32 v0, 8, v1 -; GCN-NEXT: s_mov_b32 s4, 0x47000000 -; GCN-NEXT: v_cvt_f32_u32_e32 v1, v0 -; GCN-NEXT: v_mul_f32_e32 v2, 0x38000000, v1 -; GCN-NEXT: v_trunc_f32_e32 v2, v2 -; GCN-NEXT: v_mad_f32 v1, -v2, s4, v1 -; GCN-NEXT: v_cvt_u32_f32_e32 v2, v2 -; GCN-NEXT: v_cmp_ge_f32_e64 vcc, |v1|, s4 -; GCN-NEXT: v_addc_u32_e32 v1, vcc, 0, v2, vcc -; GCN-NEXT: v_lshlrev_b32_e32 v1, 15, v1 -; GCN-NEXT: v_sub_i32_e32 v0, vcc, v0, v1 -; GCN-NEXT: v_and_b32_e32 v0, 0xffffff, v0 +; GCN-NEXT: v_bfe_u32 v0, v1, 8, 15 ; GCN-NEXT: v_mov_b32_e32 v1, 0 ; GCN-NEXT: s_setpc_b64 s[30:31] ;