[InstCombine] Add more test cases for missing combines of selects with and/or/xor...
authorCraig Topper <craig.topper@gmail.com>
Tue, 4 Apr 2017 17:48:08 +0000 (17:48 +0000)
committerCraig Topper <craig.topper@gmail.com>
Tue, 4 Apr 2017 17:48:08 +0000 (17:48 +0000)
llvm-svn: 299450

llvm/test/Transforms/InstCombine/and.ll
llvm/test/Transforms/InstCombine/or.ll
llvm/test/Transforms/InstCombine/xor.ll

index b433574974a94ddcc0ba19268350efcea2f1579d..9a23342feb12c4a28a377f0673943ccbe1e9fd32 100644 (file)
@@ -494,3 +494,34 @@ define i64 @test39(i32 %X) {
   %res = and i64 %zsub, 240
   ret i64 %res
 }
+
+define i32 @test40(i1 %C) {
+; CHECK-LABEL: @test40(
+; CHECK-NEXT:    [[A:%.*]] = select i1 [[C:%.*]], i32 104, i32 10
+; CHECK-NEXT:    ret i32 [[A]]
+;
+  %A = select i1 %C, i32 1000, i32 10
+  %V = and i32 %A, 123
+  ret i32 %V
+}
+
+define <2 x i32> @test40vec(i1 %C) {
+; CHECK-LABEL: @test40vec(
+; CHECK-NEXT:    [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> <i32 104, i32 104>, <2 x i32> <i32 10, i32 10>
+; CHECK-NEXT:    ret <2 x i32> [[A]]
+;
+  %A = select i1 %C, <2 x i32> <i32 1000, i32 1000>, <2 x i32> <i32 10, i32 10>
+  %V = and <2 x i32> %A, <i32 123, i32 123>
+  ret <2 x i32> %V
+}
+
+define <2 x i32> @test40vec2(i1 %C) {
+; CHECK-LABEL: @test40vec2(
+; CHECK-NEXT:    [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> <i32 1000, i32 2500>, <2 x i32> <i32 10, i32 30>
+; CHECK-NEXT:    [[V:%.*]] = and <2 x i32> [[A]], <i32 123, i32 333>
+; CHECK-NEXT:    ret <2 x i32> [[V]]
+;
+  %A = select i1 %C, <2 x i32> <i32 1000, i32 2500>, <2 x i32> <i32 10, i32 30>
+  %V = and <2 x i32> %A, <i32 123, i32 333>
+  ret <2 x i32> %V
+}
index 2ca3997d135791d7485776cb2e32bdf03efbb3f8..24431095b3695b26f758f78152968995f8cbfe77 100644 (file)
@@ -722,3 +722,14 @@ define <2 x i32> @test49vec(i1 %C) {
   %V = or <2 x i32> %A, <i32 123, i32 123>
   ret <2 x i32> %V
 }
+
+define <2 x i32> @test49vec2(i1 %C) {
+; CHECK-LABEL: @test49vec2(
+; CHECK-NEXT:    [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> <i32 1000, i32 2500>, <2 x i32> <i32 10, i32 30>
+; CHECK-NEXT:    [[V:%.*]] = or <2 x i32> [[A]], <i32 123, i32 333>
+; CHECK-NEXT:    ret <2 x i32> [[V]]
+;
+  %A = select i1 %C, <2 x i32> <i32 1000, i32 2500>, <2 x i32> <i32 10, i32 30>
+  %V = or <2 x i32> %A, <i32 123, i32 333>
+  ret <2 x i32> %V
+}
index 374361030f2a73e0996f5b65566b7b7f9f0c015b..444dfd1d29f516299d06c8184d52a4864bc38366 100644 (file)
@@ -373,3 +373,14 @@ define <2 x i32> @test29vec(i1 %C) {
   %V = xor <2 x i32> %A, <i32 123, i32 123>
   ret <2 x i32> %V
 }
+
+define <2 x i32> @test29vec2(i1 %C) {
+; CHECK-LABEL: @test29vec2(
+; CHECK-NEXT:    [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> <i32 1000, i32 2500>, <2 x i32> <i32 10, i32 30>
+; CHECK-NEXT:    [[V:%.*]] = xor <2 x i32> [[A]], <i32 123, i32 333>
+; CHECK-NEXT:    ret <2 x i32> [[V]]
+;
+  %A = select i1 %C, <2 x i32> <i32 1000, i32 2500>, <2 x i32> <i32 10, i32 30>
+  %V = xor <2 x i32> %A, <i32 123, i32 333>
+  ret <2 x i32> %V
+}