[PATCH] D125449: [ConstantFold] Fold bitcasts on scalable vector splats.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 07:19:57 PDT 2022


sdesmalen added a comment.

In D125449#3508487 <https://reviews.llvm.org/D125449#3508487>, @frasercrmck wrote:

> From what I gather about the bug report, RISCV doesn't suffer from it as we always `dyn_cast` to `Instruction`. Is that right? Just wondering if we should add a similar test - I don't think we have constant expr coverage in `sink-splat-operands.ll`.

That's what I did initially, but I couldn't write a test with a ZExt/SExt as ConstExpr that wouldn't fold, so that would mean I'd rewrite the code without being able to test it.



================
Comment at: llvm/lib/IR/ConstantFold.cpp:406
+        if (Constant *Splat = V->getSplatValue()) {
+          VectorType *DestVecTy = cast<VectorType>(DestTy);
+          Type *DstEltTy = DestVecTy->getElementType();
----------------
frasercrmck wrote:
> `DestVecTy` == `DestVTy`, no?
You're right, I moved this code around a few times and didn't spot this.


================
Comment at: llvm/test/Transforms/InstCombine/addrspacecast.ll:206
 ; CHECK-LABEL: @constant_fold_null_vector(
-; CHECK-NEXT:    ret <4 x i32 addrspace(4)*> addrspacecast (<4 x i32 addrspace(3)*> zeroinitializer to <4 x i32 addrspace(4)*>)
+; CHECK-NEXT:    ret <4 x i32 addrspace(4)*> <i32 addrspace(4)* addrspacecast (i32 addrspace(3)* null to i32 addrspace(4)*), i32 addrspace(4)* addrspacecast (i32 addrspace(3)* null to i32 addrspace(4)*), i32 addrspace(4)* addrspacecast (i32 addrspace(3)* null to i32 addrspace(4)*), i32 addrspace(4)* addrspacecast (i32 addrspace(3)* null to i32 addrspace(4)*)>
 ;
----------------
frasercrmck wrote:
> This one strikes me as peculiar. Is it all less canonical than it was before?
You're right, that's probably not desired, because addrspacecast's don't fold any further. I've reverted that change now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125449



More information about the llvm-commits mailing list