[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 18 03:54:49 PDT 2024


================
@@ -946,6 +946,56 @@ class PossiblyNonNegInst : public CastInst {
   }
 };
 
+/// Cast Instruction that can have a nowrap flags (only trunc)
+class PossiblyNoWrapInst : public CastInst {
+public:
+  enum { AnyWrap = 0, NoUnsignedWrap = (1 << 0), NoSignedWrap = (1 << 1) };
+
+  static bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::Trunc;
+  }
+
+  static bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
----------------
arsenm wrote:

```suggestion
    const Instruction *I = dyn_cast<Instruction>(V);
    return I && classof(I);
```

https://github.com/llvm/llvm-project/pull/85592


More information about the llvm-commits mailing list