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

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 02:28:43 PDT 2022


frasercrmck added a comment.

>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`.



================
Comment at: llvm/lib/IR/ConstantFold.cpp:406
+        if (Constant *Splat = V->getSplatValue()) {
+          VectorType *DestVecTy = cast<VectorType>(DestTy);
+          Type *DstEltTy = DestVecTy->getElementType();
----------------
`DestVecTy` == `DestVTy`, no?


================
Comment at: llvm/lib/IR/ConstantFold.cpp:409
+          return ConstantVector::getSplat(
+              cast<VectorType>(DestTy)->getElementCount(),
+              ConstantExpr::getCast(opc, Splat, DstEltTy));
----------------
`cast<VectorType>(DestTy)` == `DestVTy`.


================
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)*)>
 ;
----------------
This one strikes me as peculiar. Is it all less canonical than it was before?


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