[llvm] VPlan: use worklist in simplifyRecipes (PR #93998)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 06:07:58 PDT 2024
================
@@ -7,135 +7,109 @@ define void @test(ptr %p, i40 %a) {
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
; CHECK: vector.ph:
-; CHECK-NEXT: [[BROADCAST_SPLATINSERT1:%.*]] = insertelement <16 x i40> poison, i40 [[A]], i64 0
-; CHECK-NEXT: [[BROADCAST_SPLAT2:%.*]] = shufflevector <16 x i40> [[BROADCAST_SPLATINSERT1]], <16 x i40> poison, <16 x i32> zeroinitializer
; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE32:%.*]] ]
; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <16 x i32> poison, i32 [[INDEX]], i64 0
; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <16 x i32> [[BROADCAST_SPLATINSERT]], <16 x i32> poison, <16 x i32> zeroinitializer
; CHECK-NEXT: [[VEC_IV:%.*]] = add <16 x i32> [[BROADCAST_SPLAT]], <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
; CHECK-NEXT: [[TMP0:%.*]] = icmp ule <16 x i32> [[VEC_IV]], <i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9, i32 9>
-; CHECK-NEXT: [[TMP1:%.*]] = shl <16 x i40> [[BROADCAST_SPLAT2]], <i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24, i40 24>
-; CHECK-NEXT: [[TMP2:%.*]] = ashr <16 x i40> [[TMP1]], <i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28, i40 28>
-; CHECK-NEXT: [[TMP3:%.*]] = trunc <16 x i40> [[TMP2]] to <16 x i32>
-; CHECK-NEXT: [[TMP4:%.*]] = trunc <16 x i32> [[TMP3]] to <16 x i1>
-; CHECK-NEXT: [[TMP5:%.*]] = icmp eq <16 x i1> [[TMP4]], zeroinitializer
-; CHECK-NEXT: [[TMP6:%.*]] = icmp ult <16 x i1> zeroinitializer, [[TMP5]]
-; CHECK-NEXT: [[TMP7:%.*]] = or <16 x i1> [[TMP6]], <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>
-; CHECK-NEXT: [[TMP8:%.*]] = icmp sgt <16 x i1> [[TMP7]], zeroinitializer
----------------
artagnon wrote:
So, I stepped through the code and didn't see anything surprising happening. The final VPlan, emitted as:
```
VPlan 'Final VPlan for VF={4},UF>=1' {
Live-in vp<%0> = VF * UF
Live-in vp<%1> = vector-trip-count
Live-in vp<%2> = backedge-taken count
Live-in ir<10> = original trip-count
vector.ph:
Successor(s): vector loop
<x1> vector loop: {
vector.body:
EMIT vp<%3> = CANONICAL-INDUCTION ir<0>, vp<%6>
EMIT vp<%4> = WIDEN-CANONICAL-INDUCTION vp<%3>
EMIT vp<%5> = icmp ule vp<%4>, vp<%2>
WIDEN ir<%icmp.sgt> = icmp sgt ir<true>, ir<false>
Successor(s): pred.store
<xVFxUF> pred.store: {
pred.store.entry:
BRANCH-ON-MASK vp<%5>
Successor(s): pred.store.if, pred.store.continue
pred.store.if:
REPLICATE store ir<%icmp.sgt>, ir<%p>
Successor(s): pred.store.continue
pred.store.continue:
No successors
}
Successor(s): for.body.0
for.body.0:
EMIT vp<%6> = add vp<%3>, vp<%0>
EMIT branch-on-count vp<%6>, vp<%1>
No successors
}
Successor(s): middle.block
middle.block:
EMIT branch-on-cond ir<true>
Successor(s): ir-bb<exit>, scalar.ph
ir-bb<exit>:
No successors
scalar.ph:
No successors
}
```
seems to be correct too. I'm confused about why `icmp sgt ir<true>, ir<false>` is lowered to `false`: is there an underlying bug somewhere (independent of this patch)?
https://github.com/llvm/llvm-project/pull/93998
More information about the llvm-commits
mailing list