[PATCH] D148803: [ConstantFolding] Fix crash when folding vector llvm.is.fpclass
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 01:26:41 PDT 2023
foad added a comment.
In D148803#4286333 <https://reviews.llvm.org/D148803#4286333>, @mstorsjo wrote:
> I've bisected a failed assert to this commit. Repro:
>
> $ cat repro.c
> int a;
> float *b;
> float c;
> void d() {
> float *e = d;
> for (int f = 0; f < a; f++) {
> c = b[f];
> e[f] = 10.f * c;
> if (__builtin_isnormal(e[f]))
> e[f] = 351.f;
> }
> }
> $ clang -target aarch64-linux-gnu -c repro.c -O2
> clang: ../lib/IR/Instructions.cpp:652: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
Thanks! Here's an IR repro:
; RUN: opt < %s -passes=loop-vectorize -S | FileCheck %s
target triple = "aarch64-unknown-linux-gnu"
define void @d() {
bb:
br label %bb2
bb1:
ret void
bb2:
%i = phi i64 [ 0, %bb ], [ %i7, %bb2 ]
%i3 = load float, ptr null, align 4
%i4 = getelementptr float, ptr @d, i64 %i
%i5 = tail call i1 @llvm.is.fpclass.f32(float 0.0, i32 0)
%i6 = select i1 %i5, float 0.0, float 0.0
store float %i6, ptr %i4, align 4
%i7 = add i64 %i, 1
%i8 = icmp eq i64 %i7, 0
br i1 %i8, label %bb1, label %bb2
}
declare i1 @llvm.is.fpclass.f32(float, i32 immarg)
The problem is that `VPWidenCallRecipe::execute` assumes that vector intrinsics are overloaded on their result type. `llvm.is.fpclass` is overloaded on the type of its first argument instead. I'm not sure what the best fix is.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148803/new/
https://reviews.llvm.org/D148803
More information about the llvm-commits
mailing list