From 165f90357fab423c7a9b4394ae0b9b1161c6f15a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 21 Jul 2011 16:04:16 +0100 Subject: [PATCH] Tiny cleanups, doc update re int8/16 performance --- docs/ispc.txt | 10 ++++++++++ expr.cpp | 2 +- stdlib.ispc | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/ispc.txt b/docs/ispc.txt index 25695004..93afe154 100644 --- a/docs/ispc.txt +++ b/docs/ispc.txt @@ -93,6 +93,7 @@ Contents: + `Understanding How to Interoperate With the Application's Data`_ + `Communicating Between SPMD Program Instances`_ + `Gather and Scatter`_ + + `8 and 16-bit Integer Types`_ + `Low-level Vector Tricks`_ + `Debugging`_ + `The "Fast math" Option`_ @@ -2528,6 +2529,15 @@ do a vector load. For example, given: A regular vector load is done from array, starting at offset ``2*x``. + +8 and 16-bit Integer Types +-------------------------- + +The code generated for 8 and 16-bit integer types is generally not as +efficient as the code generated for 32-bit integer types. It is generally +worthwhile to use 32-bit integer types for intermediate computations, even +if the final result will be stored in a smaller integer type. + Low-level Vector Tricks ----------------------- diff --git a/expr.cpp b/expr.cpp index 4052159c..5c19347b 100644 --- a/expr.cpp +++ b/expr.cpp @@ -1659,7 +1659,7 @@ AssignExpr::TypeCheck() { if (rvalue != NULL) rvalue = rvalue->TypeCheck(); if (rvalue != NULL && lvalue != NULL) - rvalue = rvalue->TypeConv(lvalue->GetType(), "operator ="); + rvalue = rvalue->TypeConv(lvalue->GetType(), "assignment"); if (rvalue == NULL || lvalue == NULL) return NULL; diff --git a/stdlib.ispc b/stdlib.ispc index cef517c3..2b8dc582 100644 --- a/stdlib.ispc +++ b/stdlib.ispc @@ -2363,7 +2363,7 @@ static inline uniform float half_to_float(uniform unsigned int16 h) { uniform unsigned int32 hs = h & (int32)0x8000u; // Pick off sign bit uniform unsigned int32 he = h & (int32)0x7C00u; // Pick off exponent bits uniform unsigned int32 hm = h & (int32)0x03FFu; // Pick off mantissa bits - cif (he == 0) { + if (he == 0) { // Denormal will convert to normalized uniform int e = -1; // The following loop figures out how much extra to adjust the exponent @@ -2485,7 +2485,7 @@ static inline uniform int16 float_to_half(uniform float f) { ret = (xs >> 16); } else { - cif (xe == 0x7F800000u) { + if (xe == 0x7F800000u) { // Inf or NaN (all the exponent bits are set) if (xm == 0) // Zero mantissa -> signed infinity