Skip to content

Instantly share code, notes, and snippets.

@mtrofin
Created May 9, 2022 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtrofin/19ccc1c0fc2da8689422837ad442896c to your computer and use it in GitHub Desktop.
Save mtrofin/19ccc1c0fc2da8689422837ad442896c to your computer and use it in GitHub Desktop.
D125248 sample
; RUN: opt -aa-pipeline=default /tmp/example3.ll -S -passes='instcombine,gvn,simplifycfg<switch-range-to-icmp;hoist-common-insts;sink-common-insts>'
declare void @consume(i32)
define dso_local void @bilinearKernel(i32 noundef %height, [256 x i32]* nocapture noundef readonly %inputImage, i1 %test, i64 %index, i32 %t.exit, i32 %t.exit1) {
entry:
br label %for.preheader
for.preheader:
%i = phi i32 [%i.next, %for.backedge], [0, %entry]
%div = lshr i32 %i, 2
%idx1 = zext i32 %div to i64
%add = add i32 %div, 1
%cmp = icmp slt i32 %add, %height
%idx2 = zext i32 %div to i64
; ; Option 1:
; %cmp.fr = freeze i1 %cmp
; br i1 %cmp.fr, label %for.body.us1, label %for.body.us2
; Option 2:
br i1 %cmp, label %for.body.us1, label %for.body.us2
for.body.us2:
%j = phi i32 [ %inc.us199, %for.inc.us198 ], [ 0, %for.preheader]
br i1 %test, label %if.then, label %if.else
if.else:
%arrayidx93.us189 = getelementptr inbounds [256 x i32], [256 x i32]* %inputImage, i64 %idx1, i64 %index
%val1 = load i32, i32* %arrayidx93.us189, align 4
call void @consume(i32 %val1)
br label %for.inc.us198
if.then:
%arrayidx68.us = getelementptr inbounds [256 x i32], [256 x i32]* %inputImage, i64 %idx2, i64 %index
%val2 = load i32, i32* %arrayidx68.us, align 4
call void @consume(i32 %val2)
br label %for.inc.us198
for.body.us1:
br label %for.backedge
for.inc.us198:
%inc.us199 = add nuw nsw i32 %j, 1
%cmp5.us200 = icmp slt i32 %inc.us199, %t.exit1
br i1 %cmp5.us200, label %for.body.us2, label %for.backedge
for.backedge:
%i.next = add nuw nsw i32 %i, 1
%cmp.us = icmp slt i32 %i.next, %t.exit
br i1 %cmp.us, label %for.preheader, label %end
end:
ret void
}
define dso_local void @bilinearKernel(i32 noundef %height, [256 x i32]* nocapture noundef readonly %inputImage, i1 %test, i64 %index, i32 %t.exit, i32 %t.exit1) {
entry:
br label %for.preheader
for.preheader: ; preds = %for.backedge, %entry
%i = phi i32 [ %i.next, %for.backedge ], [ 0, %entry ]
%div = lshr i32 %i, 2
%idx1 = zext i32 %div to i64
%div.fr = freeze i32 %div
%add = add i32 %div.fr, 1
%cmp = icmp slt i32 %add, %height
%idx2 = zext i32 %div.fr to i64
br i1 %cmp, label %for.backedge, label %for.body.us2
for.body.us2: ; preds = %for.body.us2, %for.preheader
%j = phi i32 [ %inc.us199, %for.body.us2 ], [ 0, %for.preheader ]
%idx2.idx1 = select i1 %test, i64 %idx2, i64 %idx1
%arrayidx68.us = getelementptr inbounds [256 x i32], [256 x i32]* %inputImage, i64 %idx2.idx1, i64 %index
%val2 = load i32, i32* %arrayidx68.us, align 4
call void @consume(i32 %val2)
%inc.us199 = add nuw nsw i32 %j, 1
%cmp5.us200 = icmp slt i32 %inc.us199, %t.exit1
br i1 %cmp5.us200, label %for.body.us2, label %for.backedge
for.backedge: ; preds = %for.preheader, %for.body.us2
%i.next = add nuw nsw i32 %i, 1
%cmp.us = icmp slt i32 %i.next, %t.exit
br i1 %cmp.us, label %for.preheader, label %end
end: ; preds = %for.backedge
ret void
}
define dso_local void @bilinearKernel(i32 noundef %height, [256 x i32]* nocapture noundef readonly %inputImage, i1 %test, i64 %index, i32 %t.exit, i32 %t.exit1) {
entry:
br label %for.preheader
for.preheader: ; preds = %for.backedge, %entry
%i = phi i32 [ %i.next, %for.backedge ], [ 0, %entry ]
%div = lshr i32 %i, 2
%idx1 = zext i32 %div to i64
%add = add nuw nsw i32 %div, 1
%cmp = icmp slt i32 %add, %height
br i1 %cmp, label %for.backedge, label %for.body.us2
for.body.us2: ; preds = %for.body.us2, %for.preheader
%j = phi i32 [ %inc.us199, %for.body.us2 ], [ 0, %for.preheader ]
%arrayidx68.us = getelementptr inbounds [256 x i32], [256 x i32]* %inputImage, i64 %idx1, i64 %index
%val2 = load i32, i32* %arrayidx68.us, align 4
call void @consume(i32 %val2)
%inc.us199 = add nuw nsw i32 %j, 1
%cmp5.us200 = icmp slt i32 %inc.us199, %t.exit1
br i1 %cmp5.us200, label %for.body.us2, label %for.backedge
for.backedge: ; preds = %for.preheader, %for.body.us2
%i.next = add nuw nsw i32 %i, 1
%cmp.us = icmp slt i32 %i.next, %t.exit
br i1 %cmp.us, label %for.preheader, label %end
end: ; preds = %for.backedge
ret void
}
define dso_local void @bilinearKernel(i32 noundef %height, [256 x i32]* nocapture noundef readonly %inputImage, i1 %test, i64 %index, i32 %t.exit, i32 %t.exit1) {
entry:
br label %for.preheader
for.preheader: ; preds = %for.backedge, %entry
%i = phi i32 [ %i.next, %for.backedge ], [ 0, %entry ]
%i.fr = freeze i32 %i
%div = lshr i32 %i.fr, 2
%idx1 = zext i32 %div to i64
%add = add nuw nsw i32 %div, 1
%cmp = icmp slt i32 %add, %height
br i1 %cmp, label %for.backedge, label %for.body.us2
for.body.us2: ; preds = %for.body.us2, %for.preheader
%j = phi i32 [ %inc.us199, %for.body.us2 ], [ 0, %for.preheader ]
%arrayidx68.us = getelementptr inbounds [256 x i32], [256 x i32]* %inputImage, i64 %idx1, i64 %index
%val2 = load i32, i32* %arrayidx68.us, align 4
call void @consume(i32 %val2)
%inc.us199 = add nuw nsw i32 %j, 1
%cmp5.us200 = icmp slt i32 %inc.us199, %t.exit1
br i1 %cmp5.us200, label %for.body.us2, label %for.backedge
for.backedge: ; preds = %for.preheader, %for.body.us2
%i.next = add nuw nsw i32 %i.fr, 1
%cmp.us = icmp slt i32 %i.next, %t.exit
br i1 %cmp.us, label %for.preheader, label %end
end: ; preds = %for.backedge
ret void
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment