[llvm] [llvm][RISCV] Optimize fabs for fixed vectors (PR #194554)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 12:00:24 PDT 2026


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

Shouldn't call TLI.isExtractVecEltCheap(VT, 1) is there is only 1 element.

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


More information about the llvm-commits mailing list