[all-commits] [llvm/llvm-project] 9ca363: [APInt] Add saturating truncation methods

Roman Lebedev via All-commits all-commits at lists.llvm.org
Fri Nov 8 06:53:22 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9ca363d89c103b06b986f87c0eaf3e8a00b06947
      https://github.com/llvm/llvm-project/commit/9ca363d89c103b06b986f87c0eaf3e8a00b06947
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2019-11-08 (Fri, 08 Nov 2019)

  Changed paths:
    M llvm/include/llvm/ADT/APInt.h
    M llvm/lib/Support/APInt.cpp
    M llvm/unittests/ADT/APIntTest.cpp

  Log Message:
  -----------
  [APInt] Add saturating truncation methods

Summary:
The signed one is needed for implementation of `ConstantRange::smul_sat()`,
unsigned is for completeness only.

Reviewers: nikic, RKSimon, spatel

Reviewed By: nikic

Subscribers: hiraditya, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69993


  Commit: 5a9fd76d2f7cd831cb02a33ea6a267256e37f69c
      https://github.com/llvm/llvm-project/commit/5a9fd76d2f7cd831cb02a33ea6a267256e37f69c
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2019-11-08 (Fri, 08 Nov 2019)

  Changed paths:
    M llvm/include/llvm/IR/ConstantRange.h
    M llvm/lib/IR/ConstantRange.cpp
    M llvm/unittests/IR/ConstantRangeTest.cpp

  Log Message:
  -----------
  [ConstantRange] Add umul_sat()/smul_sat() methods

Summary:
To be used in `ConstantRange::mulWithNoOverflow()`,
may in future be useful for when saturating shift/mul ops are added.

These are precise as far as i can tell.

I initially though i will need `APInt::[us]mul_sat()` for these,
but it turned out much simpler to do what `ConstantRange::multiply()`
does - perform multiplication in twice the bitwidth, and then truncate.
Though here we want saturating signed truncation.

Reviewers: nikic, reames, spatel

Reviewed By: nikic

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69994


  Commit: 7dddfa2a9c14d9627d76474c05542a5675c7716e
      https://github.com/llvm/llvm-project/commit/7dddfa2a9c14d9627d76474c05542a5675c7716e
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2019-11-08 (Fri, 08 Nov 2019)

  Changed paths:
    M llvm/lib/IR/ConstantRange.cpp

  Log Message:
  -----------
  [NFC] ConstantRange::subWithNoWrap(): fixup comment


Compare: https://github.com/llvm/llvm-project/compare/1f592ecf8238...7dddfa2a9c14


More information about the All-commits mailing list