[llvm] [IR] Add zext nneg flag (PR #67982)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 12:15:41 PDT 2023


================
@@ -692,6 +692,20 @@ class CastInst : public UnaryInstruction {
   }
 };
 
+/// Instruction that can have a nneg flag (only zext).
+class NonNegInstruction : public CastInst {
----------------
nikic wrote:

Maybe it would be best to just drop it entirely? Given that we have just the one instruction supporting the flag, it might be better to stick with `isa<ZExtInst>` over `isa<NonNegInstruction>`. There is some risk that this may require future refactoring if we add the flag on additional instructions -- but that might be better than doing an unnecessary over-generalization now.

(We might want to add nneg on GEPs, but in that case the semantics of the flag would be sufficiently different that they could not share any common handling anyway.)

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


More information about the llvm-commits mailing list