[VectorCombine] fix crashing on match of non-canonical fneg
authorSanjay Patel <spatel@rotateright.com>
Mon, 17 Oct 2022 14:12:24 +0000 (10:12 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 17 Oct 2022 14:47:48 +0000 (10:47 -0400)
commit8d76fbb5f0659bba47a7f38847550a2bc8bbf0c1
tree16cebd3effe18dff405e96866c66f8e7e062814a
parente9b8d704d385472c68a50aa58413e880dd5d9aae
[VectorCombine] fix crashing on match of non-canonical fneg

We can't assume that operand 0 is the negated operand because
the matcher handles "fsub -0.0, X" (and also +0.0 with FMF).

By capturing the extract within the match, we avoid the bug
and make the transform more robust (can't assume that this
pass will only see canonical IR).
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/VectorCombine/X86/extract-fneg-insert.ll