aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2024-05-03 19:14:38 +0100
committerGitHub <noreply@github.com>2024-05-03 19:14:38 +0100
commita4d10266d20bfe5930dfed77e17832af341ed66e (patch)
tree003ca457de38a447c47387263cc6255136a246e4 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
parent46c2d936624322e141c6eff319e1ad2d25f1afd7 (diff)
downloadllvm-a4d10266d20bfe5930dfed77e17832af341ed66e.zip
llvm-a4d10266d20bfe5930dfed77e17832af341ed66e.tar.gz
llvm-a4d10266d20bfe5930dfed77e17832af341ed66e.tar.bz2
[VectorCombine] Add foldShuffleToIdentity (#88693)
This patch adds a basic version of a combine that attempts to remove shuffles that when combined simplify away to an identity shuffle. For example: %ab = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> %at = shufflevector <8 x half> %a, <8 x half> poison, <4 x i32> <i32 7, i32 6, i32 5, i32 4> %abt = fneg <4 x half> %at %abb = fneg <4 x half> %ab %r = shufflevector <4 x half> %abt, <4 x half> %abb, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0> By looking through the shuffles and fneg, it can be simplified to: %r = fneg <8 x half> %a The code tracks each lane starting from the original shuffle, keeping a track of a vector of {src, idx}. As we propagate up through the instructions we will either look through intermediate instructions (binops and unops) or see a collections of lanes that all have the same src and incrementing idx (an identity). We can also see a single value with identical lanes, which we can treat like a splat. Only the basic version is added here, handling identities, splats, binops and unops. In follow-up patches other instructions can be added such as constants, intrinsics, cmp/sel and zext/sext/trunc.
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
0 files changed, 0 insertions, 0 deletions