Questions about specifying VFP4 in clang for ARM

Hi,

I’m able to use vfp4 via llc: “-mattr=+neon,+vfp4 –fp-contract=fast” to generate fused multiply-add (vfma)

However, with clang driver, I tried –mfpu=vfp4, but it returns:

clang: error: the clang compiler does not support ‘-mfpu=vfp4’

Then, I added the following code in lib/Driver/Tools.cpp, addFPUArgs():

else if (FPU == “vfp4” || FPU == “vfpv4”) {

CmdArgs.push_back(“-target-feature”);

CmdArgs.push_back(“+vfp4”);

CmdArgs.push_back(“-target-feature”);

CmdArgs.push_back(“+neon”);

I also updated lib/Basic/Targets.cpp::setFeatureEanbled()

if (Name == “soft-float” || Name == “soft-float-abi” ||

Name == “vfp2” || Name == “vfp3” || Name == “neon” || Name == “d16” ||

Name == “neonfp” || Name == “vfp4”) {

Features[Name] = Enabled;

But still no luck. It doesn’t even fold the mul/add to vmla instructions.

The cc1 flags are:

-cc1 -triple armv7-none-linux-gnueabi -S -disable-free -main-file-name fdiv.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -ffp-contract=fast -mconstructor-aliases -target-abi aapcs-linux -target-cpu cortex-a9 -mfloat-abi soft -target-feature +soft-float-abi -target-feature +vfp4 -target-feature +neon -target-linker-version 2.20.1 -momit-leaf-frame-pointer -v -coverage-file /home/weimingz/llvm_tests/fdiv.s -resource-dir /local/scratch/llvm-build/llvm-tip/Debug+Asserts/bin/…/lib/clang/3.2 -isysroot /home/common/build_tools/gcc-4.6.1-cs/arm-2011.09 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /home/common/build_tools/gcc-4.6.1-cs/arm-2011.09/usr/local/include -internal-isystem /local/scratch/llvm-build/llvm-tip/Debug+Asserts/bin/…/lib/clang/3.2/include -internal-externc-isystem /home/common/build_tools/gcc-4.6.1-cs/arm-2011.09/include -internal-externc-isystem /home/common/build_tools/gcc-4.6.1-cs/arm-2011.09/usr/include -O3 -fno-dwarf-directory-asm -fdebug-compilation-dir /home/weimingz/llvm_tests/fdiv -ferror-limit 19 -fmessage-length 147 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o test.s -x c test.c

And I also notice that, in lib/Driver/Tools.cpp, addFPUArgs():

else if (FPU == “vfp3” || FPU == “vfpv3”) {

CmdArgs.push_back(“-target-feature”);

CmdArgs.push_back(“+vfp3”);

CmdArgs.push_back(“-target-feature”);

CmdArgs.push_back(“-neon”); è why do we disable neon here?

}

Thanks,

Weiming

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

I see a pretty obvious hole in your reasoning: you didn't specify
anything to make clang default to –fp-contract=fast. Am I missing
something?

-Eli

Hi Eli,

I passed "-ffp-contract=fast" to clang.
The complete clang command is:
clang -O3 -mcpu=cortex-a9 -mfpu=vfp4 -S -c -o test.s test.c
-ffp-contract=fast
The cc1 flags (use -v) are in the previouse email.

Clang doesn't recognize "vfp4" for mfpu option.
Maybe there is other option to specify vfp4?

Weiming

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by
The Linux Foundation