Skip to content

Instantly share code, notes, and snippets.

@bjacob
Created March 5, 2025 19:49
Show Gist options
  • Save bjacob/53e17e34e5654b99b8cc46fa59198100 to your computer and use it in GitHub Desktop.
Save bjacob/53e17e34e5654b99b8cc46fa59198100 to your computer and use it in GitHub Desktop.
// -----// IR Dump After CSE (cse) //----- //
func.func @__builtin_fill_i64(%arg0: !util.buffer, %arg1: !util.buffer, %arg2: !util.list<!util.buffer>, %arg3: i32, %arg4: i32, %arg5: i32, %arg6: i32, %arg7: i32, %arg8: i32, %arg9: i32, %arg10: i32, %arg11: i32) attributes {translation_info = #iree_codegen.translation_info<pipeline = VMVXDefault>} {
%c12 = arith.constant 12 : index
%c8 = arith.constant 8 : index
%c4 = arith.constant 4 : index
%c0 = arith.constant 0 : index
%c32_i64 = arith.constant 32 : i64
%c1 = arith.constant 1 : index
%buffer_size = util.buffer.size %arg1 : !util.buffer
%0 = util.buffer.load %arg1[%c0 for %c4] : !util.buffer{%buffer_size} -> i32
%1 = util.buffer.load %arg1[%c4 for %c4] : !util.buffer{%buffer_size} -> i32
%2 = util.buffer.load %arg1[%c8 for %c4] : !util.buffer{%buffer_size} -> i32
%3 = util.buffer.load %arg1[%c12 for %c4] : !util.buffer{%buffer_size} -> i32
%4 = arith.extui %0 : i32 to i64
%5 = arith.extui %1 : i32 to i64
%6 = arith.shli %5, %c32_i64 : i64
%7 = arith.ori %4, %6 : i64
%8 = arith.index_castui %7 : i64 to index
%9 = arith.extui %2 : i32 to i64
%10 = arith.extui %3 : i32 to i64
%11 = arith.shli %10, %c32_i64 : i64
%12 = arith.ori %9, %11 : i64
%13 = util.list.get %arg2[%c0] : !util.list<!util.buffer>
%14 = arith.index_cast %arg3 : i32 to index
%15 = arith.index_cast %arg9 : i32 to index
%16 = affine.apply affine_map<()[s0] -> (s0 * 64)>()[%14]
%17 = affine.apply affine_map<()[s0] -> (s0 * 64)>()[%15]
scf.for %arg12 = %16 to %c1 step %17 {
%18 = affine.apply affine_map<()[s0, s1] -> (s0 + s1 floordiv 8)>()[%arg12, %8]
%buffer_size_0 = util.buffer.size %13 : !util.buffer
%19 = arith.muli %18, %c8 : index
util.buffer.store %12, %13[%19 for %c8] : i64 -> !util.buffer{%buffer_size_0}
}
return
}
// -----// IR Dump After LowerAffinePass (lower-affine) //----- //
func.func @__builtin_fill_i64(%arg0: !util.buffer, %arg1: !util.buffer, %arg2: !util.list<!util.buffer>, %arg3: i32, %arg4: i32, %arg5: i32, %arg6: i32, %arg7: i32, %arg8: i32, %arg9: i32, %arg10: i32, %arg11: i32) attributes {translation_info = #iree_codegen.translation_info<pipeline = VMVXDefault>} {
%c12 = arith.constant 12 : index
%c8 = arith.constant 8 : index
%c4 = arith.constant 4 : index
%c0 = arith.constant 0 : index
%c32_i64 = arith.constant 32 : i64
%c1 = arith.constant 1 : index
%buffer_size = util.buffer.size %arg1 : !util.buffer
%0 = util.buffer.load %arg1[%c0 for %c4] : !util.buffer{%buffer_size} -> i32
%1 = util.buffer.load %arg1[%c4 for %c4] : !util.buffer{%buffer_size} -> i32
%2 = util.buffer.load %arg1[%c8 for %c4] : !util.buffer{%buffer_size} -> i32
%3 = util.buffer.load %arg1[%c12 for %c4] : !util.buffer{%buffer_size} -> i32
%4 = arith.extui %0 : i32 to i64
%5 = arith.extui %1 : i32 to i64
%6 = arith.shli %5, %c32_i64 : i64
%7 = arith.ori %4, %6 : i64
%8 = arith.index_castui %7 : i64 to index
%9 = arith.extui %2 : i32 to i64
%10 = arith.extui %3 : i32 to i64
%11 = arith.shli %10, %c32_i64 : i64
%12 = arith.ori %9, %11 : i64
%13 = util.list.get %arg2[%c0] : !util.list<!util.buffer>
%14 = arith.index_cast %arg3 : i32 to index
%15 = arith.index_cast %arg9 : i32 to index
%c64 = arith.constant 64 : index
%16 = arith.muli %14, %c64 overflow<nsw> : index
%c64_0 = arith.constant 64 : index
%17 = arith.muli %15, %c64_0 overflow<nsw> : index
scf.for %arg12 = %16 to %c1 step %17 {
%c8_1 = arith.constant 8 : index
%c0_2 = arith.constant 0 : index
%c-1 = arith.constant -1 : index
%18 = arith.cmpi slt, %8, %c0_2 : index
%19 = arith.subi %c-1, %8 : index
%20 = arith.select %18, %19, %8 : index
%21 = arith.divsi %20, %c8_1 : index
%22 = arith.subi %c-1, %21 : index
%23 = arith.select %18, %22, %21 : index
%24 = arith.addi %arg12, %23 : index
%buffer_size_3 = util.buffer.size %13 : !util.buffer
%25 = arith.muli %24, %c8 : index
util.buffer.store %12, %13[%25 for %c8] : i64 -> !util.buffer{%buffer_size_3}
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment