[DAG] Attempt to fold bswap(shl(x,c)) -> zext(bswap(trunc(shl(x,c-bw/2))))
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 24 Feb 2022 19:18:37 +0000 (19:18 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 24 Feb 2022 19:33:51 +0000 (19:33 +0000)
commit370ebc9d9a573d6a0bcb0d7c3e0a57d55b7a7673
tree46ed66636cf2eb00d2a0e4dea2570a3f48d69b19
parentb3e9fdd17051a8d9f6357deadf39f11488cd02a9
[DAG] Attempt to fold bswap(shl(x,c)) -> zext(bswap(trunc(shl(x,c-bw/2))))

If the shl is at least half the bitwidth (i.e. the lower half of the bswap source is zero), then we can reduce the shift and perform the bswap at half the bitwidth and just zero extend.

Based off PR51391 + PR53867

Differential Revision: https://reviews.llvm.org/D120192
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/load-combine-big-endian.ll
llvm/test/CodeGen/AArch64/load-combine.ll
llvm/test/CodeGen/X86/combine-bswap.ll
llvm/test/CodeGen/X86/load-combine.ll