[PATCH] D151099: [InstCombine] Remove computeKnownBits() fold for returns

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 22 07:14:11 PDT 2023


nikic created this revision.
nikic added reviewers: RKSimon, goldstein.w.n.
Herald added subscribers: foad, StephenFan, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We try to fold constant computeKnownBits() with context for return instructions only. Otherwise, we rely on SimplifyDemandedBits() to fold instructions with constant known bits.

The presence of this special fold for returns is dangerous, because it makes our tests lie about what works and what doesn't. Tests are usually written by returning the result we're interested in, but will go through this separate code path that is not used for anything else. This patch removes the special fold.

This primarily regresses patterns of the style "assume(x); return x". The responsibility of handling such patterns lies with passes like EarlyCSE/GVN anyway, which will do this reliably, and not just for returns.


https://reviews.llvm.org/D151099

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/InstCombine/known-phi-br.ll
  llvm/test/Transforms/InstCombine/zext-or-icmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151099.524292.patch
Type: text/x-patch
Size: 5422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230522/be019838/attachment.bin>


More information about the llvm-commits mailing list