[PATCH] D138185: [InstCombine] Look through bitcast if possible

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 07:58:41 PST 2022


spatel added a subscriber: RKSimon.
spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:369
     if (Instruction *I = dyn_cast<Instruction>(U.getUser())) {
-      UnionUsedElts |= findDemandedEltsBySingleUser(V, I);
+      // Bitcast between vectors with the same element count does not change
+      // the demanded elements, so we are safe to look through them.
----------------
foad wrote:
> It might be neater to handle BitCast in findDemandedEltsBySingleUser instead. In either case, you're introducing recursion, so perhaps it should have a depth limit.
Improving findDemandedEltsBySingleUser() sounds like a good idea. 

@RKSimon might have more to say about that. There may be a codegen equivalent that we can use as a guideline.


================
Comment at: llvm/test/Transforms/InstCombine/AMDGPU/demanded-vector-elts-multi-user.ll:4
+
+declare <4 x i32> @llvm.amdgcn.raw.buffer.load.v4i32(<4 x i32>, i32, i32, i32) #1
+
----------------
I can't tell what changes are expected from this patch. The patch is target-independent, so the tests should also be target-independent and minimized as much as possible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138185/new/

https://reviews.llvm.org/D138185



More information about the llvm-commits mailing list