[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)
    Nikita Popov via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Mar 18 04:06:43 PDT 2024
    
    
  
================
@@ -386,11 +394,17 @@ void Instruction::setNonNeg(bool b) {
 }
 
 bool Instruction::hasNoUnsignedWrap() const {
-  return cast<OverflowingBinaryOperator>(this)->hasNoUnsignedWrap();
+  if (auto Inst = cast<OverflowingBinaryOperator>(this))
+    return Inst->hasNoUnsignedWrap();
+
+  return cast<PossiblyNoWrapInst>(this)->hasNoUnsignedWrap();
 }
 
 bool Instruction::hasNoSignedWrap() const {
-  return cast<OverflowingBinaryOperator>(this)->hasNoSignedWrap();
+  if (auto Inst = cast<OverflowingBinaryOperator>(this))
+    return Inst->hasNoSignedWrap();
+
+  return cast<PossiblyNoWrapInst>(this)->hasNoSignedWrap();
----------------
nikic wrote:
I don't think it makes sense to share them. Outside of the flag setting/getting logic here, their use will be pretty much completely disjoint.
https://github.com/llvm/llvm-project/pull/85592
    
    
More information about the llvm-commits
mailing list