[PATCH] D117508: [SDAG] add demanded bits transform for bswap

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 17 12:01:31 PST 2022


spatel created this revision.
spatel added reviewers: bjope, dmgreen, nemanjai, craig.topper, RKSimon.
Herald added subscribers: steven.zhang, pengfei, hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

A possible codegen regression for PowerPC is noted in D117406 <https://reviews.llvm.org/D117406> because we don't recognize a pattern that demands a single byte from a bswap.

I was wondering if we have that fold in IR, and it has existed there since close to the beginning of LLVM:
https://github.com/llvm/llvm-project/blame/main/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L794
...so this patch copies that code as much as possible and adapts it for SDAG.

The test for PowerPC is over-reduced with undefs, so I made it valid again by passing in pointer args and renamed the values to make the logic clearer.


https://reviews.llvm.org/D117508

Files:
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/CodeGen/AArch64/bswap-known-bits.ll
  llvm/test/CodeGen/X86/combine-bswap.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117508.400611.patch
Type: text/x-patch
Size: 4140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220117/db2963b9/attachment.bin>


More information about the llvm-commits mailing list