Index: lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp +++ lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp @@ -184,8 +184,8 @@ } bool AMDGPUCodeGenPrepare::isSigned(const BinaryOperator &I) const { - return I.getOpcode() == Instruction::SDiv || - I.getOpcode() == Instruction::SRem; + return I.getOpcode() == Instruction::AShr || + I.getOpcode() == Instruction::SDiv || I.getOpcode() == Instruction::SRem; } bool AMDGPUCodeGenPrepare::isSigned(const SelectInst &I) const { Index: test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll =================================================================== --- test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll +++ test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll @@ -264,8 +264,8 @@ ; GCN-LABEL: @ashr_i16( ; SI: %r = ashr i16 %a, %b ; SI-NEXT: ret i16 %r -; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32 -; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32 +; VI: %[[A_32:[0-9]+]] = sext i16 %a to i32 +; VI-NEXT: %[[B_32:[0-9]+]] = sext i16 %b to i32 ; VI-NEXT: %[[R_32:[0-9]+]] = ashr i32 %[[A_32]], %[[B_32]] ; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16 ; VI-NEXT: ret i16 %[[R_16]] @@ -277,8 +277,8 @@ ; GCN-LABEL: @ashr_exact_i16( ; SI: %r = ashr exact i16 %a, %b ; SI-NEXT: ret i16 %r -; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32 -; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32 +; VI: %[[A_32:[0-9]+]] = sext i16 %a to i32 +; VI-NEXT: %[[B_32:[0-9]+]] = sext i16 %b to i32 ; VI-NEXT: %[[R_32:[0-9]+]] = ashr exact i32 %[[A_32]], %[[B_32]] ; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16 ; VI-NEXT: ret i16 %[[R_16]] @@ -783,8 +783,8 @@ ; GCN-LABEL: @ashr_3xi16( ; SI: %r = ashr <3 x i16> %a, %b ; SI-NEXT: ret <3 x i16> %r -; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32> -; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32> +; VI: %[[A_32:[0-9]+]] = sext <3 x i16> %a to <3 x i32> +; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i16> %b to <3 x i32> ; VI-NEXT: %[[R_32:[0-9]+]] = ashr <3 x i32> %[[A_32]], %[[B_32]] ; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16> ; VI-NEXT: ret <3 x i16> %[[R_16]] @@ -796,8 +796,8 @@ ; GCN-LABEL: @ashr_exact_3xi16( ; SI: %r = ashr exact <3 x i16> %a, %b ; SI-NEXT: ret <3 x i16> %r -; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32> -; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32> +; VI: %[[A_32:[0-9]+]] = sext <3 x i16> %a to <3 x i32> +; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i16> %b to <3 x i32> ; VI-NEXT: %[[R_32:[0-9]+]] = ashr exact <3 x i32> %[[A_32]], %[[B_32]] ; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16> ; VI-NEXT: ret <3 x i16> %[[R_16]]