[PATCH] D26149: [DAGCombiner] Match load by bytes idiom and fold it into a single load
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 10 09:43:53 PST 2016
hfinkel added a comment.
In https://reviews.llvm.org/D26149#591610, @apilipenko wrote:
> In https://reviews.llvm.org/D26149#590144, @hfinkel wrote:
>
> > In https://reviews.llvm.org/D26149#583791, @apilipenko wrote:
> >
> > > I found that this rule doesn't interact with the worklist mechanism in the right way. When a node is changed all its direct users are added to the work list so they can be visited and updated after the definition they are using is updated. The rule I'm adding matches complex patterns with OR node roots. When a part of the pattern is updated (e.g. one of the loads) I need to revisit the OR node but it's not necessarily a direct user of the changed node. For example, I'd like the address of this load to be reassociated so it's easier to analyze:
> > >
> > > t25: i32 = add t4, Constant:i32<2>
> > > t26: i64 = sign_extend t25
> > > t27: i64 = add t2, t26
> > > t28: i8,ch = load<LD1[%tmp9]> t0, t27, undef:i64
> > > t29: i32 = zero_extend t28
> > > t32: i32 = shl t29, Constant:i8<8>
> > > t33: i32 = or t23, t32
> > >
> > >
> > > But I have no way to trigger OR pattern matching after it happened because OR is not a direct user of the address.
> > >
> > > What is the best way to work around this limitation?
> >
> >
> > Are you looking for AddToWorklist or AddUsersToWorklist?
>
>
> I don't see how they can help me. What I need is to trigger combine for
>
> t33: i32 = or t23, t32
>
>
> When any of the node in this use-chain is combined, e.g. when
>
> t26: i64 = sign_extend t25
>
>
> is combined.
Ah, indeed. You need, in essence, to trigger another whole iteration of the combiner. You can obviously search down the chain and add things to the worklist, but you obviously want to avoid a lot of rarely-profitable work.
Can you make your code match the pattern before the sext combine?
https://reviews.llvm.org/D26149
More information about the llvm-commits
mailing list