
Previously only fixed vector splats were handled. This adds supports for scalable vectors too by allowing ConstantExpr splats. We need to add the extra V->getType()->isVectorTy() check because a ConstantExpr might be a scalar to vector bitcast. By allowing ConstantExprs this also allow fixed vector ConstantExprs to be folded, which causes the diffs in llvm/test/Analysis/ValueTracking/known-bits-from-operator-constexpr.ll and llvm/test/Transforms/InstSimplify/ConstProp/cast-vector.ll. I can remove them from this PR if reviewers would prefer. Fixes #132922
16 lines
777 B
LLVM
16 lines
777 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
|
|
|
|
; Reproducer for a crash in computeKnownBitsFromOperator due to blindly
|
|
; casting from llvm::Operator to ExtractElementInst. That does not work
|
|
; if the Operator is a ConstantExpr.
|
|
@g = global [21 x i32] zeroinitializer
|
|
define i32 @test1(i32 %a) {
|
|
; CHECK-LABEL: @test1(
|
|
; CHECK-NEXT: [[T:%.*]] = sub i32 [[A:%.*]], ptrtoint (ptr getelementptr inbounds ([21 x i32], ptr @g, i32 0, i32 17) to i32)
|
|
; CHECK-NEXT: ret i32 [[T]]
|
|
;
|
|
%t = sub i32 %a, extractelement (<4 x i32> ptrtoint (<4 x ptr> getelementptr inbounds ([21 x i32], ptr @g, <4 x i32> zeroinitializer, <4 x i32> <i32 1, i32 2, i32 3, i32 17>) to <4 x i32>), i32 3)
|
|
ret i32 %t
|
|
}
|