summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/pr33765.ll5
-rw-r--r--llvm/test/Transforms/InstCombine/trunc-binop-ext.ll102
2 files changed, 43 insertions, 64 deletions
diff --git a/llvm/test/Transforms/InstCombine/pr33765.ll b/llvm/test/Transforms/InstCombine/pr33765.ll
index 5aa99bbf7cb..0b29d67d056 100644
--- a/llvm/test/Transforms/InstCombine/pr33765.ll
+++ b/llvm/test/Transforms/InstCombine/pr33765.ll
@@ -10,9 +10,8 @@ define void @patatino(i8 %beth) {
; CHECK: if.then9:
; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[CONV]], [[CONV]]
; CHECK-NEXT: [[TINKY:%.*]] = load i16, i16* @glob, align 2
-; CHECK-NEXT: [[CONV131:%.*]] = zext i16 [[TINKY]] to i32
-; CHECK-NEXT: [[AND:%.*]] = and i32 [[MUL]], [[CONV131]]
-; CHECK-NEXT: [[CONV14:%.*]] = trunc i32 [[AND]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[MUL]] to i16
+; CHECK-NEXT: [[CONV14:%.*]] = and i16 [[TINKY]], [[TMP1]]
; CHECK-NEXT: store i16 [[CONV14]], i16* @glob, align 2
; CHECK-NEXT: ret void
;
diff --git a/llvm/test/Transforms/InstCombine/trunc-binop-ext.ll b/llvm/test/Transforms/InstCombine/trunc-binop-ext.ll
index bbd2357f1a7..59336425d5f 100644
--- a/llvm/test/Transforms/InstCombine/trunc-binop-ext.ll
+++ b/llvm/test/Transforms/InstCombine/trunc-binop-ext.ll
@@ -2,9 +2,8 @@
define i16 @narrow_sext_and(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_sext_and(
-; CHECK-NEXT: [[X321:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = and i32 [[X321]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = and i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = sext i16 %x16 to i32
@@ -15,9 +14,8 @@ define i16 @narrow_sext_and(i16 %x16, i32 %y32) {
define i16 @narrow_zext_and(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_zext_and(
-; CHECK-NEXT: [[X32:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = and i32 [[X32]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = and i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = zext i16 %x16 to i32
@@ -28,9 +26,8 @@ define i16 @narrow_zext_and(i16 %x16, i32 %y32) {
define i16 @narrow_sext_or(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_sext_or(
-; CHECK-NEXT: [[X321:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = or i32 [[X321]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = or i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = sext i16 %x16 to i32
@@ -41,9 +38,8 @@ define i16 @narrow_sext_or(i16 %x16, i32 %y32) {
define i16 @narrow_zext_or(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_zext_or(
-; CHECK-NEXT: [[X32:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = or i32 [[X32]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = or i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = zext i16 %x16 to i32
@@ -54,9 +50,8 @@ define i16 @narrow_zext_or(i16 %x16, i32 %y32) {
define i16 @narrow_sext_xor(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_sext_xor(
-; CHECK-NEXT: [[X321:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = xor i32 [[X321]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = xor i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = sext i16 %x16 to i32
@@ -67,9 +62,8 @@ define i16 @narrow_sext_xor(i16 %x16, i32 %y32) {
define i16 @narrow_zext_xor(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_zext_xor(
-; CHECK-NEXT: [[X32:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = xor i32 [[X32]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = xor i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = zext i16 %x16 to i32
@@ -80,9 +74,8 @@ define i16 @narrow_zext_xor(i16 %x16, i32 %y32) {
define i16 @narrow_sext_add(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_sext_add(
-; CHECK-NEXT: [[X321:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = add i32 [[X321]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = add i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = sext i16 %x16 to i32
@@ -93,9 +86,8 @@ define i16 @narrow_sext_add(i16 %x16, i32 %y32) {
define i16 @narrow_zext_add(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_zext_add(
-; CHECK-NEXT: [[X32:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = add i32 [[X32]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = add i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = zext i16 %x16 to i32
@@ -106,9 +98,8 @@ define i16 @narrow_zext_add(i16 %x16, i32 %y32) {
define i16 @narrow_sext_mul(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_sext_mul(
-; CHECK-NEXT: [[X32:%.*]] = sext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = mul i32 [[X32]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = mul i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = sext i16 %x16 to i32
@@ -119,9 +110,8 @@ define i16 @narrow_sext_mul(i16 %x16, i32 %y32) {
define i16 @narrow_zext_mul(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_zext_mul(
-; CHECK-NEXT: [[X32:%.*]] = zext i16 %x16 to i32
-; CHECK-NEXT: [[B:%.*]] = mul i32 [[X32]], %y32
-; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
+; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
+; CHECK-NEXT: [[R:%.*]] = mul i16 [[TMP1]], %x16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = zext i16 %x16 to i32
@@ -130,15 +120,14 @@ define i16 @narrow_zext_mul(i16 %x16, i32 %y32) {
ret i16 %r
}
-; Verify that the commuted patterns work. The div is to ensure that complexity-based
+; Verify that the commuted patterns work. The div is to ensure that complexity-based
; canonicalization doesn't swap the binop operands. Use vector types to show those work too.
define <2 x i16> @narrow_sext_and_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_sext_and_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:%.*]] = and <2 x i32> [[Y32OP0]], [[X321]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = and <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -151,9 +140,8 @@ define <2 x i16> @narrow_sext_and_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_zext_and_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_zext_and_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:%.*]] = and <2 x i32> [[Y32OP0]], [[X32]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = and <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -166,9 +154,8 @@ define <2 x i16> @narrow_zext_and_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_sext_or_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_sext_or_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:%.*]] = or <2 x i32> [[Y32OP0]], [[X321]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = or <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -181,9 +168,8 @@ define <2 x i16> @narrow_sext_or_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_zext_or_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_zext_or_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:%.*]] = or <2 x i32> [[Y32OP0]], [[X32]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = or <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -196,9 +182,8 @@ define <2 x i16> @narrow_zext_or_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_sext_xor_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_sext_xor_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:%.*]] = xor <2 x i32> [[Y32OP0]], [[X321]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = xor <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -211,9 +196,8 @@ define <2 x i16> @narrow_sext_xor_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_zext_xor_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_zext_xor_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:%.*]] = xor <2 x i32> [[Y32OP0]], [[X32]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = xor <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -226,9 +210,8 @@ define <2 x i16> @narrow_zext_xor_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_sext_add_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_sext_add_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:%.*]] = add <2 x i32> [[Y32OP0]], [[X321]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = add <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -241,9 +224,8 @@ define <2 x i16> @narrow_sext_add_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_zext_add_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_zext_add_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:%.*]] = add <2 x i32> [[Y32OP0]], [[X32]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = add <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -256,9 +238,8 @@ define <2 x i16> @narrow_zext_add_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_sext_mul_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_sext_mul_commute(
; CHECK-NEXT: [[Y32OP0:%.*]] = sdiv <2 x i32> %y32, <i32 7, i32 -17>
-; CHECK-NEXT: [[X32:%.*]] = sext <2 x i16> %x16 to <2 x i32>
-; CHECK-NEXT: [[B:%.*]] = mul <2 x i32> [[Y32OP0]], [[X32]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = mul <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
@@ -271,9 +252,8 @@ define <2 x i16> @narrow_sext_mul_commute(<2 x i16> %x16, <2 x i32> %y32) {
define <2 x i16> @narrow_zext_mul_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_zext_mul_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:%.*]] = mul <2 x i32> [[Y32OP0]], [[X32]]
-; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
+; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i32> [[Y32OP0]] to <2 x i16>
+; CHECK-NEXT: [[R:%.*]] = mul <2 x i16> [[TMP1]], %x16
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
OpenPOWER on IntegriCloud