[PATCH] D47016: [Fixed Point Arithmetic] Validation Test for Saturated Division and Comparison Fix

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 17 07:59:32 PDT 2018


leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch includes changes for division on saturated fixed point types. Overflow occurs when the resulting value cannot fit into the number of data bits for the resulting type.

For signed division, we cap at the max value of the type when the dividend sign is positive, divisor sign is negative, but the quotient is still positive. Reciprocally, we cap at the min value if the dividend is negative, divisor is positive, and quotient is negative.

For unsigned division, overflow occurs if the resulting value exceeds the max possible value that this type can hold.

The logic for comparisons between fixed point types was also fixed to account for padding bits. Since the padding bits contains values we do not care about, we mask the fixed point data bits in the underlying integral that we do care about and compare them.

This is a child of https://reviews.llvm.org/D46990


Repository:
  rC Clang

https://reviews.llvm.org/D47016

Files:
  include/clang/AST/Type.h
  include/clang/Basic/FixedPoint.h.in
  lib/AST/Type.cpp
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_all_builtin_operations.c
  test/Frontend/fixed_point_validation.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47016.147319.patch
Type: text/x-patch
Size: 12824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180517/f7676c80/attachment.bin>


More information about the cfe-commits mailing list