[llvm] r303310 - [InstCombine] add test for missing icmp bool fold; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 15:20:03 PDT 2017


Author: spatel
Date: Wed May 17 17:20:02 2017
New Revision: 303310

URL: http://llvm.org/viewvc/llvm-project?rev=303310&view=rev
Log:
[InstCombine] add test for missing icmp bool fold; NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/set.ll

Modified: llvm/trunk/test/Transforms/InstCombine/set.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/set.ll?rev=303310&r1=303309&r2=303310&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/set.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/set.ll Wed May 17 17:20:02 2017
@@ -110,8 +110,8 @@ define i1 @test12(i1 %A) {
 
 define i1 @test13(i1 %A, i1 %B) {
 ; CHECK-LABEL: @test13(
-; CHECK-NEXT:    [[CTMP:%.*]] = xor i1 %B, true
-; CHECK-NEXT:    [[C:%.*]] = or i1 [[CTMP]], %A
+; CHECK-NEXT:    [[TMP1:%.*]] = xor i1 %B, true
+; CHECK-NEXT:    [[C:%.*]] = or i1 [[TMP1]], %A
 ; CHECK-NEXT:    ret i1 [[C]]
 ;
   %C = icmp uge i1 %A, %B
@@ -120,8 +120,8 @@ define i1 @test13(i1 %A, i1 %B) {
 
 define <2 x i1> @test13vec(<2 x i1> %A, <2 x i1> %B) {
 ; CHECK-LABEL: @test13vec(
-; CHECK-NEXT:    [[CTMP:%.*]] = xor <2 x i1> %B, <i1 true, i1 true>
-; CHECK-NEXT:    [[C:%.*]] = or <2 x i1> [[CTMP]], %A
+; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i1> %B, <i1 true, i1 true>
+; CHECK-NEXT:    [[C:%.*]] = or <2 x i1> [[TMP1]], %A
 ; CHECK-NEXT:    ret <2 x i1> [[C]]
 ;
   %C = icmp uge <2 x i1> %A, %B
@@ -130,8 +130,8 @@ define <2 x i1> @test13vec(<2 x i1> %A,
 
 define i1 @test14(i1 %A, i1 %B) {
 ; CHECK-LABEL: @test14(
-; CHECK-NEXT:    [[CTMP:%.*]] = xor i1 %A, %B
-; CHECK-NEXT:    [[C:%.*]] = xor i1 [[CTMP]], true
+; CHECK-NEXT:    [[TMP1:%.*]] = xor i1 %A, %B
+; CHECK-NEXT:    [[C:%.*]] = xor i1 [[TMP1]], true
 ; CHECK-NEXT:    ret i1 [[C]]
 ;
   %C = icmp eq i1 %A, %B
@@ -140,14 +140,30 @@ define i1 @test14(i1 %A, i1 %B) {
 
 define <3 x i1> @test14vec(<3 x i1> %A, <3 x i1> %B) {
 ; CHECK-LABEL: @test14vec(
-; CHECK-NEXT:    [[CTMP:%.*]] = xor <3 x i1> %A, %B
-; CHECK-NEXT:    [[C:%.*]] = xor <3 x i1> [[CTMP]], <i1 true, i1 true, i1 true>
+; CHECK-NEXT:    [[TMP1:%.*]] = xor <3 x i1> %A, %B
+; CHECK-NEXT:    [[C:%.*]] = xor <3 x i1> [[TMP1]], <i1 true, i1 true, i1 true>
 ; CHECK-NEXT:    ret <3 x i1> [[C]]
 ;
   %C = icmp eq <3 x i1> %A, %B
   ret <3 x i1> %C
 }
 
+; FIXME: Not recognizing the icmp bool with constant exposes a missing fold.
+
+define i1 @bool_eq0(i64 %a) {
+; CHECK-LABEL: @bool_eq0(
+; CHECK-NEXT:    [[B:%.*]] = icmp sgt i64 %a, 0
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i64 %a, 1
+; CHECK-NEXT:    [[AND:%.*]] = xor i1 [[C]], [[B]]
+; CHECK-NEXT:    ret i1 [[AND]]
+;
+  %b = icmp sgt i64 %a, 0
+  %c = icmp eq i64 %a, 1
+  %notc = icmp eq i1 %c, false
+  %and = and i1 %b, %notc
+  ret i1 %and
+}
+
 define i1 @test16(i32 %A) {
 ; CHECK-LABEL: @test16(
 ; CHECK-NEXT:    ret i1 false
@@ -191,8 +207,8 @@ endif:
 
 define i1 @test19(i1 %A, i1 %B) {
 ; CHECK-LABEL: @test19(
-; CHECK-NEXT:    [[CTMP:%.*]] = xor i1 %A, %B
-; CHECK-NEXT:    [[C:%.*]] = xor i1 [[CTMP]], true
+; CHECK-NEXT:    [[TMP1:%.*]] = xor i1 %A, %B
+; CHECK-NEXT:    [[C:%.*]] = xor i1 [[TMP1]], true
 ; CHECK-NEXT:    ret i1 [[C]]
 ;
   %a = zext i1 %A to i32




More information about the llvm-commits mailing list