]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Sign extend AShr when promoting (instead of zero extending)
authorKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Mon, 3 Oct 2016 18:29:01 +0000 (18:29 +0000)
committerKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>
Mon, 3 Oct 2016 18:29:01 +0000 (18:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283130 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
test/CodeGen/AMDGPU/amdgpu-codegenprepare-i16-to-i32.ll

index 843001ae0f19a4c727ca91edfbde69e98d183fef..88b1be2e6b82f32885c2fb9af145a2e6308bcb41 100644 (file)
@@ -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 {
index ed512b4ddd9a9e2f2251827262a904f26df42d5f..a4a882ed844a3f5094b13076e5cdce6d62d7a30c 100644 (file)
@@ -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]]