Skip to content

Commit fbfac8e

Browse files
committed
[InstCombine] add tests for or-xor-nand; NFC
1 parent 1c12e12 commit fbfac8e

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

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

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,3 +956,103 @@ define i8 @or_not_xor_common_op_use2(i8 %x, i8 %y, i8 %z) {
956956
%o2 = or i8 %xor, %o1
957957
ret i8 %o2
958958
}
959+
960+
define i4 @or_nand_xor_common_op_commute0(i4 %x, i4 %y, i4 %z) {
961+
; CHECK-LABEL: @or_nand_xor_common_op_commute0(
962+
; CHECK-NEXT: [[AND:%.*]] = and i4 [[X:%.*]], [[Z:%.*]]
963+
; CHECK-NEXT: [[NAND:%.*]] = xor i4 [[AND]], -1
964+
; CHECK-NEXT: [[XOR:%.*]] = xor i4 [[X]], [[Y:%.*]]
965+
; CHECK-NEXT: [[R:%.*]] = or i4 [[XOR]], [[NAND]]
966+
; CHECK-NEXT: ret i4 [[R]]
967+
;
968+
%and = and i4 %x, %z
969+
%nand = xor i4 %and, -1
970+
%xor = xor i4 %x, %y
971+
%r = or i4 %nand, %xor
972+
ret i4 %r
973+
}
974+
975+
define <2 x i4> @or_nand_xor_common_op_commute1(<2 x i4> %x, <2 x i4> %y, <2 x i4> %z) {
976+
; CHECK-LABEL: @or_nand_xor_common_op_commute1(
977+
; CHECK-NEXT: [[AND:%.*]] = and <2 x i4> [[Z:%.*]], [[X:%.*]]
978+
; CHECK-NEXT: [[NAND:%.*]] = xor <2 x i4> [[AND]], <i4 poison, i4 -1>
979+
; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i4> [[X]], [[Y:%.*]]
980+
; CHECK-NEXT: [[R:%.*]] = or <2 x i4> [[XOR]], [[NAND]]
981+
; CHECK-NEXT: ret <2 x i4> [[R]]
982+
;
983+
%and = and <2 x i4> %z, %x
984+
%nand = xor <2 x i4> %and, <i4 poison, i4 -1>
985+
%xor = xor <2 x i4> %x, %y
986+
%r = or <2 x i4> %xor, %nand
987+
ret <2 x i4> %r
988+
}
989+
990+
define i8 @or_nand_xor_common_op_commute2(i8 %x, i8 %y, i8 %z) {
991+
; CHECK-LABEL: @or_nand_xor_common_op_commute2(
992+
; CHECK-NEXT: [[AND:%.*]] = and i8 [[X:%.*]], [[Z:%.*]]
993+
; CHECK-NEXT: call void @use(i8 [[AND]])
994+
; CHECK-NEXT: [[NAND:%.*]] = xor i8 [[AND]], -1
995+
; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Y:%.*]], [[X]]
996+
; CHECK-NEXT: [[R:%.*]] = or i8 [[XOR]], [[NAND]]
997+
; CHECK-NEXT: ret i8 [[R]]
998+
;
999+
%and = and i8 %x, %z
1000+
call void @use(i8 %and)
1001+
%nand = xor i8 %and, -1
1002+
%xor = xor i8 %y, %x
1003+
%r = or i8 %nand, %xor
1004+
ret i8 %r
1005+
}
1006+
1007+
define i8 @or_nand_xor_common_op_commute3(i8 %x, i8 %y, i8 %z) {
1008+
; CHECK-LABEL: @or_nand_xor_common_op_commute3(
1009+
; CHECK-NEXT: [[AND:%.*]] = and i8 [[Z:%.*]], [[X:%.*]]
1010+
; CHECK-NEXT: [[NAND:%.*]] = xor i8 [[AND]], -1
1011+
; CHECK-NEXT: call void @use(i8 [[NAND]])
1012+
; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Y:%.*]], [[X]]
1013+
; CHECK-NEXT: [[R:%.*]] = or i8 [[XOR]], [[NAND]]
1014+
; CHECK-NEXT: ret i8 [[R]]
1015+
;
1016+
%and = and i8 %z, %x
1017+
%nand = xor i8 %and, -1
1018+
call void @use(i8 %nand)
1019+
%xor = xor i8 %y, %x
1020+
%r = or i8 %xor, %nand
1021+
ret i8 %r
1022+
}
1023+
1024+
define i8 @or_nand_xor_common_op_commute3_use2(i8 %x, i8 %y, i8 %z) {
1025+
; CHECK-LABEL: @or_nand_xor_common_op_commute3_use2(
1026+
; CHECK-NEXT: [[AND:%.*]] = and i8 [[Z:%.*]], [[X:%.*]]
1027+
; CHECK-NEXT: [[NAND:%.*]] = xor i8 [[AND]], -1
1028+
; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Y:%.*]], [[X]]
1029+
; CHECK-NEXT: call void @use(i8 [[XOR]])
1030+
; CHECK-NEXT: [[R:%.*]] = or i8 [[XOR]], [[NAND]]
1031+
; CHECK-NEXT: ret i8 [[R]]
1032+
;
1033+
%and = and i8 %z, %x
1034+
%nand = xor i8 %and, -1
1035+
%xor = xor i8 %y, %x
1036+
call void @use(i8 %xor)
1037+
%r = or i8 %xor, %nand
1038+
ret i8 %r
1039+
}
1040+
1041+
define i8 @or_nand_xor_common_op_commute3_use3(i8 %x, i8 %y, i8 %z) {
1042+
; CHECK-LABEL: @or_nand_xor_common_op_commute3_use3(
1043+
; CHECK-NEXT: [[AND:%.*]] = and i8 [[Z:%.*]], [[X:%.*]]
1044+
; CHECK-NEXT: [[NAND:%.*]] = xor i8 [[AND]], -1
1045+
; CHECK-NEXT: call void @use(i8 [[NAND]])
1046+
; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Y:%.*]], [[X]]
1047+
; CHECK-NEXT: call void @use(i8 [[XOR]])
1048+
; CHECK-NEXT: [[R:%.*]] = or i8 [[XOR]], [[NAND]]
1049+
; CHECK-NEXT: ret i8 [[R]]
1050+
;
1051+
%and = and i8 %z, %x
1052+
%nand = xor i8 %and, -1
1053+
call void @use(i8 %nand)
1054+
%xor = xor i8 %y, %x
1055+
call void @use(i8 %xor)
1056+
%r = or i8 %xor, %nand
1057+
ret i8 %r
1058+
}

0 commit comments

Comments
 (0)