ret i1 %res
}
-; We currently require recursion through first operand
-; (Though for add, which is cummutable, we could support either)
define i1 @recurrence_add_op_order(i8 %A) {
; CHECK-LABEL: @recurrence_add_op_order(
; CHECK-NEXT: entry:
ret i1 %res
}
+define i1 @recurrence_sub_op_order(i8 %A) {
+; CHECK-LABEL: @recurrence_sub_op_order(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[B:%.*]] = add i8 [[A:%.*]], 1
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[A_IV:%.*]] = phi i8 [ [[A]], [[ENTRY]] ], [ [[A_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[B_IV:%.*]] = phi i8 [ [[B]], [[ENTRY]] ], [ [[B_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT: [[A_IV_NEXT]] = sub i8 1, [[A_IV]]
+; CHECK-NEXT: [[B_IV_NEXT]] = sub i8 1, [[B_IV]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[IV_NEXT]], 10
+; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: [[RES:%.*]] = icmp eq i8 [[A_IV]], [[B_IV]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+entry:
+ %B = add i8 %A, 1
+ br label %loop
+loop:
+ %iv = phi i64 [0, %entry], [%iv.next, %loop]
+ %A.iv = phi i8 [%A, %entry], [%A.iv.next, %loop]
+ %B.iv = phi i8 [%B, %entry], [%B.iv.next, %loop]
+ %iv.next = add i64 %iv, 1
+ %A.iv.next = sub i8 1, %A.iv
+ %B.iv.next = sub i8 1, %B.iv
+ %cmp = icmp ne i64 %iv.next, 10
+ br i1 %cmp, label %loop, label %exit
+exit:
+ %res = icmp eq i8 %A.iv, %B.iv
+ ret i1 %res
+}
+
+define i1 @recurrence_sub_op_order2(i8 %A) {
+; CHECK-LABEL: @recurrence_sub_op_order2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[B:%.*]] = add i8 [[A:%.*]], 1
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[A_IV:%.*]] = phi i8 [ [[A]], [[ENTRY]] ], [ [[A_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[B_IV:%.*]] = phi i8 [ [[B]], [[ENTRY]] ], [ [[B_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT: [[A_IV_NEXT]] = sub i8 1, [[A_IV]]
+; CHECK-NEXT: [[B_IV_NEXT]] = sub i8 [[B_IV]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[IV_NEXT]], 10
+; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: [[RES:%.*]] = icmp eq i8 [[A_IV]], [[B_IV]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+entry:
+ %B = add i8 %A, 1
+ br label %loop
+loop:
+ %iv = phi i64 [0, %entry], [%iv.next, %loop]
+ %A.iv = phi i8 [%A, %entry], [%A.iv.next, %loop]
+ %B.iv = phi i8 [%B, %entry], [%B.iv.next, %loop]
+ %iv.next = add i64 %iv, 1
+ %A.iv.next = sub i8 1, %A.iv
+ %B.iv.next = sub i8 %B.iv, 1
+ %cmp = icmp ne i64 %iv.next, 10
+ br i1 %cmp, label %loop, label %exit
+exit:
+ %res = icmp eq i8 %A.iv, %B.iv
+ ret i1 %res
+}
+
+
define i1 @recurrence_mul_neq(i8 %A) {
; CHECK-LABEL: @recurrence_mul_neq(
; CHECK-NEXT: entry:
ret i1 %res
}
+; Represents a power function, but still invertable!
+define i1 @recurrence_shl_op_order(i8 %A) {
+; CHECK-LABEL: @recurrence_shl_op_order(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[B:%.*]] = add i8 [[A:%.*]], 1
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[A_IV:%.*]] = phi i8 [ [[A]], [[ENTRY]] ], [ [[A_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[B_IV:%.*]] = phi i8 [ [[B]], [[ENTRY]] ], [ [[B_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT: [[A_IV_NEXT]] = shl nuw i8 1, [[A_IV]]
+; CHECK-NEXT: [[B_IV_NEXT]] = shl nuw i8 1, [[B_IV]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[IV_NEXT]], 10
+; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: [[RES:%.*]] = icmp eq i8 [[A_IV]], [[B_IV]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+entry:
+ %B = add i8 %A, 1
+ br label %loop
+loop:
+ %iv = phi i64 [0, %entry], [%iv.next, %loop]
+ %A.iv = phi i8 [%A, %entry], [%A.iv.next, %loop]
+ %B.iv = phi i8 [%B, %entry], [%B.iv.next, %loop]
+ %iv.next = add i64 %iv, 1
+ %A.iv.next = shl nuw i8 1, %A.iv
+ %B.iv.next = shl nuw i8 1, %B.iv
+ %cmp = icmp ne i64 %iv.next, 10
+ br i1 %cmp, label %loop, label %exit
+exit:
+ %res = icmp eq i8 %A.iv, %B.iv
+ ret i1 %res
+}
+
define i1 @recurrence_lshr_neq(i8 %A) {
; CHECK-LABEL: @recurrence_lshr_neq(
; CHECK-NEXT: entry:
ret i1 %res
}
+define i1 @recurrence_lshr_op_order(i8 %A) {
+; CHECK-LABEL: @recurrence_lshr_op_order(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[B:%.*]] = add i8 [[A:%.*]], 1
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[A_IV:%.*]] = phi i8 [ [[A]], [[ENTRY]] ], [ 1, [[LOOP]] ]
+; CHECK-NEXT: [[B_IV:%.*]] = phi i8 [ [[B]], [[ENTRY]] ], [ 1, [[LOOP]] ]
+; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[IV_NEXT]], 10
+; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: [[RES:%.*]] = icmp eq i8 [[A_IV]], [[B_IV]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+entry:
+ %B = add i8 %A, 1
+ br label %loop
+loop:
+ %iv = phi i64 [0, %entry], [%iv.next, %loop]
+ %A.iv = phi i8 [%A, %entry], [%A.iv.next, %loop]
+ %B.iv = phi i8 [%B, %entry], [%B.iv.next, %loop]
+ %iv.next = add i64 %iv, 1
+ %A.iv.next = lshr exact i8 1, %A.iv
+ %B.iv.next = lshr exact i8 1, %B.iv
+ %cmp = icmp ne i64 %iv.next, 10
+ br i1 %cmp, label %loop, label %exit
+exit:
+ %res = icmp eq i8 %A.iv, %B.iv
+ ret i1 %res
+}
+
+
define i1 @recurrence_ashr_neq(i8 %A) {
; CHECK-LABEL: @recurrence_ashr_neq(
; CHECK-NEXT: entry: