[PATCH] D122655: [SDAG] try to canonicalize logical shift after bswap

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 29 07:00:37 PDT 2022


spatel created this revision.
spatel added reviewers: Chenbing.Zheng, RKSimon, craig.topper.
Herald added subscribers: luke957, StephenFan, frasercrmck, ecnelises, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, kristof.beyls, arichardson, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, MaskRay.
Herald added a project: LLVM.

When shifting by a byte-multiple:
bswap (shl X, C) --> lshr (bswap X), C
bswap (lshr X, C) --> shl (bswap X), C

This is the backend version of D122010 <https://reviews.llvm.org/D122010> and an alternative suggested in D120648 <https://reviews.llvm.org/D120648>. There's an extra check to make sure the shift amount is valid that was not in the rough draft.

I'm not sure if there is a larger motivating case for RISCV (bug report?), but the ARM diffs show a benefit from having a late version of the transform (because we do not combine the loads in IR).


https://reviews.llvm.org/D122655

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/arm64-rev.ll
  llvm/test/CodeGen/AArch64/load-combine-big-endian.ll
  llvm/test/CodeGen/AArch64/load-combine.ll
  llvm/test/CodeGen/ARM/load-combine-big-endian.ll
  llvm/test/CodeGen/ARM/load-combine.ll
  llvm/test/CodeGen/RISCV/bswap-shift.ll
  llvm/test/CodeGen/X86/combine-bswap.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122655.418864.patch
Type: text/x-patch
Size: 15474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220329/4cf64288/attachment.bin>


More information about the llvm-commits mailing list