[PATCH] D117912: [IR] document and update ctlz/cttz intrinsics to optionally return poison rather than undef

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 21 11:20:05 PST 2022


spatel created this revision.
spatel added reviewers: lebedev.ri, nikic, nlopes, RKSimon, pengfei, efriedma, aqjune.
Herald added subscribers: jdoerfert, hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The behavior in Analysis (knownbits) implements poison semantics already, and we expect the transforms (for example, in instcombine) derived from those semantics, so this patch changes the LangRef and remaining code to be consistent. This is one more step in removing "undef" from LLVM.

Without this, I think https://github.com/llvm/llvm-project/issues/53330 has a legitimate complaint because that report wants to allow subsequent code to mask off bits, and that is allowed with undef values. The clang builtins are not actually documented anywhere AFAICT, but we might want to add that to remove more uncertainty.

Hopefully, we are approaching a point where we can stop caring about the legacy behavior (~10 years since better x86 instructions were introduced)...but I'm usually too optimistic about those timeframes. :)


https://reviews.llvm.org/D117912

Files:
  llvm/docs/LangRef.rst
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/intrinsic-select.ll
  llvm/test/Transforms/InstCombine/intrinsics.ll
  llvm/test/Transforms/InstSimplify/ConstProp/bitcount.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117912.402041.patch
Type: text/x-patch
Size: 16839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220121/5faa0852/attachment.bin>


More information about the llvm-commits mailing list