From 5a6215a127c6ae78b0faac6af09988e13b927474 Mon Sep 17 00:00:00 2001 From: Pei Mu Date: Mon, 1 May 2023 20:15:42 +0100 Subject: [PATCH] __builtin_assume example Addresses #653. --- ...14cf5545715f1cfc7d1b362a6c646fd988aafe.txt | 46 +++++++++++++++++++ applications/newton/llvm-ir/c-files/e_acosh.c | 1 + .../llvm-ir/c-files/inferBoundControlFlow.c | 1 + .../newton/llvm-ir/performance_test/Makefile | 12 +++++ 4 files changed, 60 insertions(+) create mode 100644 analysis/statistics/cb14cf5545715f1cfc7d1b362a6c646fd988aafe.txt diff --git a/analysis/statistics/cb14cf5545715f1cfc7d1b362a6c646fd988aafe.txt b/analysis/statistics/cb14cf5545715f1cfc7d1b362a6c646fd988aafe.txt new file mode 100644 index 000000000..f51786b31 --- /dev/null +++ b/analysis/statistics/cb14cf5545715f1cfc7d1b362a6c646fd988aafe.txt @@ -0,0 +1,46 @@ + +changeset: 1480:cb14cf5545715f1cfc7d1b362a6c646fd988aafe +char kNewtonVersion[] = "0.3-alpha-1480 (cb14cf5545715f1cfc7d1b362a6c646fd988aafe) (build 05-01-2023-11:20-pei@pei-G5-5500-Linux-5.19.0-41-generic-x86_64)"; +\n./src/noisy/noisy-linux-EN -O0 applications/noisy/helloWorld.n -s +\n./src/newton/newton-linux-EN -v 0 -eP applications/newton/invariants/ViolinWithTemperatureDependence-pigroups.nt + +Informational Report: +--------------------- +Invariant "ViolinWithTemperatureDependenceForPiGroups" has 2 unique kernels, each with 2 column(s)... + + Kernel 0 is a valid kernel: + + 1 1 + -0.5 -0 + 1 0 + 0.5 0 + 0 -1 + -0 -1 + + + The ordering of parameters is: P1 P0 P3 P2 P4 P5 + + Pi group 0, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^( 0) P5^(-0) + + Pi group 0, Pi 1 is: P0^(-0) P1^( 1) P2^( 0) P3^( 0) P4^(-1) P5^(-1) + + + Kernel 1 is a valid kernel: + + 1 0 + -0.5 1 + 1 -2 + 0.5 -1 + -0 -2 + 0 -2 + + + The ordering of parameters is: P1 P0 P3 P2 P4 P5 + + Pi group 1, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^(-0) P5^( 0) + + Pi group 1, Pi 1 is: P0^( 1) P1^( 0) P2^(-1) P3^(-2) P4^(-2) P5^(-2) + + + + diff --git a/applications/newton/llvm-ir/c-files/e_acosh.c b/applications/newton/llvm-ir/c-files/e_acosh.c index ef9053877..a41440fb2 100644 --- a/applications/newton/llvm-ir/c-files/e_acosh.c +++ b/applications/newton/llvm-ir/c-files/e_acosh.c @@ -48,6 +48,7 @@ double __ieee754_acosh(x) bmx055xAcceleration x; #endif { + __builtin_assume(x > 3 && x < 10); double t; int hx; hx = __HI(x); diff --git a/applications/newton/llvm-ir/c-files/inferBoundControlFlow.c b/applications/newton/llvm-ir/c-files/inferBoundControlFlow.c index 9535b0664..f1b41d7bd 100644 --- a/applications/newton/llvm-ir/c-files/inferBoundControlFlow.c +++ b/applications/newton/llvm-ir/c-files/inferBoundControlFlow.c @@ -46,6 +46,7 @@ typedef double bmx055xAcceleration; // [-16, 16] static int ifStatement(bmx055xAcceleration x) { + __builtin_assume(x > 3 && x < 10); int y = 397; /* * If statement diff --git a/applications/newton/llvm-ir/performance_test/Makefile b/applications/newton/llvm-ir/performance_test/Makefile index a779c32f7..32b864225 100644 --- a/applications/newton/llvm-ir/performance_test/Makefile +++ b/applications/newton/llvm-ir/performance_test/Makefile @@ -221,6 +221,14 @@ madgwick_opt: llvm-dis ../MadgwickAHRSfix_output.bc $(call max_opt_fn,MadgwickAHRSfix) +inferBoundControlFlow_non_opt: + $(call max_opt_fn,inferBoundControlFlow) + +inferBoundControlFlow_opt: + cd $(NEWTON_BIN_DIR) && $(call newton_opt_fn,MadgwickAHRSfix) + llvm-dis ../MadgwickAHRSfix_output.bc + $(call max_opt_fn,inferBoundControlFlow) + compile_test_madgwick: $(CC) $(TARGET_FLAG) ../test_madgwick.c -no-pie -L. -lout -O3 -Os -o main_out -lm @@ -298,6 +306,10 @@ perf_func_call: clean make_ll func_call_opt compile_lib compile_func_call interface_lib: clean make_ll soft_float_api_opt compile_lib +perf_inferBoundControlFlow: clean make_ll inferBoundControlFlow_non_opt compile_lib + +perf_inferBoundControlFlow_opt: clean make_ll inferBoundControlFlow_opt compile_lib + auto_test_compile: clang++ auto_test.cpp -g -o auto_test