[test-suite] r332395 - [test-suite][ubsan] Remove optimization that causes UB in SimpleMOC.

Brian Homerding via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 13:42:38 PDT 2018


Author: homerdin
Date: Tue May 15 13:42:38 2018
New Revision: 332395

URL: http://llvm.org/viewvc/llvm-project?rev=332395&view=rev
Log:
[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.

Modified:
    test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c

Modified: test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c?rev=332395&r1=332394&r2=332395&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C/SimpleMOC/solver.c Tue May 15 13:42:38 2018
@@ -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)




More information about the llvm-commits mailing list