[llvm] [llvm][RISCV] Optimize fneg for fixed vectors (PR #194555)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 11:59:46 PDT 2026


================
@@ -2076,7 +2076,7 @@ SDValue VectorLegalizer::ExpandFNEG(SDNode *Node) {
          TLI.isOperationLegalOrCustomOrPromote(ISD::FNEG, EltVT)) ||
         (VT.getVectorNumElements() < 3 &&
          TLI.isOperationLegal(ISD::FNEG, EltVT) &&
-         TLI.isExtractVecEltCheap(VT, 0)))
+         TLI.isExtractVecEltCheap(VT, 0) && TLI.isExtractVecEltCheap(VT, 1)))
----------------
topperc wrote:

Probably shouldn't query TLI.isExtractVecEltCheap(VT, 1) if there is only 1 element.

https://github.com/llvm/llvm-project/pull/194555


More information about the llvm-commits mailing list