aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Homerding <homerdin@gmail.com>2018-05-15 20:42:38 +0000
committerBrian Homerding <homerdin@gmail.com>2018-05-15 20:42:38 +0000
commitf9c975a1e7ffc5c3c0dca6e52b53831319af5d25 (patch)
tree48fc15624ee86c32ab97cfba2d42b605b4e0d513
parentc7a2924a68899a25cffa058d8b38247c33b4f8e8 (diff)
[test-suite][ubsan] Remove optimization that causes UB in SimpleMOC.
This patch replaces the hand written ceil() with a call to ceilf(). This small optimization is outside the primary kernel and should show little to no difference in performance for the test suite. Previously the UB was only used in an '==' comparison for an early exit from the loop and had no effect on the program behavior. git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@332395 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c b/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c
index b9fca131..5560f457 100644
--- a/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c
+++ b/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c
@@ -904,10 +904,8 @@ int get_pos_interval( float z, float dz)
* negative direction */
int get_neg_interval( float z, float dz)
{
- // NOTE: a bit of trickery using floors to obtain ceils
- int interval = INT_MAX - (int) ( (double) INT_MAX
- - (double) ( z / dz ) );
- return interval;
+ int interval = (int) ( ceilf( z / dz ) );
+ return interval;
}
int calc_next_fai( float z, float dz, bool pos_dir)