%r = icmp sgt i8 %or, -1
ret i1 %r
}
+
+define i1 @icmp_or_xor_2_eq(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
+; CHECK-LABEL: @icmp_or_xor_2_eq(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %cmp = icmp eq i64 %or, 0
+ ret i1 %cmp
+}
+
+define i1 @icmp_or_xor_2_ne(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
+; CHECK-LABEL: @icmp_or_xor_2_ne(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[OR]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %cmp = icmp ne i64 %or, 0
+ ret i1 %cmp
+}
+
+; negative test - wrong cmp constant
+
+define i1 @icmp_or_xor_2_eq_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
+; CHECK-LABEL: @icmp_or_xor_2_eq_fail(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 1
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %cmp = icmp eq i64 %or, 1
+ ret i1 %cmp
+}
+
+; negative test - wrong cmp constant
+
+define i1 @icmp_or_xor_2_ne_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
+; CHECK-LABEL: @icmp_or_xor_2_ne_fail(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[OR]], 1
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %cmp = icmp ne i64 %or, 1
+ ret i1 %cmp
+}
+
+; negative test - xor multiuse
+
+define i1 @icmp_or_xor_2_3_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
+; CHECK-LABEL: @icmp_or_xor_2_3_fail(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 0
+; CHECK-NEXT: [[CMP_1:%.*]] = icmp eq i64 [[XOR]], 0
+; CHECK-NEXT: [[OR1:%.*]] = or i1 [[CMP]], [[CMP_1]]
+; CHECK-NEXT: ret i1 [[OR1]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %cmp = icmp eq i64 %or, 0
+ %cmp_1 = icmp eq i64 %xor, 0
+ %or1 = or i1 %cmp, %cmp_1
+ ret i1 %or1
+}
+
+; negative test - xor multiuse
+
+define i1 @icmp_or_xor_2_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
+; CHECK-LABEL: @icmp_or_xor_2_4_fail(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR]], 0
+; CHECK-NEXT: [[CMP_1:%.*]] = icmp eq i64 [[XOR1]], 0
+; CHECK-NEXT: [[OR1:%.*]] = or i1 [[CMP]], [[CMP_1]]
+; CHECK-NEXT: ret i1 [[OR1]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %cmp = icmp eq i64 %or, 0
+ %cmp_1 = icmp eq i64 %xor1, 0
+ %or1 = or i1 %cmp, %cmp_1
+ ret i1 %or1
+}
+
+define i1 @icmp_or_xor_3_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
+; CHECK-LABEL: @icmp_or_xor_3_1(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
+; CHECK-NEXT: [[OR1:%.*]] = or i64 [[OR]], [[XOR2]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %xor2 = xor i64 %x3, %y3
+ %or1 = or i64 %or, %xor2
+ %cmp = icmp eq i64 %or1, 0
+ ret i1 %cmp
+}
+
+; negative test - and instead of or
+
+define i1 @icmp_or_xor_3_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
+; CHECK-LABEL: @icmp_or_xor_3_fail(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[AND:%.*]] = and i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
+; CHECK-NEXT: [[OR1:%.*]] = or i64 [[AND]], [[XOR2]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %and = and i64 %xor, %xor1
+ %xor2 = xor i64 %x3, %y3
+ %or1 = or i64 %and, %xor2
+ %cmp = icmp eq i64 %or1, 0
+ ret i1 %cmp
+}
+
+define i1 @icmp_or_xor_3_3(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
+; CHECK-LABEL: @icmp_or_xor_3_3(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
+; CHECK-NEXT: [[OR1:%.*]] = or i64 [[XOR2]], [[OR]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %xor2 = xor i64 %x3, %y3
+ %or1 = or i64 %xor2, %or
+ %cmp = icmp eq i64 %or1, 0
+ ret i1 %cmp
+}
+
+; negative test - and instead of or
+
+define i1 @icmp_or_xor_3_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3) {
+; CHECK-LABEL: @icmp_or_xor_3_4_fail(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[AND:%.*]] = and i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
+; CHECK-NEXT: [[OR1:%.*]] = or i64 [[XOR2]], [[AND]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR1]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %and = and i64 %xor, %xor1
+ %xor2 = xor i64 %x3, %y3
+ %or1 = or i64 %xor2, %and
+ %cmp = icmp eq i64 %or1, 0
+ ret i1 %cmp
+}
+
+define i1 @icmp_or_xor_4_1(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3, i64 %x4, i64 %y4) {
+; CHECK-LABEL: @icmp_or_xor_4_1(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
+; CHECK-NEXT: [[XOR3:%.*]] = xor i64 [[X4:%.*]], [[Y4:%.*]]
+; CHECK-NEXT: [[OR1:%.*]] = or i64 [[XOR2]], [[XOR3]]
+; CHECK-NEXT: [[OR2:%.*]] = or i64 [[OR]], [[OR1]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR2]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %xor2 = xor i64 %x3, %y3
+ %xor3 = xor i64 %x4, %y4
+ %or1 = or i64 %xor2, %xor3
+ %or2 = or i64 %or, %or1
+ %cmp = icmp eq i64 %or2, 0
+ ret i1 %cmp
+}
+
+define i1 @icmp_or_xor_4_2(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3, i64 %y3, i64 %x4, i64 %y4) {
+; CHECK-LABEL: @icmp_or_xor_4_2(
+; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
+; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
+; CHECK-NEXT: [[OR:%.*]] = or i64 [[XOR]], [[XOR1]]
+; CHECK-NEXT: [[XOR2:%.*]] = xor i64 [[X3:%.*]], [[Y3:%.*]]
+; CHECK-NEXT: [[XOR3:%.*]] = xor i64 [[X4:%.*]], [[Y4:%.*]]
+; CHECK-NEXT: [[OR1:%.*]] = or i64 [[XOR2]], [[XOR3]]
+; CHECK-NEXT: [[OR2:%.*]] = or i64 [[OR1]], [[OR]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[OR2]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %xor = xor i64 %x1, %y1
+ %xor1 = xor i64 %x2, %y2
+ %or = or i64 %xor, %xor1
+ %xor2 = xor i64 %x3, %y3
+ %xor3 = xor i64 %x4, %y4
+ %or1 = or i64 %xor2, %xor3
+ %or2 = or i64 %or1, %or
+ %cmp = icmp eq i64 %or2, 0
+ ret i1 %cmp
+}