[PATCH] D46193: [LSR] Skip LSR if the cost of input is cheaper than LSR's solution
Krzysztof Parzyszek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 9 10:55:22 PDT 2018
kparzysz added a comment.
Here's the IR immediately before LSR:
define dso_local i32 @foo(%struct.S* nocapture readonly %Data, i32 %Off, i32 %Idx, i32* nocapture %Out) local_unnamed_addr #0 {
entry:
%X = getelementptr inbounds %struct.S, %struct.S* %Data, i32 0, i32 0
%0 = load i32, i32* %X, align 4, !tbaa !2
%cmp = icmp sgt i32 %0, %Off
br i1 %cmp, label %while.cond.preheader, label %cleanup
while.cond.preheader: ; preds = %entry
%Y = getelementptr inbounds %struct.S, %struct.S* %Data, i32 0, i32 1
%1 = load i32, i32* %Y, align 4, !tbaa !8
br label %while.cond
while.cond: ; preds = %while.cond, %while.cond.preheader
%Col.0 = phi i32 [ %sub, %while.cond ], [ %Idx, %while.cond.preheader ]
%cmp1 = icmp slt i32 %Col.0, %1
%sub = sub nsw i32 %Col.0, %1
br i1 %cmp1, label %while.end, label %while.cond
while.end: ; preds = %while.cond
%Ptr = getelementptr inbounds %struct.S, %struct.S* %Data, i32 0, i32 2
%2 = load i32*, i32** %Ptr, align 4, !tbaa !9
%add.ptr = getelementptr inbounds i32, i32* %2, i32 %Col.0
%mul = mul nsw i32 %1, %Off
%add.ptr4 = getelementptr inbounds i32, i32* %add.ptr, i32 %mul
%3 = load i32, i32* %add.ptr4, align 4, !tbaa !10
store i32 %3, i32* %Out, align 4, !tbaa !10
br label %cleanup
cleanup: ; preds = %entry, %while.end
%retval.0 = phi i32 [ 0, %while.end ], [ 5, %entry ]
ret i32 %retval.0
}
https://reviews.llvm.org/D46193
More information about the llvm-commits
mailing list