Skip to content

Instantly share code, notes, and snippets.

@aqjune
aqjune / gist:0dc142cfeb7417d637a1f3682a87d7dc
Created October 18, 2021 03:20
ff_seek_frame_binary.c
int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
int64_t target_ts, int flags)
{
const AVInputFormat *const avif = s->iformat;
int64_t pos_min=pos_min, pos_max=pos_max, pos, pos_limit;
int64_t ts_min, ts_max, ts;
int index;
int64_t ret;
AVStream *st;
FFStream *sti;
@aqjune
aqjune / conv2d_to_img2col_opt.mlir
Created June 17, 2021 09:55
conv2d_to_img2col_opt.mlir
// RUN: iree-opt -split-input-file -iree-codegen-convert-conv-to-img2col %s
#map0 = affine_map<(d0, d1, d2, d3, d4, d5) -> (d0, d1 + d3, d2 + d4, d5)>
#map1 = affine_map<(d0, d1, d2, d3, d4, d5) -> (d0, d1, d2, d3, d4, d5)>
module {
func @conv_16433136(%arg0: tensor<1x16x16x4xf32>, %arg1: tensor<3x3x4x16xf32>, %arg2: tensor<1x14x14x16xf32>) -> tensor<1x14x14x16xf32> {
%0 = linalg.init_tensor [1, 14, 14, 3, 3, 4] : tensor<1x14x14x3x3x4xf32>
%1 = linalg.generic {indexing_maps = [#map0, #map1], iterator_types = ["parallel", "parallel", "parallel", "parallel", "parallel", "parallel"]} ins(%arg0 : tensor<1x16x16x4xf32>) outs(%0 : tensor<1x14x14x3x3x4xf32>) {
^bb0(%arg3: f32, %arg4: f32): // no predecessors
linalg.yield %arg3 : f32
@aqjune
aqjune / tellg.cpp
Created April 27, 2021 05:09
tellg.cpp
#include<iostream>
#include<sstream>
using namespace std;
int main() {
stringstream ss;
ss << "aa\nbb\n";
string str1;
getline(ss, str1);
cout << "str(): " << ss.str() << endl;
@aqjune
aqjune / output.txt
Created February 18, 2021 09:40
select-safe-bool-transforms.ll translation validation
----------------------------------------
define i1 @merge_logical_and_and(i1 %X, i1 %Y) {
%0:
%c = select i1 %X, i1 %Y, i1 0
%res = and i1 %X, %c
ret i1 %res
}
=>
define i1 @merge_logical_and_and(i1 %X, i1 %Y) {
@aqjune
aqjune / addnsw.patch
Created February 8, 2021 13:50
Add nsw patch
diff --git a/ir/instr.cpp b/ir/instr.cpp
index 21e015a..4d93443 100644
--- a/ir/instr.cpp
+++ b/ir/instr.cpp
@@ -367,8 +367,17 @@ StateValue BinOp::toSMT(State &s) const {
case Add:
fn = [&](auto a, auto ap, auto b, auto bp) -> StateValue {
expr non_poison = true;
- if (flags & NSW)
+ if (flags & NSW) {
@aqjune
aqjune / res.txt
Created February 8, 2021 07:58
list-nodiffs.sh results
NODIFF: ./constexpr/ret.src.ll
NODIFF: ./constexpr/shufflevector-nocopy.src.ll
NODIFF: ./unordered-bbs.src.ll
NODIFF: ./memory/calloc-undef.src.ll
ill-formed test: ./calls/fncall-noreturn2.srctgt.ll
ill-formed test: ./globals/const2.srctgt.ll
NODIFF: ./libcalls/gettimeofday.srctgt.ll
NODIFF: ./attrs/dereferenceable-shrink.srctgt.ll
ill-formed test: ./memory/glb-6.srctgt.ll
ill-formed test: ./memory/bitcast.srctgt.ll
@aqjune
aqjune / list-nodiffs.sh
Last active February 8, 2021 07:58
list-nodiffs.sh
tempsrc=`mktemp`
temptgt=`mktemp`
# 1. src.ll/tgt.ll tests
for i in `find . -name "*.src.ll"`; do
itgt="${i%.src.ll}.tgt.ll"
grep -v '^;' $i | awk 'NF' >$tempsrc # ignore comments and whitespaces
grep -v '^;' $itgt | awk 'NF' >$temptgt
@aqjune
aqjune / a.diff
Created January 16, 2021 11:36
diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 6a7fe9d707a2..ad4b13a52300 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -49,7 +49,7 @@ using namespace PatternMatch;
/// FIXME: Enabled by default until the pattern is supported well.
static cl::opt<bool> EnableUnsafeSelectTransform(
- "instcombine-unsafe-select-transform", cl::init(true),
+ "instcombine-unsafe-select-transform", cl::init(false),
@aqjune
aqjune / diff.txt
Created January 16, 2021 11:36
Diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 6a7fe9d707a2..ad4b13a52300 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -49,7 +49,7 @@ using namespace PatternMatch;
/// FIXME: Enabled by default until the pattern is supported well.
static cl::opt<bool> EnableUnsafeSelectTransform(
- "instcombine-unsafe-select-transform", cl::init(true),
+ "instcombine-unsafe-select-transform", cl::init(false),
target datalayout="e"
;target datalayout="E" ; both is fine
define void @src(i8** %q) {
%ofs = shl i64 7, 60
%p = getelementptr i8, i8* null, i64 %ofs
store i8* %p, i8** %q
ret void
}