[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 19 10:24:58 PST 2018


leonardchan added inline comments.


================
Comment at: clang/test/Frontend/fixed_point_add.c:269
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = call i15 @llvm.uadd.sat.i15(i15 [[USA_TRUNC]], i15 [[USA_SAT_TRUNC]])
+  // UNSIGNED-NEXT: [[SUM_EXT:%[a-z0-9]+]] = zext i15 [[SUM]] to i16
+  // UNSIGNED-NEXT: store i16 [[SUM_EXT]], i16* %usa_sat, align 2
----------------
ebevhan wrote:
> This is probably a candidate for an isel optimization. This operation also works as an `i16 ssat.add` with a negative-clamp-to-zero afterwards, and if the target supports `i16 ssat.add` natively then it will likely be a lot more efficient than whatever an `i15 uadd.sat` produces.
Do you think it would be more efficient for now then if instead we did SHL by 1, saturate, then [AL]SHR by 1? This way we could use `i16 ssat.add` instead of `i15 ssat.add`?


Repository:
  rC Clang

https://reviews.llvm.org/D53738





More information about the cfe-commits mailing list