[llvm] [InstCombine] Swap out range metadata to range attribute for cttz/ctlz/ctpop (PR #88776)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 00:53:55 PDT 2024


================
@@ -450,6 +452,10 @@ void Instruction::dropPoisonGeneratingFlags() {
     cast<TruncInst>(this)->setHasNoUnsignedWrap(false);
     cast<TruncInst>(this)->setHasNoSignedWrap(false);
     break;
+
+  case Instruction::Call:
+  case Instruction::Invoke:
+    cast<CallBase>(this)->removeRetAttr(Attribute::Range);
----------------
nikic wrote:

This is all a bit tricky, but the tl;dr is that we only care about call-site attributes in this context. Any attributes we'd have on an intrinsic function declaration would hold unconditionally and would not actually make the result more poisonous. E.g. if you have a ctlz.i32 we could add range(0, 32) to the declaration, but that will never make the result more poisonous. Non-intrinsics are currently not relevant in this context, because the surrounding analysis wouldn't support them anyway.

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


More information about the llvm-commits mailing list