From: Konstantin Zhuravlyov Date: Mon, 3 Oct 2016 18:29:01 +0000 (+0000) Subject: [AMDGPU] Sign extend AShr when promoting (instead of zero extending) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e8f5fd9f825024ce679de9d429d2f377659f95d;p=llvm [AMDGPU] Sign extend AShr when promoting (instead of zero extending) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283130 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp b/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp index 843001ae0f1..88b1be2e6b8 100644 --- a/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp +++ b/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp @@ -172,8 +172,8 @@ bool AMDGPUCodeGenPrepare::isI32Ty(const Type *T) const { } 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 { diff --git a/test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll b/test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll index ed512b4ddd9..a4a882ed844 100644 --- a/test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll +++ b/test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll @@ -226,8 +226,8 @@ define i16 @lshr_exact_i16(i16 %a, i16 %b) { } ; VI-LABEL: @ashr_i16( -; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32 -; VI: %[[B_32:[0-9]+]] = zext i16 %b to i32 +; VI: %[[A_32:[0-9]+]] = sext i16 %a to i32 +; VI: %[[B_32:[0-9]+]] = sext i16 %b to i32 ; VI: %[[R_32:[0-9]+]] = ashr i32 %[[A_32]], %[[B_32]] ; VI: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16 ; VI: ret i16 %[[R_16]] @@ -237,8 +237,8 @@ define i16 @ashr_i16(i16 %a, i16 %b) { } ; VI-LABEL: @ashr_exact_i16( -; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32 -; VI: %[[B_32:[0-9]+]] = zext i16 %b to i32 +; VI: %[[A_32:[0-9]+]] = sext i16 %a to i32 +; VI: %[[B_32:[0-9]+]] = sext i16 %b to i32 ; VI: %[[R_32:[0-9]+]] = ashr exact i32 %[[A_32]], %[[B_32]] ; VI: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16 ; VI: ret i16 %[[R_16]] @@ -651,8 +651,8 @@ define <3 x i16> @lshr_exact_3xi16(<3 x i16> %a, <3 x i16> %b) { } ; VI-LABEL: @ashr_3xi16( -; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32> -; VI: %[[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: %[[B_32:[0-9]+]] = sext <3 x i16> %b to <3 x i32> ; VI: %[[R_32:[0-9]+]] = ashr <3 x i32> %[[A_32]], %[[B_32]] ; VI: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16> ; VI: ret <3 x i16> %[[R_16]] @@ -662,8 +662,8 @@ define <3 x i16> @ashr_3xi16(<3 x i16> %a, <3 x i16> %b) { } ; VI-LABEL: @ashr_exact_3xi16( -; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32> -; VI: %[[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: %[[B_32:[0-9]+]] = sext <3 x i16> %b to <3 x i32> ; VI: %[[R_32:[0-9]+]] = ashr exact <3 x i32> %[[A_32]], %[[B_32]] ; VI: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16> ; VI: ret <3 x i16> %[[R_16]]