Skip to content

Commit 32c42b7

Browse files
committed
[InstCombine] Add pre-commit tests
1 parent 55eb93b commit 32c42b7

File tree

1 file changed

+176
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+176
-0
lines changed

llvm/test/Transforms/InstCombine/xor.ll

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,3 +1485,179 @@ define i4 @PR96857_xor_without_noundef(i4 %val0, i4 %val1, i4 %val2) {
14851485
%val7 = xor i4 %val4, %val6
14861486
ret i4 %val7
14871487
}
1488+
1489+
define i32 @or_disjoint_with_xor(i32 %a, i32 %b) {
1490+
; CHECK-LABEL: @or_disjoint_with_xor(
1491+
; CHECK-NEXT: entry:
1492+
; CHECK-NEXT: [[TMP0:%.*]] = xor i32 [[A:%.*]], -1
1493+
; CHECK-NEXT: [[XOR:%.*]] = and i32 [[B:%.*]], [[TMP0]]
1494+
; CHECK-NEXT: ret i32 [[XOR]]
1495+
;
1496+
entry:
1497+
%or = or disjoint i32 %a, %b
1498+
%xor = xor i32 %or, %a
1499+
ret i32 %xor
1500+
}
1501+
1502+
define i32 @xor_with_or_disjoint(i32 %a, i32 %b, i32 %c) {
1503+
; CHECK-LABEL: @xor_with_or_disjoint(
1504+
; CHECK-NEXT: entry:
1505+
; CHECK-NEXT: [[TMP0:%.*]] = xor i32 [[A:%.*]], -1
1506+
; CHECK-NEXT: [[XOR:%.*]] = and i32 [[B:%.*]], [[TMP0]]
1507+
; CHECK-NEXT: ret i32 [[XOR]]
1508+
;
1509+
entry:
1510+
%or = or disjoint i32 %a, %b
1511+
%xor = xor i32 %a, %or
1512+
ret i32 %xor
1513+
}
1514+
1515+
define <2 x i32> @or_disjoint_with_xor_vec(<2 x i32> %a, < 2 x i32> %b, <2 x i32> %c) {
1516+
; CHECK-LABEL: @or_disjoint_with_xor_vec(
1517+
; CHECK-NEXT: entry:
1518+
; CHECK-NEXT: [[TMP0:%.*]] = xor <2 x i32> [[A:%.*]], <i32 -1, i32 -1>
1519+
; CHECK-NEXT: [[XOR:%.*]] = and <2 x i32> [[B:%.*]], [[TMP0]]
1520+
; CHECK-NEXT: ret <2 x i32> [[XOR]]
1521+
;
1522+
entry:
1523+
%or = or disjoint <2 x i32> %a, %b
1524+
%xor = xor <2 x i32> %or, %a
1525+
ret <2 x i32> %xor
1526+
}
1527+
1528+
define <2 x i32> @xor_with_or_disjoint_vec(<2 x i32> %a, < 2 x i32> %b, <2 x i32> %c) {
1529+
; CHECK-LABEL: @xor_with_or_disjoint_vec(
1530+
; CHECK-NEXT: entry:
1531+
; CHECK-NEXT: [[TMP0:%.*]] = xor <2 x i32> [[A:%.*]], <i32 -1, i32 -1>
1532+
; CHECK-NEXT: [[XOR:%.*]] = and <2 x i32> [[B:%.*]], [[TMP0]]
1533+
; CHECK-NEXT: ret <2 x i32> [[XOR]]
1534+
;
1535+
entry:
1536+
%or = or disjoint <2 x i32> %a, %b
1537+
%xor = xor <2 x i32> %a, %or
1538+
ret <2 x i32> %xor
1539+
}
1540+
1541+
define i32 @select_or_disjoint_xor(i32 %a, i1 %c) {
1542+
; CHECK-LABEL: @select_or_disjoint_xor(
1543+
; CHECK-NEXT: entry:
1544+
; CHECK-NEXT: [[S:%.*]] = select i1 [[C:%.*]], i32 0, i32 4
1545+
; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[A:%.*]], 4
1546+
; CHECK-NEXT: [[OR:%.*]] = or disjoint i32 [[S]], [[SHL]]
1547+
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[OR]], 4
1548+
; CHECK-NEXT: ret i32 [[XOR]]
1549+
;
1550+
entry:
1551+
%s = select i1 %c, i32 0, i32 4
1552+
%shl = shl i32 %a, 4
1553+
%or = or disjoint i32 %s, %shl
1554+
%xor = xor i32 %or, 4
1555+
ret i32 %xor
1556+
}
1557+
1558+
define <2 x i32> @select_or_disjoint_xor_vec(<2 x i32> %a, i1 %c) {
1559+
; CHECK-LABEL: @select_or_disjoint_xor_vec(
1560+
; CHECK-NEXT: entry:
1561+
; CHECK-NEXT: [[S:%.*]] = select i1 [[C:%.*]], <2 x i32> zeroinitializer, <2 x i32> <i32 4, i32 4>
1562+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> [[A:%.*]], <i32 4, i32 4>
1563+
; CHECK-NEXT: [[OR:%.*]] = or disjoint <2 x i32> [[S]], [[SHL]]
1564+
; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i32> [[OR]], <i32 4, i32 4>
1565+
; CHECK-NEXT: ret <2 x i32> [[XOR]]
1566+
;
1567+
entry:
1568+
%s = select i1 %c, <2 x i32> <i32 0, i32 0>, <2 x i32> <i32 4, i32 4>
1569+
%shl = shl <2 x i32> %a, <i32 4, i32 4>
1570+
%or = or <2 x i32> %s, %shl
1571+
%xor = xor <2 x i32> %or, <i32 4, i32 4>
1572+
ret <2 x i32> %xor
1573+
}
1574+
1575+
define i32 @select_or_disjoint_or(i32 %a, i1 %c) {
1576+
; CHECK-LABEL: @select_or_disjoint_or(
1577+
; CHECK-NEXT: entry:
1578+
; CHECK-NEXT: [[S:%.*]] = select i1 [[C:%.*]], i32 0, i32 4
1579+
; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[A:%.*]], 4
1580+
; CHECK-NEXT: [[OR:%.*]] = or disjoint i32 [[S]], [[SHL]]
1581+
; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[OR]], 4
1582+
; CHECK-NEXT: ret i32 [[ADD]]
1583+
;
1584+
entry:
1585+
%s = select i1 %c, i32 0, i32 4
1586+
%shl = shl i32 %a, 4
1587+
%or = or disjoint i32 %s, %shl
1588+
%add = add i32 %or, 4
1589+
ret i32 %add
1590+
}
1591+
1592+
define <2 x i32> @select_or_disjoint_or_vec(<2 x i32> %a, i1 %c) {
1593+
; CHECK-LABEL: @select_or_disjoint_or_vec(
1594+
; CHECK-NEXT: entry:
1595+
; CHECK-NEXT: [[S:%.*]] = select i1 [[C:%.*]], <2 x i32> zeroinitializer, <2 x i32> <i32 4, i32 4>
1596+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> [[A:%.*]], <i32 4, i32 4>
1597+
; CHECK-NEXT: [[OR:%.*]] = or disjoint <2 x i32> [[S]], [[SHL]]
1598+
; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw <2 x i32> [[OR]], <i32 4, i32 4>
1599+
; CHECK-NEXT: ret <2 x i32> [[ADD]]
1600+
;
1601+
entry:
1602+
%s = select i1 %c, <2 x i32> <i32 0, i32 0>, <2 x i32> <i32 4, i32 4>
1603+
%shl = shl <2 x i32> %a, <i32 4, i32 4>
1604+
%or = or <2 x i32> %s, %shl
1605+
%add = add <2 x i32> %or, <i32 4, i32 4>
1606+
ret <2 x i32> %add
1607+
}
1608+
1609+
define i32 @or_multi_use_disjoint_with_xor(i32 %a, i32 %b, i32 %c) {
1610+
; CHECK-LABEL: @or_multi_use_disjoint_with_xor(
1611+
; CHECK-NEXT: entry:
1612+
; CHECK-NEXT: [[OR:%.*]] = or disjoint i32 [[A:%.*]], [[B:%.*]]
1613+
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[OR]], [[C:%.*]]
1614+
; CHECK-NEXT: [[ADD:%.*]] = add i32 [[OR]], [[XOR]]
1615+
; CHECK-NEXT: ret i32 [[ADD]]
1616+
;
1617+
entry:
1618+
%or = or disjoint i32 %a, %b
1619+
%xor = xor i32 %or, %c
1620+
%add = add i32 %or, %xor
1621+
ret i32 %add
1622+
}
1623+
1624+
define <2 x i32> @or_multi_use_disjoint_with_xor_vec(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c) {
1625+
; CHECK-LABEL: @or_multi_use_disjoint_with_xor_vec(
1626+
; CHECK-NEXT: entry:
1627+
; CHECK-NEXT: [[OR:%.*]] = or disjoint <2 x i32> [[A:%.*]], [[B:%.*]]
1628+
; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i32> [[OR]], [[C:%.*]]
1629+
; CHECK-NEXT: [[ADD:%.*]] = add <2 x i32> [[OR]], [[XOR]]
1630+
; CHECK-NEXT: ret <2 x i32> [[ADD]]
1631+
;
1632+
entry:
1633+
%or = or disjoint <2 x i32> %a, %b
1634+
%xor = xor <2 x i32> %or, %c
1635+
%add = add <2 x i32> %or, %xor
1636+
ret <2 x i32> %add
1637+
}
1638+
1639+
define i32 @add_with_or(i32 %a, i32 %b, i32 %c) {
1640+
; CHECK-LABEL: @add_with_or(
1641+
; CHECK-NEXT: entry:
1642+
; CHECK-NEXT: [[ADD:%.*]] = add i32 [[A:%.*]], [[B:%.*]]
1643+
; CHECK-NEXT: [[OR:%.*]] = or i32 [[ADD]], [[C:%.*]]
1644+
; CHECK-NEXT: ret i32 [[OR]]
1645+
;
1646+
entry:
1647+
%add = add i32 %a, %b
1648+
%or = or i32 %add, %c
1649+
ret i32 %or
1650+
}
1651+
1652+
define <2 x i32> @add_with_or_vec(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c) {
1653+
; CHECK-LABEL: @add_with_or_vec(
1654+
; CHECK-NEXT: entry:
1655+
; CHECK-NEXT: [[ADD:%.*]] = add <2 x i32> [[A:%.*]], [[B:%.*]]
1656+
; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[ADD]], [[C:%.*]]
1657+
; CHECK-NEXT: ret <2 x i32> [[OR]]
1658+
;
1659+
entry:
1660+
%add = add <2 x i32> %a, %b
1661+
%or = or <2 x i32> %add, %c
1662+
ret <2 x i32> %or
1663+
}

0 commit comments

Comments
 (0)