https://github.com/halide/Halide
Revision 63cfd9daa3d3da08ef4bfbd42040faf8fda389fa authored by Andrew Adams on 12 October 2021, 20:52:24 UTC, committed by GitHub on 12 October 2021, 20:52:24 UTC
* Look through lets in find_intrinsics

If an Expr like: narrow((widen(x) + y + 1)/2) gets lifted into a let,
the simplifier will then substitute things in like so: let foo =
widen(x) + y in narrow(foo + 1)/2, potentially breaking a pattern. This
is a general problem for patterns that widen, do some math, and then
narrow.

They will always get cut at the widening operation, so this PR just
substitutes in all widening operations. This can't cause combinatorial
blow-up, because each substitution has a wider type than the values that
it depends on, so the chains can be at most 2-3 lets deep.

* Make substituting in widening lets a prepass instead

* Move find_intrinsics a little earlier in lowering

* Handle impure subexpressions

by leaving them behind at the original let site

* FindIntrinsics must be after the last simplification pass
1 parent a351021
Raw File
Tip revision: 63cfd9daa3d3da08ef4bfbd42040faf8fda389fa authored by Andrew Adams on 12 October 2021, 20:52:24 UTC
Substitute in all widening lets prior to find_intrinsics (#6307)
Tip revision: 63cfd9d
run-clang-format.sh
#!/bin/bash

set -e

ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# We are currently standardized on using LLVM/Clang12 for this script.
# Note that this is totally independent of the version of LLVM that you
# are using to build Halide itself. If you don't have LLVM12 installed,
# you can usually install what you need easily via:
#
# sudo apt-get install llvm-12 clang-12 libclang-12-dev clang-tidy-12
# export CLANG_FORMAT_LLVM_INSTALL_DIR=/usr/lib/llvm-12

[ -z "$CLANG_FORMAT_LLVM_INSTALL_DIR" ] && echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." && exit
echo CLANG_FORMAT_LLVM_INSTALL_DIR = ${CLANG_FORMAT_LLVM_INSTALL_DIR}

VERSION=$(${CLANG_FORMAT_LLVM_INSTALL_DIR}/bin/clang-format --version)
if [[ ${VERSION} =~ .*version\ 12.* ]]
then
    echo "clang-format version 12 found."
else
    echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM 12 install!"
    exit 1
fi

# Note that we specifically exclude files starting with . in order
# to avoid finding emacs backup files
find "${ROOT_DIR}/apps" \
     "${ROOT_DIR}/src" \
     "${ROOT_DIR}/tools" \
     "${ROOT_DIR}/test" \
     "${ROOT_DIR}/util" \
     "${ROOT_DIR}/python_bindings" \
     \( -name "*.cpp" -o -name "*.h" -o -name "*.c" \) -and -not -wholename "*/.*" | \
     xargs ${CLANG_FORMAT_LLVM_INSTALL_DIR}/bin/clang-format -i -style=file
back to top