llvm.org GIT mirror llvm / aa578f6
[Tests] Add ne icmp tests w/preinc forms for LoopPredication Turns out this is substaintially easier to match then the post increment form, so let's start there. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362260 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 3 months ago
1 changed file(s) with 80 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
16291629 ret i32 0
16301630 }
16311631
1632 ; Same as previous, but with a pre-increment test since this is easier to match
1633 define i32 @ne_latch_zext_preinc(i32* %array, i32 %length, i16 %n16) {
1634 ; CHECK-LABEL: @ne_latch_zext_preinc(
1635 ; CHECK-NEXT: loop.preheader:
1636 ; CHECK-NEXT: [[N:%.*]] = zext i16 [[N16:%.*]] to i32
1637 ; CHECK-NEXT: br label [[LOOP:%.*]]
1638 ; CHECK: loop:
1639 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[LOOP]] ], [ 0, [[LOOP_PREHEADER:%.*]] ]
1640 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
1641 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ]
1642 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1643 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I]], [[N]]
1644 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT:%.*]]
1645 ; CHECK: exit:
1646 ; CHECK-NEXT: ret i32 0
1647 ;
1648 loop.preheader:
1649 %n = zext i16 %n16 to i32
1650 br label %loop
1651
1652 loop:
1653 %i = phi i32 [ %i.next, %loop ], [ 0, %loop.preheader ]
1654 %within.bounds = icmp ult i32 %i, %length
1655 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
1656
1657 %i.next = add nuw i32 %i, 1
1658 %continue = icmp ne i32 %i, %n
1659 br i1 %continue, label %loop, label %exit
1660
1661 exit:
1662 ret i32 0
1663 }
1664
16321665 ; NE Check (as produced by LFTR) where we can prove Start < End via the
16331666 ; condition guarding the loop entry.
16341667 define i32 @ne_latch_dom_check(i32* %array, i32 %length, i32 %n) {
16691702 exit:
16701703 ret i32 0
16711704 }
1705
1706 ; Same as previous, but easier to match
1707 define i32 @ne_latch_dom_check_preinc(i32* %array, i32 %length, i32 %n) {
1708 ; CHECK-LABEL: @ne_latch_dom_check_preinc(
1709 ; CHECK-NEXT: entry:
1710 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
1711 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1712 ; CHECK: loop.preheader:
1713 ; CHECK-NEXT: br label [[LOOP:%.*]]
1714 ; CHECK: loop:
1715 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[LOOP]] ], [ 0, [[LOOP_PREHEADER]] ]
1716 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
1717 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ]
1718 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1719 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I]], [[N]]
1720 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]]
1721 ; CHECK: exit.loopexit:
1722 ; CHECK-NEXT: br label [[EXIT]]
1723 ; CHECK: exit:
1724 ; CHECK-NEXT: ret i32 0
1725 ;
1726 entry:
1727 %tmp5 = icmp sle i32 %n, 0
1728 br i1 %tmp5, label %exit, label %loop.preheader
1729
1730 loop.preheader:
1731 br label %loop
1732
1733 loop:
1734 %i = phi i32 [ %i.next, %loop ], [ 0, %loop.preheader ]
1735 %within.bounds = icmp ult i32 %i, %length
1736 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
1737
1738 %i.next = add nuw i32 %i, 1
1739 %continue = icmp ne i32 %i, %n
1740 br i1 %continue, label %loop, label %exit
1741
1742 exit:
1743 ret i32 0
1744 }
1745
16721746
16731747 ; NE latch - can't prove (end-start) mod step == 0 (i.e. might wrap
16741748 ; around several times or even be infinite)
16821756 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
16831757 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ]
16841758 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 3
1685 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], [[N]]
1759 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I]], [[N]]
16861760 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT:%.*]]
16871761 ; CHECK: exit:
16881762 ; CHECK-NEXT: ret i32 0
16971771 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
16981772
16991773 %i.next = add i32 %i, 3
1700 %continue = icmp ne i32 %i.next, %n
1774 %continue = icmp ne i32 %i, %n
17011775 br i1 %continue, label %loop, label %exit
17021776
17031777 exit:
17141788 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
17151789 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ]
17161790 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 2
1717 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], 400
1791 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I]], 400
17181792 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT:%.*]]
17191793 ; CHECK: exit:
17201794 ; CHECK-NEXT: ret i32 0
17281802 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
17291803
17301804 %i.next = add nuw i32 %i, 2
1731 %continue = icmp ne i32 %i.next, 400
1805 %continue = icmp ne i32 %i, 400
17321806 br i1 %continue, label %loop, label %exit
17331807
17341808 exit:
17451819 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
17461820 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ]
17471821 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
1748 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], 0
1822 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I]], 0
17491823 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT:%.*]]
17501824 ; CHECK: exit:
17511825 ; CHECK-NEXT: ret i32 0
17591833 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
17601834
17611835 %i.next = add i32 %i, 1
1762 %continue = icmp ne i32 %i.next, 0
1836 %continue = icmp ne i32 %i, 0
17631837 br i1 %continue, label %loop, label %exit
17641838
17651839 exit: