[GlobalISel] Fold or of shifts to funnel shift.
authorAbinav Puthan Purayil <abinav.puthanpurayil@amd.com>
Tue, 23 Nov 2021 17:13:18 +0000 (22:43 +0530)
committerAbinav Puthan Purayil <abinav.puthanpurayil@amd.com>
Fri, 26 Nov 2021 11:35:29 +0000 (17:05 +0530)
commit4af45f10cccbaabc87758c4dc50b94bfd31fe848
treedcb0218a8d691abfbe6918888c55b1f40fe31c7b
parente20391fc5d6a72e712449142e803fb81b8a75153
[GlobalISel] Fold or of shifts to funnel shift.

This change folds a basic funnel shift idiom:
- (or (shl x, amt), (lshr y, sub(bw, amt))) -> fshl(x, y, amt)
- (or (shl x, sub(bw, amt)), (lshr y, amt)) -> fshr(x, y, amt)

This also helps in folding to rotate shift if x and y are equal since we
already have a funnel shift to rotate combine.

Differential Revision: https://reviews.llvm.org/D114499
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
llvm/include/llvm/Target/GlobalISel/Combine.td
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fsh.mir [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-rot.mir [new file with mode: 0644]