[llvm] r330975 - [NFC][InstCombine] rem.ll: add a few commutative tests.
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 26 11:44:37 PDT 2018
Author: lebedevri
Date: Thu Apr 26 11:44:37 2018
New Revision: 330975
URL: http://llvm.org/viewvc/llvm-project?rev=330975&view=rev
Log:
[NFC][InstCombine] rem.ll: add a few commutative tests.
This closes a gap in missing test coverage in
isKnownToBeAPowerOfTwo() from ValueTracking.cpp
Modified:
llvm/trunk/test/Transforms/InstCombine/rem.ll
Modified: llvm/trunk/test/Transforms/InstCombine/rem.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/rem.ll?rev=330975&r1=330974&r2=330975&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/rem.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/rem.ll Thu Apr 26 11:44:37 2018
@@ -386,6 +386,60 @@ define i32 @test19(i32 %x, i32 %y) {
ret i32 %E
}
+define i32 @test19_commutative0(i32 %x, i32 %y) {
+; CHECK-LABEL: @test19_commutative0(
+; CHECK-NEXT: [[A:%.*]] = shl i32 1, [[X:%.*]]
+; CHECK-NEXT: [[B:%.*]] = shl i32 1, [[Y:%.*]]
+; CHECK-NEXT: [[C:%.*]] = and i32 [[B]], [[A]]
+; CHECK-NEXT: [[D:%.*]] = add i32 [[C]], [[A]]
+; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[D]], -1
+; CHECK-NEXT: [[E:%.*]] = and i32 [[TMP1]], [[Y]]
+; CHECK-NEXT: ret i32 [[E]]
+;
+ %A = shl i32 1, %x
+ %B = shl i32 1, %y
+ %C = and i32 %B, %A ; swapped
+ %D = add i32 %C, %A
+ %E = urem i32 %y, %D
+ ret i32 %E
+}
+
+define i32 @test19_commutative1(i32 %x, i32 %y) {
+; CHECK-LABEL: @test19_commutative1(
+; CHECK-NEXT: [[A:%.*]] = shl i32 1, [[X:%.*]]
+; CHECK-NEXT: [[B:%.*]] = shl i32 1, [[Y:%.*]]
+; CHECK-NEXT: [[C:%.*]] = and i32 [[A]], [[B]]
+; CHECK-NEXT: [[D:%.*]] = add i32 [[A]], [[C]]
+; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[D]], -1
+; CHECK-NEXT: [[E:%.*]] = and i32 [[TMP1]], [[Y]]
+; CHECK-NEXT: ret i32 [[E]]
+;
+ %A = shl i32 1, %x
+ %B = shl i32 1, %y
+ %C = and i32 %A, %B
+ %D = add i32 %A, %C ; swapped
+ %E = urem i32 %y, %D
+ ret i32 %E
+}
+
+define i32 @test19_commutative2(i32 %x, i32 %y) {
+; CHECK-LABEL: @test19_commutative2(
+; CHECK-NEXT: [[A:%.*]] = shl i32 1, [[X:%.*]]
+; CHECK-NEXT: [[B:%.*]] = shl i32 1, [[Y:%.*]]
+; CHECK-NEXT: [[C:%.*]] = and i32 [[B]], [[A]]
+; CHECK-NEXT: [[D:%.*]] = add i32 [[A]], [[C]]
+; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[D]], -1
+; CHECK-NEXT: [[E:%.*]] = and i32 [[TMP1]], [[Y]]
+; CHECK-NEXT: ret i32 [[E]]
+;
+ %A = shl i32 1, %x
+ %B = shl i32 1, %y
+ %C = and i32 %B, %A ; swapped
+ %D = add i32 %A, %C ; swapped
+ %E = urem i32 %y, %D
+ ret i32 %E
+}
+
define <2 x i64> @test20(<2 x i64> %X, <2 x i1> %C) {
; CHECK-LABEL: @test20(
; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[C:%.*]], <2 x i64> <i64 1, i64 2>, <2 x i64> zeroinitializer
More information about the llvm-commits
mailing list