When evaluating floating point instructions in the inliner, ask the TTI whether it is an expensive operation. By default, it's not an expensive operation. This keeps the default behavior the same as before. The ARM TTI has been updated to return back TCC_Expensive for targets which don't have hardware floating point.
Details
Diff Detail
Event Timeline
Ping
Cameron Esfahani
dirty@apple.com
"Americans are very skilled at creating a custom meaning from something that's mass-produced."
Ann Powers
Hi Cameron,
We could probably do with some tests for this, and I think the ARM logic needs a bit of work.
lib/Target/ARM/ARMSubtarget.h | ||
---|---|---|
316–318 | I don't think this is quite right. The relevant code in ARMISelLowering is: if (!TM.Options.UseSoftFloat && Subtarget->hasVFP2() && !Subtarget->isThumb1Only()) (notably: any CPU with float has VFP2; SoftFloat can be specified even if the hardware supports it; and Thumb1 didn't have access to VFP). | |
lib/Target/ARM/ARMTargetTransformInfo.cpp | ||
455 | I don't think this is quite right. The relevant code in ARMISelLowering is: if (!TM.Options.UseSoftFloat && Subtarget->hasVFP2() && !Subtarget->isThumb1Only()) (notably: any CPU with float has VFP2; SoftFloat can be specified even if the hardware supports it; and Thumb1 didn't have access to VFP). |
I have a unit test for this patch, but it's in the clang side, so I will submit it after this patch gets approved.
I've changed the code to adopt your suggestions. I'll send out an updated patch soon.
Cameron Esfahani
dirty@apple.com
"I cannot for the life of me understand why, while people without driver's licenses are not allowed on public roads, in bookstores one can find any number of books by persons without decency - let alone knowledge."
"His Master's Voice", Stanislaw Lem
It's in the CodeGen directory. Here's the current testcase:
[dirty@girlyouknowitstrue work]$ cat llvm/tools/clang/test/CodeGen/inline-fp.c
RUN: %clang -Oz -target armv7-apple-macosx10.8.0 -mcpu=cortex-a8 -march=armv7 -S -emit-llvm %s -o - | FileCheck %s
RUN: %clang -Oz -target armv7-apple-macosx10.8.0 -mcpu=cortex-m3 -march=armv7 -S -emit-llvm %s -o - | FileCheck -check-prefix NO-FP %s
extern float powf(float x, float y);
extern float fabsf(float x);
static float f1(int response, unsigned char value1) {
float value2 = 2620.0f * powf(1.01f, value1 - 1); float responseDelta = (response - value2) / value2; return (responseDelta);
}
extern void getX(int *responseX, unsigned char *valueX);
extern void getY(int *responseY, unsigned char *valueY);
extern void getZ(int *responseZ, unsigned char *valueZ);
CHECK-NOT: define internal arm_aapcscc float @f1(
NO-FP: define internal arm_aapcscc float @f1(
int test_all(void) {
int responseX; int responseY; int responseZ; unsigned char valueX; unsigned char valueY; unsigned char valueZ; getX(&responseX, &valueX); getY(&responseY, &valueY); getZ(&responseZ, &valueZ); float responseDeltaX = f1(responseX, valueX); float responseDeltaY = f1(responseY, valueY); float responseDeltaZ = f1(responseZ, valueZ); int success = 1; if (fabsf(responseDeltaX) > 0.14f) success = 0; else if (fabsf(responseDeltaY) > 0.14f) success = 0; else if (fabsf(responseDeltaZ) > 0.14f) success = 0; return (success);
}
Cameron Esfahani
dirty@apple.com
"Americans are very skilled at creating a custom meaning from something that's mass-produced."
Ann Powers
Integrate patch suggestions from Tim Northover: use the same logic in ARMTTI as in ARMISelLowering.
Yeah, not so much. Testcases like that need to be in the backend. No
optimization testcases in the front end if we can help it. (i.e. testing
options)
Thanks!
-eric
Update patch to account for routines which have the "use-soft-float" attribute. Add test case where we make sure that routines marked with "use-soft-float" are not inlined, but routines without that attribute are.
Update patch to work with Chandler's changes to TTI. Removed reference to Options.UseSoftFloat, as it's eventually going away and function attribute "use-soft-float" is more appropriate.
Can probably expand the testcase a bit more with CHECK/CHECK-NOT for the various calls? One inline comment.
Otherwise LGTM.
-eric
lib/Analysis/IPA/InlineCost.cpp | ||
---|---|---|
911 | s/will/may. |
s/will/may.