[PATCH] D60668: [IR] Add WithOverflowInst class

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 14 07:28:26 PDT 2019


nikic created this revision.
nikic added reviewers: lebedev.ri, spatel.
Herald added subscribers: llvm-commits, sanjoy, hiraditya.
Herald added a project: LLVM.

Related to D60656 <https://reviews.llvm.org/D60656>. This adds a WithOverflowInst class with a few helper methods to get the underlying binop, signedness and nowrap type and makes use of it where sensible. I think the result is pretty nice and there will be two more uses in D60650 <https://reviews.llvm.org/D60650>/D60656 <https://reviews.llvm.org/D60656>.

The refactorings are all NFC, though I left a couple of TODOs where things could be improved. In particular we have two places where add/sub are handled but mul isn't.

As a followup for this, I believe it would be good to add PatternMatch support for m_ExtractValue() and m_WithOverflow(), so you can write something like `m_ExtractValue(m_WithOverflow(WO), 0)`, which is a common pattern.


Repository:
  rL LLVM

https://reviews.llvm.org/D60668

Files:
  llvm/include/llvm/Analysis/ValueTracking.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/NewGVN.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60668.195066.patch
Type: text/x-patch
Size: 20849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190414/beb26ad9/attachment-0001.bin>


More information about the llvm-commits mailing list