[llvm] r322907 - [InstSimplify] regenerate checks and add tests for commutes; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 15:11:24 PST 2018
Author: spatel
Date: Thu Jan 18 15:11:24 2018
New Revision: 322907
URL: http://llvm.org/viewvc/llvm-project?rev=322907&view=rev
Log:
[InstSimplify] regenerate checks and add tests for commutes; NFC
Modified:
llvm/trunk/test/Transforms/InstSimplify/reassociate.ll
Modified: llvm/trunk/test/Transforms/InstSimplify/reassociate.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/reassociate.ll?rev=322907&r1=322906&r2=322907&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/reassociate.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/reassociate.ll Thu Jan 18 15:11:24 2018
@@ -1,9 +1,9 @@
-; NOTE: Assertions have been autogenerated by update_test_checks.py
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
define i32 @add1(i32 %x) {
; CHECK-LABEL: @add1(
-; CHECK: ret i32 %x
+; CHECK-NEXT: ret i32 [[X:%.*]]
;
; (X + -1) + 1 -> X
%l = add i32 %x, -1
@@ -13,7 +13,7 @@ define i32 @add1(i32 %x) {
define i32 @and1(i32 %x, i32 %y) {
; CHECK-LABEL: @and1(
-; CHECK: [[L:%.*]] = and i32 %x, %y
+; CHECK-NEXT: [[L:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i32 [[L]]
;
; (X & Y) & X -> X & Y
@@ -24,7 +24,7 @@ define i32 @and1(i32 %x, i32 %y) {
define i32 @and2(i32 %x, i32 %y) {
; CHECK-LABEL: @and2(
-; CHECK: [[R:%.*]] = and i32 %x, %y
+; CHECK-NEXT: [[R:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
; X & (X & Y) -> X & Y
@@ -35,7 +35,7 @@ define i32 @and2(i32 %x, i32 %y) {
define i32 @or1(i32 %x, i32 %y) {
; CHECK-LABEL: @or1(
-; CHECK: [[L:%.*]] = or i32 %x, %y
+; CHECK-NEXT: [[L:%.*]] = or i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i32 [[L]]
;
; (X | Y) | X -> X | Y
@@ -46,7 +46,7 @@ define i32 @or1(i32 %x, i32 %y) {
define i32 @or2(i32 %x, i32 %y) {
; CHECK-LABEL: @or2(
-; CHECK: [[R:%.*]] = or i32 %x, %y
+; CHECK-NEXT: [[R:%.*]] = or i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
; X | (X | Y) -> X | Y
@@ -57,7 +57,7 @@ define i32 @or2(i32 %x, i32 %y) {
define i32 @xor1(i32 %x, i32 %y) {
; CHECK-LABEL: @xor1(
-; CHECK: ret i32 %y
+; CHECK-NEXT: ret i32 [[Y:%.*]]
;
; (X ^ Y) ^ X = Y
%l = xor i32 %x, %y
@@ -67,7 +67,7 @@ define i32 @xor1(i32 %x, i32 %y) {
define i32 @xor2(i32 %x, i32 %y) {
; CHECK-LABEL: @xor2(
-; CHECK: ret i32 %y
+; CHECK-NEXT: ret i32 [[Y:%.*]]
;
; X ^ (X ^ Y) = Y
%r = xor i32 %x, %y
@@ -77,7 +77,7 @@ define i32 @xor2(i32 %x, i32 %y) {
define i32 @sub1(i32 %x, i32 %y) {
; CHECK-LABEL: @sub1(
-; CHECK: ret i32 %y
+; CHECK-NEXT: ret i32 [[Y:%.*]]
;
%d = sub i32 %x, %y
%r = sub i32 %x, %d
@@ -86,7 +86,7 @@ define i32 @sub1(i32 %x, i32 %y) {
define i32 @sub2(i32 %x) {
; CHECK-LABEL: @sub2(
-; CHECK: ret i32 -1
+; CHECK-NEXT: ret i32 -1
;
; X - (X + 1) -> -1
%xp1 = add i32 %x, 1
@@ -96,7 +96,7 @@ define i32 @sub2(i32 %x) {
define i32 @sub3(i32 %x, i32 %y) {
; CHECK-LABEL: @sub3(
-; CHECK: ret i32 %x
+; CHECK-NEXT: ret i32 [[X:%.*]]
;
; ((X + 1) + Y) - (Y + 1) -> X
%xp1 = add i32 %x, 1
@@ -106,31 +106,97 @@ define i32 @sub3(i32 %x, i32 %y) {
ret i32 %r
}
-define i32 @sdiv1(i32 %x, i32 %y) {
-; CHECK-LABEL: @sdiv1(
-; CHECK: ret i32 %x
-;
; (no overflow X * Y) / Y -> X
+
+define i32 @mulnsw_sdiv(i32 %x, i32 %y) {
+; CHECK-LABEL: @mulnsw_sdiv(
+; CHECK-NEXT: ret i32 [[X:%.*]]
+;
%mul = mul nsw i32 %x, %y
%r = sdiv i32 %mul, %y
ret i32 %r
}
-define i32 @sdiv2(i32 %x, i32 %y) {
-; CHECK-LABEL: @sdiv2(
-; CHECK: [[DIV:%.*]] = sdiv i32 %x, %y
-; CHECK-NEXT: ret i32 [[DIV]]
+define <2 x i32> @mulnsw_sdiv_commute(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @mulnsw_sdiv_commute(
+; CHECK-NEXT: ret <2 x i32> [[X:%.*]]
+;
+ %mul = mul nsw <2 x i32> %y, %x
+ %r = sdiv <2 x i32> %mul, %y
+ ret <2 x i32> %r
+}
+
+; (no overflow X * Y) / Y -> X
+
+define <2 x i8> @mulnuw_udiv(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @mulnuw_udiv(
+; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
;
+ %mul = mul nuw <2 x i8> %x, %y
+ %r = udiv <2 x i8> %mul, %y
+ ret <2 x i8> %r
+}
+
+define i32 @mulnuw_udiv_commute(i32 %x, i32 %y) {
+; CHECK-LABEL: @mulnuw_udiv_commute(
+; CHECK-NEXT: ret i32 [[X:%.*]]
+;
+ %mul = mul nuw i32 %y, %x
+ %r = udiv i32 %mul, %y
+ ret i32 %r
+}
+
; (((X / Y) * Y) / Y) -> X / Y
+
+define i32 @sdiv_mul_sdiv(i32 %x, i32 %y) {
+; CHECK-LABEL: @sdiv_mul_sdiv(
+; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[DIV]]
+;
%div = sdiv i32 %x, %y
%mul = mul i32 %div, %y
%r = sdiv i32 %mul, %y
ret i32 %r
}
+define i32 @sdiv_mul_sdiv_commute(i32 %x, i32 %y) {
+; CHECK-LABEL: @sdiv_mul_sdiv_commute(
+; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[DIV]]
+;
+ %div = sdiv i32 %x, %y
+ %mul = mul i32 %y, %div
+ %r = sdiv i32 %mul, %y
+ ret i32 %r
+}
+
+; (((X / Y) * Y) / Y) -> X / Y
+
+define i32 @udiv_mul_udiv(i32 %x, i32 %y) {
+; CHECK-LABEL: @udiv_mul_udiv(
+; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[DIV]]
+;
+ %div = udiv i32 %x, %y
+ %mul = mul i32 %div, %y
+ %r = udiv i32 %mul, %y
+ ret i32 %r
+}
+
+define i32 @udiv_mul_udiv_commute(i32 %x, i32 %y) {
+; CHECK-LABEL: @udiv_mul_udiv_commute(
+; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[DIV]]
+;
+ %div = udiv i32 %x, %y
+ %mul = mul i32 %y, %div
+ %r = udiv i32 %mul, %y
+ ret i32 %r
+}
+
define i32 @sdiv3(i32 %x, i32 %y) {
; CHECK-LABEL: @sdiv3(
-; CHECK: ret i32 0
+; CHECK-NEXT: ret i32 0
;
; (X rem Y) / Y -> 0
%rem = srem i32 %x, %y
@@ -140,7 +206,7 @@ define i32 @sdiv3(i32 %x, i32 %y) {
define i32 @sdiv4(i32 %x, i32 %y) {
; CHECK-LABEL: @sdiv4(
-; CHECK: ret i32 %x
+; CHECK-NEXT: ret i32 [[X:%.*]]
;
; (X / Y) * Y -> X if the division is exact
%div = sdiv exact i32 %x, %y
@@ -150,7 +216,7 @@ define i32 @sdiv4(i32 %x, i32 %y) {
define i32 @sdiv5(i32 %x, i32 %y) {
; CHECK-LABEL: @sdiv5(
-; CHECK: ret i32 %x
+; CHECK-NEXT: ret i32 [[X:%.*]]
;
; Y * (X / Y) -> X if the division is exact
%div = sdiv exact i32 %x, %y
@@ -158,32 +224,9 @@ define i32 @sdiv5(i32 %x, i32 %y) {
ret i32 %mul
}
-
-define i32 @udiv1(i32 %x, i32 %y) {
-; CHECK-LABEL: @udiv1(
-; CHECK: ret i32 %x
-;
-; (no overflow X * Y) / Y -> X
- %mul = mul nuw i32 %x, %y
- %r = udiv i32 %mul, %y
- ret i32 %r
-}
-
-define i32 @udiv2(i32 %x, i32 %y) {
-; CHECK-LABEL: @udiv2(
-; CHECK: [[DIV:%.*]] = udiv i32 %x, %y
-; CHECK-NEXT: ret i32 [[DIV]]
-;
-; (((X / Y) * Y) / Y) -> X / Y
- %div = udiv i32 %x, %y
- %mul = mul i32 %div, %y
- %r = udiv i32 %mul, %y
- ret i32 %r
-}
-
define i32 @udiv3(i32 %x, i32 %y) {
; CHECK-LABEL: @udiv3(
-; CHECK: ret i32 0
+; CHECK-NEXT: ret i32 0
;
; (X rem Y) / Y -> 0
%rem = urem i32 %x, %y
@@ -193,7 +236,7 @@ define i32 @udiv3(i32 %x, i32 %y) {
define i32 @udiv4(i32 %x, i32 %y) {
; CHECK-LABEL: @udiv4(
-; CHECK: ret i32 %x
+; CHECK-NEXT: ret i32 [[X:%.*]]
;
; (X / Y) * Y -> X if the division is exact
%div = udiv exact i32 %x, %y
@@ -203,7 +246,7 @@ define i32 @udiv4(i32 %x, i32 %y) {
define i32 @udiv5(i32 %x, i32 %y) {
; CHECK-LABEL: @udiv5(
-; CHECK: ret i32 %x
+; CHECK-NEXT: ret i32 [[X:%.*]]
;
; Y * (X / Y) -> X if the division is exact
%div = udiv exact i32 %x, %y
@@ -213,7 +256,7 @@ define i32 @udiv5(i32 %x, i32 %y) {
define i16 @trunc1(i32 %x) {
; CHECK-LABEL: @trunc1(
-; CHECK: ret i16 1
+; CHECK-NEXT: ret i16 1
;
%y = add i32 %x, 1
%tx = trunc i32 %x to i16
More information about the llvm-commits
mailing list