[llvm] r318342 - [InstCombine] add sub narrowing tests; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 14:19:55 PST 2017


Author: spatel
Date: Wed Nov 15 14:19:55 2017
New Revision: 318342

URL: http://llvm.org/viewvc/llvm-project?rev=318342&view=rev
Log:
[InstCombine] add sub narrowing tests; NFC

This might be the root cause of PR35295:
https://bugs.llvm.org/show_bug.cgi?id=35295

Modified:
    llvm/trunk/test/Transforms/InstCombine/trunc-binop-ext.ll

Modified: llvm/trunk/test/Transforms/InstCombine/trunc-binop-ext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/trunc-binop-ext.ll?rev=318342&r1=318341&r2=318342&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/trunc-binop-ext.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/trunc-binop-ext.ll Wed Nov 15 14:19:55 2017
@@ -96,6 +96,32 @@ define i16 @narrow_zext_add(i16 %x16, i3
   ret i16 %r
 }
 
+define i16 @narrow_sext_sub(i16 %x16, i32 %y32) {
+; CHECK-LABEL: @narrow_sext_sub(
+; CHECK-NEXT:    [[X321:%.*]] = zext i16 %x16 to i32
+; CHECK-NEXT:    [[B:%.*]] = sub i32 [[X321]], %y32
+; CHECK-NEXT:    [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT:    ret i16 [[R]]
+;
+  %x32 = sext i16 %x16 to i32
+  %b = sub i32 %x32, %y32
+  %r = trunc i32 %b to i16
+  ret i16 %r
+}
+
+define i16 @narrow_zext_sub(i16 %x16, i32 %y32) {
+; CHECK-LABEL: @narrow_zext_sub(
+; CHECK-NEXT:    [[X32:%.*]] = zext i16 %x16 to i32
+; CHECK-NEXT:    [[B:%.*]] = sub i32 [[X32]], %y32
+; CHECK-NEXT:    [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT:    ret i16 [[R]]
+;
+  %x32 = zext i16 %x16 to i32
+  %b = sub i32 %x32, %y32
+  %r = trunc i32 %b to i16
+  ret i16 %r
+}
+
 define i16 @narrow_sext_mul(i16 %x16, i32 %y32) {
 ; CHECK-LABEL: @narrow_sext_mul(
 ; CHECK-NEXT:    [[TMP1:%.*]] = trunc i32 %y32 to i16
@@ -234,6 +260,36 @@ define <2 x i16> @narrow_zext_add_commut
   %r = trunc <2 x i32> %b to <2 x i16>
   ret <2 x i16> %r
 }
+
+define <2 x i16> @narrow_sext_sub_commute(<2 x i16> %x16, <2 x i32> %y32) {
+; CHECK-LABEL: @narrow_sext_sub_commute(
+; CHECK-NEXT:    [[Y32OP0:%.*]] = sdiv <2 x i32> %y32, <i32 7, i32 -17>
+; CHECK-NEXT:    [[X321:%.*]] = zext <2 x i16> %x16 to <2 x i32>
+; CHECK-NEXT:    [[B:%.*]] = sub <2 x i32> [[Y32OP0]], [[X321]]
+; CHECK-NEXT:    [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT:    ret <2 x i16> [[R]]
+;
+  %y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
+  %x32 = sext <2 x i16> %x16 to <2 x i32>
+  %b = sub <2 x i32> %y32op0, %x32
+  %r = trunc <2 x i32> %b to <2 x i16>
+  ret <2 x i16> %r
+}
+
+define <2 x i16> @narrow_zext_sub_commute(<2 x i16> %x16, <2 x i32> %y32) {
+; CHECK-LABEL: @narrow_zext_sub_commute(
+; CHECK-NEXT:    [[Y32OP0:%.*]] = sdiv <2 x i32> %y32, <i32 7, i32 -17>
+; CHECK-NEXT:    [[X32:%.*]] = zext <2 x i16> %x16 to <2 x i32>
+; CHECK-NEXT:    [[B:%.*]] = sub <2 x i32> [[Y32OP0]], [[X32]]
+; CHECK-NEXT:    [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT:    ret <2 x i16> [[R]]
+;
+  %y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
+  %x32 = zext <2 x i16> %x16 to <2 x i32>
+  %b = sub <2 x i32> %y32op0, %x32
+  %r = trunc <2 x i32> %b to <2 x i16>
+  ret <2 x i16> %r
+}
 
 define <2 x i16> @narrow_sext_mul_commute(<2 x i16> %x16, <2 x i32> %y32) {
 ; CHECK-LABEL: @narrow_sext_mul_commute(




More information about the llvm-commits mailing list