[PATCH] D28625: [InstCombine] try to shrink bitwise logic with phi operand
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 22 11:24:02 PST 2017
spatel added a comment.
In https://reviews.llvm.org/D28625#650747, @efriedma wrote:
> If you unroll your example loop once, it no longer gets recognized.
Passing -funroll-loops on one of my original loops yields something monstrous. There's no way to solve a case like that without enhancing SimplifyDemandedUseBits()? Ie, we have to chase operands until we 'complete the circle' from incoming phi to logic op. And even that won't work if the unrolling is excessive enough to trip the recursive depth check in SimplifyDemandedBits. I'll abandon this patch if you think the more general solution is the way to go.
for.body:
%indvars.iv = phi i64 [ %indvars.iv.unr, %for.body.preheader.new ], [ %indvars.iv.next.3, %for.body ]
%all.010 = phi i8 [ %all.010.unr, %for.body.preheader.new ], [ %and.3, %for.body ]
%arrayidx = getelementptr inbounds i32, i32* %haystack, i64 %indvars.iv
%5 = load i32, i32* %arrayidx, align 4
%cmp1 = icmp eq i32 %5, %needle
%conv = zext i1 %cmp1 to i8
%and = and i8 %conv, %all.010
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%arrayidx.1 = getelementptr inbounds i32, i32* %haystack, i64 %indvars.iv.next
%6 = load i32, i32* %arrayidx.1, align 4
%cmp1.1 = icmp eq i32 %6, %needle
%conv.1 = zext i1 %cmp1.1 to i8
%and.1 = and i8 %conv.1, %and
%indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
%arrayidx.2 = getelementptr inbounds i32, i32* %haystack, i64 %indvars.iv.next.1
%7 = load i32, i32* %arrayidx.2, align 4
%cmp1.2 = icmp eq i32 %7, %needle
%conv.2 = zext i1 %cmp1.2 to i8
%and.2 = and i8 %conv.2, %and.1
%indvars.iv.next.2 = add nsw i64 %indvars.iv, 3
%arrayidx.3 = getelementptr inbounds i32, i32* %haystack, i64 %indvars.iv.next.2
%8 = load i32, i32* %arrayidx.3, align 4
%cmp1.3 = icmp eq i32 %8, %needle
%conv.3 = zext i1 %cmp1.3 to i8
%and.3 = and i8 %conv.3, %and.2
%indvars.iv.next.3 = add nsw i64 %indvars.iv, 4
%exitcond.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
br i1 %exitcond.3, label %for.cond.cleanup.loopexit.unr-lcssa, label %for.body
https://reviews.llvm.org/D28625
More information about the llvm-commits
mailing list