[VPlan] Add test for sinking pointer induction increments.
authorFlorian Hahn <flo@fhahn.com>
Wed, 12 Oct 2022 11:06:40 +0000 (12:06 +0100)
committerFlorian Hahn <flo@fhahn.com>
Wed, 12 Oct 2022 11:06:40 +0000 (12:06 +0100)
Extra test for D133762.

llvm/test/Transforms/LoopVectorize/vplan-sink-scalars-and-merge.ll

index fcd4782..6133334 100644 (file)
@@ -1128,3 +1128,74 @@ loop:
 exit:
   ret void
 }
+
+define void @ptr_induction_remove_dead_recipe(i8* %start, i8* %end) {
+; CHECK-LABEL: LV: Checking a loop in 'ptr_induction_remove_dead_recipe'
+; CHECK:       VPlan 'Initial VPlan for VF={2},UF>=1' {
+; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
+; CHECK-EMPTY:
+; CHECK-NEXT: vector.ph:
+; CHECK-NEXT: Successor(s): vector loop
+; CHECK-EMPTY:
+; CHECK-NEXT: <x1> vector loop: {
+; CHECK-NEXT:   vector.body:
+; CHECK-NEXT:     EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
+; CHECK-NEXT:     EMIT ir<%ptr.iv> = WIDEN-POINTER-INDUCTION ir<%start>, -1
+; CHECK-NEXT:     REPLICATE ir<%ptr.iv.next> = getelementptr ir<%ptr.iv>, ir<-1>
+; CHECK-NEXT:     WIDEN ir<%l> = load ir<%ptr.iv.next>
+; CHECK-NEXT:     WIDEN ir<%c.1> = icmp ir<%l>, ir<0>
+; CHECK-NEXT:   Successor(s): if.then
+; CHECK-EMPTY:
+; CHECK-NEXT:   if.then:
+; CHECK-NEXT:     EMIT vp<[[NEG:%.+]]> = not ir<%c.1>
+; CHECK-NEXT:   Successor(s): pred.store
+; CHECK-EMPTY:
+; CHECK-NEXT:   <xVFxUF> pred.store: {
+; CHECK-NEXT:     pred.store.entry:
+; CHECK-NEXT:       BRANCH-ON-MASK vp<[[NEG]]>
+; CHECK-NEXT:     Successor(s): pred.store.if, pred.store.continue
+; CHECK-EMPTY:
+; CHECK-NEXT:     pred.store.if:
+; CHECK-NEXT:       REPLICATE store ir<95>, ir<%ptr.iv.next>
+; CHECK-NEXT:     Successor(s): pred.store.continue
+; CHECK-EMPTY:
+; CHECK-NEXT:     pred.store.continue:
+; CHECK-NEXT:     No successors
+; CHECK-NEXT:   }
+; CHECK-NEXT:   Successor(s): if.then.0
+; CHECK-EMPTY:
+; CHECK-NEXT:   if.then.0:
+; CHECK-NEXT:   Successor(s): loop.latch
+; CHECK-EMPTY:
+; CHECK-NEXT:   loop.latch:
+; CHECK-NEXT:     EMIT vp<[[CAN_IV_NEXT:%.+]]> = VF * UF +(nuw)  vp<[[CAN_IV]]>
+; CHECK-NEXT:     EMIT branch-on-count  vp<[[CAN_IV_NEXT]]> vp<[[VEC_TC]]>
+; CHECK-NEXT:   No successors
+; CHECK-NEXT: }
+; CHECK-NEXT: Successor(s): middle.block
+; CHECK-EMPTY:
+; CHECK-NEXT: middle.block:
+; CHECK-NEXT: No successors
+; CHECK-NEXT: }
+;
+entry:
+  br label %loop.header
+
+loop.header:
+  %ptr.iv = phi i8* [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
+  %ptr.iv.next = getelementptr inbounds i8, i8* %ptr.iv, i64 -1
+  %l = load i8, i8* %ptr.iv.next, align 1
+  %c.1 = icmp eq i8 %l, 0
+  br i1 %c.1, label %loop.latch, label %if.then
+
+if.then:
+  store i8 95, i8* %ptr.iv.next, align 1
+  br label %loop.latch
+
+loop.latch:
+  %c.2 = icmp eq i8* %ptr.iv.next, %end
+  br i1 %c.2, label %exit, label %loop.header
+
+exit:
+  ret void
+}