Author: Craig Topper Date: 2023-04-04T09:01:24-07:00 New Revision: 0109f8d1e3bf64e4b23db6e2f284185207e46541
URL: https://github.com/llvm/llvm-project/commit/0109f8d1e3bf64e4b23db6e2f284185207e46541 DIFF: https://github.com/llvm/llvm-project/commit/0109f8d1e3bf64e4b23db6e2f284185207e46541.diff LOG: [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of __builtin_neon_vfmsh_f16. Addresses the FIXME and removes the only in tree use of llvm::ConstantFP::getZeroValueForNegation for an FP type. Reviewed By: dmgreen, SjoerdMeijer Differential Revision: https://reviews.llvm.org/D147497 Added: Modified: clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index f399b0770143..1d79d9a14635 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -10965,14 +10965,12 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy, {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), Ops[0]}); case NEON::BI__builtin_neon_vfmsh_f16: { - // FIXME: This should be an fneg instruction: - Value *Zero = llvm::ConstantFP::getZeroValueForNegation(HalfTy); - Value* Sub = Builder.CreateFSub(Zero, EmitScalarExpr(E->getArg(1)), "vsubh"); + Value* Neg = Builder.CreateFNeg(EmitScalarExpr(E->getArg(1)), "vsubh"); // NEON intrinsic puts accumulator first, unlike the LLVM fma. return emitCallMaybeConstrainedFPBuiltin( *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy, - {Sub, EmitScalarExpr(E->getArg(2)), Ops[0]}); + {Neg, EmitScalarExpr(E->getArg(2)), Ops[0]}); } case NEON::BI__builtin_neon_vaddd_s64: case NEON::BI__builtin_neon_vaddd_u64: diff --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c index 198c4523d651..536713402b5d 100644 --- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c +++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c @@ -290,8 +290,7 @@ float16_t test_vfmah_f16(float16_t a, float16_t b, float16_t c) { } // COMMON-LABEL: test_vfmsh_f16 -// UNCONSTRAINED: [[SUB:%.*]] = fsub half 0xH8000, %b -// CONSTRAINED: [[SUB:%.*]] = call half @llvm.experimental.constrained.fsub.f16(half 0xH8000, half %b, metadata !"round.tonearest", metadata !"fpexcept.strict") +// COMMONIR: [[SUB:%.*]] = fneg half %b // UNCONSTRAINED: [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half %a) // CONSTRAINED: [[ADD:%.*]] = call half @llvm.experimental.constrained.fma.f16(half [[SUB]], half %c, half %a, metadata !"round.tonearest", metadata !"fpexcept.strict") // COMMONIR: ret half [[ADD]] diff --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c index b374ba1ab097..d745a7789326 100644 --- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c +++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c @@ -652,7 +652,7 @@ float16_t test_vfmah_f16(float16_t a, float16_t b, float16_t c) { } // CHECK-LABEL: test_vfmsh_f16 -// CHECK: [[SUB:%.*]] = fsub half 0xH8000, %b +// CHECK: [[SUB:%.*]] = fneg half %b // CHECK: [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half %a) // CHECK: ret half [[ADD]] float16_t test_vfmsh_f16(float16_t a, float16_t b, float16_t c) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits