Index: lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def =================================================================== --- lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def +++ lib/Target/AMDGPU/AMDGPUGenRegisterBankInfo.def @@ -16,13 +16,13 @@ enum PartialMappingIdx { None = - 1, - PM_SGPR1 = 0, - PM_SGPR16 = 4, - PM_SGPR32 = 5, - PM_SGPR64 = 6, - PM_SGPR128 = 7, - PM_SGPR256 = 8, - PM_SGPR512 = 9, + PM_SGPR1 = 4, + PM_SGPR16 = 5, + PM_SGPR32 = 6, + PM_SGPR64 = 7, + PM_SGPR128 = 8, + PM_SGPR256 = 9, + PM_SGPR512 = 10, PM_VGPR1 = 10, PM_VGPR16 = 14, PM_VGPR32 = 15, @@ -37,13 +37,14 @@ const RegisterBankInfo::PartialMapping PartMappings[] { // StartIdx, Length, RegBank {0, 1, SCCRegBank}, + {0, 1, SGPRRegBank}, // SGPR begin {0, 16, SGPRRegBank}, {0, 32, SGPRRegBank}, {0, 64, SGPRRegBank}, {0, 128, SGPRRegBank}, {0, 256, SGPRRegBank}, {0, 512, SGPRRegBank}, - {0, 1, SGPRRegBank}, + {0, 1, VGPRRegBank}, // VGPR begin {0, 16, VGPRRegBank}, {0, 32, VGPRRegBank}, {0, 64, VGPRRegBank}, @@ -56,7 +57,7 @@ const RegisterBankInfo::ValueMapping ValMappings[] { {&PartMappings[0], 1}, - {nullptr, 0}, + {nullptr, 0}, // Illegal power of 2 sizes {nullptr, 0}, {nullptr, 0}, {&PartMappings[1], 1}, @@ -66,21 +67,22 @@ {&PartMappings[5], 1}, {&PartMappings[6], 1}, {&PartMappings[7], 1}, + {nullptr, 0}, // Illegal power of 2 sizes {nullptr, 0}, {nullptr, 0}, - {nullptr, 0}, - {&PartMappings[8], 1}, {&PartMappings[9], 1}, {&PartMappings[10], 1}, {&PartMappings[11], 1}, {&PartMappings[12], 1}, {&PartMappings[13], 1}, {&PartMappings[14], 1}, - {&PartMappings[15], 1} + {&PartMappings[15], 1}, + {&PartMappings[16], 1} }; enum ValueMappingIdx { - SGPRStartIdx = 0, + SCCStartIdx = 0, + SGPRStartIdx = 1, VGPRStartIdx = 10 }; @@ -89,7 +91,9 @@ unsigned Idx; switch (Size) { case 1: - Idx = BankID == AMDGPU::SCCRegBankID ? PM_SGPR1 : PM_VGPR1; + if (BankID == AMDGPU::SCCRegBankID) + return &ValMappings[0]; + Idx = BankID == AMDGPU::SGPRRegBankID ? PM_SGPR1 : PM_VGPR1; break; case 96: Idx = BankID == AMDGPU::SGPRRegBankID ? PM_SGPR96 : PM_VGPR96; Index: test/CodeGen/AMDGPU/GlobalISel/regbankselect-trunc.mir =================================================================== --- test/CodeGen/AMDGPU/GlobalISel/regbankselect-trunc.mir +++ test/CodeGen/AMDGPU/GlobalISel/regbankselect-trunc.mir @@ -10,7 +10,7 @@ bb.0: liveins: $sgpr0_sgpr1 ; CHECK-LABEL: name: trunc_i64_to_i32_s - ; CHECK: [[COPY:%[0-9]+]]:sgpr(s64) = COPY $sgpr0 + ; CHECK: [[COPY:%[0-9]+]]:sgpr(s64) = COPY $sgpr0_sgpr1 ; CHECK: [[TRUNC:%[0-9]+]]:sgpr(s32) = G_TRUNC [[COPY]](s64) %0:_(s64) = COPY $sgpr0_sgpr1 %1:_(s32) = G_TRUNC %0 @@ -24,8 +24,63 @@ bb.0: liveins: $vgpr0_vgpr1 ; CHECK-LABEL: name: trunc_i64_to_i32_v - ; CHECK: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0 + ; CHECK: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1 ; CHECK: [[TRUNC:%[0-9]+]]:vgpr(s32) = G_TRUNC [[COPY]](s64) %0:_(s64) = COPY $vgpr0_vgpr1 %1:_(s32) = G_TRUNC %0 ... +--- +name: trunc_i64_to_i1_s +legalized: true + +body: | + bb.0: + liveins: $sgpr0_sgpr1 + ; CHECK-LABEL: name: trunc_i64_to_i1_s + ; CHECK: [[COPY:%[0-9]+]]:sgpr(s64) = COPY $sgpr0_sgpr1 + ; CHECK: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY]](s64) + %0:_(s64) = COPY $sgpr0_sgpr1 + %1:_(s1) = G_TRUNC %0 +... + +--- +name: trunc_i64_to_i1_v +legalized: true + +body: | + bb.0: + liveins: $vgpr0_vgpr1 + ; CHECK-LABEL: name: trunc_i64_to_i1_v + ; CHECK: [[COPY:%[0-9]+]]:vgpr(s64) = COPY $vgpr0_vgpr1 + ; CHECK: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY]](s64) + %0:_(s64) = COPY $vgpr0_vgpr1 + %1:_(s1) = G_TRUNC %0 +... + +--- +name: trunc_i32_to_i1_s +legalized: true + +body: | + bb.0: + liveins: $sgpr0 + ; CHECK-LABEL: name: trunc_i32_to_i1_s + ; CHECK: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0 + ; CHECK: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY]](s32) + %0:_(s32) = COPY $sgpr0 + %1:_(s1) = G_TRUNC %0 +... + +--- +name: trunc_i32_to_i1_v +legalized: true + +body: | + bb.0: + liveins: $vgpr0 + ; CHECK-LABEL: name: trunc_i32_to_i1_v + ; CHECK: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 + ; CHECK: [[TRUNC:%[0-9]+]]:sgpr(s1) = G_TRUNC [[COPY]](s32) + %0:_(s32) = COPY $vgpr0 + %1:_(s1) = G_TRUNC %0 +...