Skip to content

Commit adde6a8

Browse files
committed
[InstCombine] Add pre-commit tests. NFC.
1 parent e776484 commit adde6a8

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

llvm/test/Transforms/InstCombine/icmp-mul.ll

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,3 +1464,122 @@ entry:
14641464
%cmp = icmp slt i8 %mul1, %mul2
14651465
ret i1 %cmp
14661466
}
1467+
1468+
define i1 @test_icmp_slt_mul_known_sgt(i64 %x, i64 %z) {
1469+
; CHECK-LABEL: @test_icmp_slt_mul_known_sgt(
1470+
; CHECK-NEXT: entry:
1471+
; CHECK-NEXT: [[Y:%.*]] = add nsw i64 [[X:%.*]], 1
1472+
; CHECK-NEXT: [[MUL1:%.*]] = mul nsw i64 [[X]], [[Z:%.*]]
1473+
; CHECK-NEXT: [[MUL2:%.*]] = mul nsw i64 [[Y]], [[Z]]
1474+
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[MUL1]], [[MUL2]]
1475+
; CHECK-NEXT: ret i1 [[CMP]]
1476+
;
1477+
entry:
1478+
%y = add nsw i64 %x, 1
1479+
%mul1 = mul nsw i64 %x, %z
1480+
%mul2 = mul nsw i64 %y, %z
1481+
%cmp = icmp slt i64 %mul1, %mul2
1482+
ret i1 %cmp
1483+
}
1484+
1485+
define i1 @test_icmp_sle_mul_known_sgt(i64 %x, i64 %z) {
1486+
; CHECK-LABEL: @test_icmp_sle_mul_known_sgt(
1487+
; CHECK-NEXT: entry:
1488+
; CHECK-NEXT: [[Y:%.*]] = add nsw i64 [[X:%.*]], 1
1489+
; CHECK-NEXT: [[MUL1:%.*]] = mul nsw i64 [[X]], [[Z:%.*]]
1490+
; CHECK-NEXT: [[MUL2:%.*]] = mul nsw i64 [[Y]], [[Z]]
1491+
; CHECK-NEXT: [[CMP:%.*]] = icmp sle i64 [[MUL1]], [[MUL2]]
1492+
; CHECK-NEXT: ret i1 [[CMP]]
1493+
;
1494+
entry:
1495+
%y = add nsw i64 %x, 1
1496+
%mul1 = mul nsw i64 %x, %z
1497+
%mul2 = mul nsw i64 %y, %z
1498+
%cmp = icmp sle i64 %mul1, %mul2
1499+
ret i1 %cmp
1500+
}
1501+
1502+
define i1 @test_icmp_mul_known_slt(i64 %x, i64 %z) {
1503+
; CHECK-LABEL: @test_icmp_mul_known_slt(
1504+
; CHECK-NEXT: entry:
1505+
; CHECK-NEXT: [[Y:%.*]] = add nsw i64 [[X:%.*]], 1
1506+
; CHECK-NEXT: [[MUL1:%.*]] = mul nsw i64 [[X]], [[Z:%.*]]
1507+
; CHECK-NEXT: [[MUL2:%.*]] = mul nsw i64 [[Y]], [[Z]]
1508+
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[MUL2]], [[MUL1]]
1509+
; CHECK-NEXT: ret i1 [[CMP]]
1510+
;
1511+
entry:
1512+
%y = add nsw i64 %x, 1
1513+
%mul1 = mul nsw i64 %x, %z
1514+
%mul2 = mul nsw i64 %y, %z
1515+
%cmp = icmp slt i64 %mul2, %mul1
1516+
ret i1 %cmp
1517+
}
1518+
1519+
define i1 @test_icmp_slt_mul_known_sgt_commuted1(i64 %x, i64 %z) {
1520+
; CHECK-LABEL: @test_icmp_slt_mul_known_sgt_commuted1(
1521+
; CHECK-NEXT: entry:
1522+
; CHECK-NEXT: [[Y:%.*]] = add nsw i64 [[X:%.*]], 1
1523+
; CHECK-NEXT: [[MUL1:%.*]] = mul nsw i64 [[Z:%.*]], [[X]]
1524+
; CHECK-NEXT: [[MUL2:%.*]] = mul nsw i64 [[Y]], [[Z]]
1525+
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[MUL1]], [[MUL2]]
1526+
; CHECK-NEXT: ret i1 [[CMP]]
1527+
;
1528+
entry:
1529+
%y = add nsw i64 %x, 1
1530+
%mul1 = mul nsw i64 %z, %x
1531+
%mul2 = mul nsw i64 %y, %z
1532+
%cmp = icmp slt i64 %mul1, %mul2
1533+
ret i1 %cmp
1534+
}
1535+
1536+
define i1 @test_icmp_slt_mul_known_sgt_commuted2(i64 %x, i64 %z) {
1537+
; CHECK-LABEL: @test_icmp_slt_mul_known_sgt_commuted2(
1538+
; CHECK-NEXT: entry:
1539+
; CHECK-NEXT: [[Y:%.*]] = add nsw i64 [[X:%.*]], 1
1540+
; CHECK-NEXT: [[MUL1:%.*]] = mul nsw i64 [[X]], [[Z:%.*]]
1541+
; CHECK-NEXT: [[MUL2:%.*]] = mul nsw i64 [[Z]], [[Y]]
1542+
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[MUL1]], [[MUL2]]
1543+
; CHECK-NEXT: ret i1 [[CMP]]
1544+
;
1545+
entry:
1546+
%y = add nsw i64 %x, 1
1547+
%mul1 = mul nsw i64 %x, %z
1548+
%mul2 = mul nsw i64 %z, %y
1549+
%cmp = icmp slt i64 %mul1, %mul2
1550+
ret i1 %cmp
1551+
}
1552+
1553+
define i1 @test_icmp_slt_mul_unknown(i64 %x, i64 %z) {
1554+
; CHECK-LABEL: @test_icmp_slt_mul_unknown(
1555+
; CHECK-NEXT: entry:
1556+
; CHECK-NEXT: [[Y:%.*]] = add i64 [[X:%.*]], 1
1557+
; CHECK-NEXT: [[MUL1:%.*]] = mul nsw i64 [[X]], [[Z:%.*]]
1558+
; CHECK-NEXT: [[MUL2:%.*]] = mul nsw i64 [[Z]], [[Y]]
1559+
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[MUL1]], [[MUL2]]
1560+
; CHECK-NEXT: ret i1 [[CMP]]
1561+
;
1562+
entry:
1563+
%y = add i64 %x, 1
1564+
%mul1 = mul nsw i64 %x, %z
1565+
%mul2 = mul nsw i64 %z, %y
1566+
%cmp = icmp slt i64 %mul1, %mul2
1567+
ret i1 %cmp
1568+
}
1569+
1570+
define i1 @test_icmp_slt_mul_no_nsw(i64 %x, i64 %z) {
1571+
; CHECK-LABEL: @test_icmp_slt_mul_no_nsw(
1572+
; CHECK-NEXT: entry:
1573+
; CHECK-NEXT: [[Y:%.*]] = add nsw i64 [[X:%.*]], 1
1574+
; CHECK-NEXT: [[MUL1:%.*]] = mul i64 [[X]], [[Z:%.*]]
1575+
; CHECK-NEXT: [[MUL2:%.*]] = mul nsw i64 [[Z]], [[Y]]
1576+
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[MUL1]], [[MUL2]]
1577+
; CHECK-NEXT: ret i1 [[CMP]]
1578+
;
1579+
entry:
1580+
%y = add nsw i64 %x, 1
1581+
%mul1 = mul i64 %x, %z
1582+
%mul2 = mul nsw i64 %z, %y
1583+
%cmp = icmp slt i64 %mul1, %mul2
1584+
ret i1 %cmp
1585+
}

0 commit comments

Comments
 (0)