x87: should evaluate function calls like fabs and pow for constant arguments
- Dominant language
- C++
- Stars
- 8.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Subject: https://github.com/rfalke/decompiler-subjects/blob/master/from_holdec/i386_x87_fpu/ia32_elf/subject.exe
Output:
```
int32_t FABS(int32_t a1) {
float64_t v1 = fabs((float64_t)(int64_t)a1);
printf("FABS(para): should= is=%12f/%15e\n", v1, v1);
float64_t v2 = fabsl(-1.0L); // 0x8049f56
printf("FABS(-1): should= 1.000000/ 1.000000e+00 is=%12f/%15e\n", v2, v2);
printf("FABS(-0): should= 0.000000/ 0.000000e+00 is=%12f/%15e\n", 0.0, 0.0);
printf("FABS(+1): should= 1.000000/ 1.000000e+00 is=%12f/%15e\n", 1.0, 1.0);
return 0;
}
```
For -0 and +1 there is no fabs call but not so for -1.0. "fabsl(-1.0L)" should be replaced with "1.0".
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the decompiler output from subject.exe and inspect the generated FABS function, especially the fabsl(-1.0L) expression. Trace the constant-evaluation path for floating-point function calls such as fabs and pow; done means the constant argument is evaluated and the output contains 1.0 rather than fabsl(-1.0L).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, reverse-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100