[InstSimplify] Fix a scalable-vector crash
authorFraser Cormack <fraser@codeplay.com>
Thu, 22 Jun 2023 15:49:39 +0000 (16:49 +0100)
committerFraser Cormack <fraser@codeplay.com>
Wed, 28 Jun 2023 16:07:10 +0000 (17:07 +0100)
commit55372309a4c757af17f7dc33e5b686cf8565997f
treecfab445bb45583501b98eee6ed0eae1ca4119863
parenteeba037e0bb6bf0686eca73f4b4cf5eaf573499b
[InstSimplify] Fix a scalable-vector crash

D143505 fixed/simplified folding of operations with SNaN operands. In
doing so it introduced a crash when handling scalable vector types,
wherein the scalable-vector ConstantVector was cast to a ConstantFP.

Since we know by that point in the code that if we've found a NaN, we're
dealing with a scalable-vector splat (as there are no other kinds of
scalable-vector constant for which that holds), we can grab the splatted
value and re-use the existing code, which will automatically splat the
new NaN back to a scalable vector for us.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D153566
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/fp-nan.ll