[llvm] [PowerPC] improve performance on the isNan and !isNan function in case of -ffp-model=strict" (PR #215587)
zhijian lin via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 06:46:51 PDT 2026
diggerlin wrote:
> 1. There seems a slightly difference in terms of instruction count between the two PRs in `P8 + VSX`.
> 2. There is also a difference that "reland" used `xscmpudp` and this PR uses `fcmpu`.
>
> Just an observation from Bob's analysis. Not sure if it is significant or not though.
>
> ## Instruction count comparison: `isNan` / `!isNan` under `-ffp-model=strict`
> ### `isNan` (i32 3)
> Function Target Commit `7e1aba74` (reland) PR #215587 (fix) Delta
> `isNan` f64/f32 P8 + VSX 3 (`xscmpudp` + `li` + `iseleq`) 4 (`fcmpu` + 2×`li` + `isel`) +1
> `isNan` f64/f32 P9 4 (`xststdcdp` + 2×`li` + `iseleq`) 4 (`xststdcdp` + 2×`li` + `iseleq`) —
> `isNan` f64/f32 P8 no-VSX 3 (`fcmpu` + `li` + `iseleq`) 3 (`fcmpu` + `li` + `iseleq`) —
> ### `!isNan` (i32 1020)
> Function Target Commit `7e1aba74` (reland) PR #215587 (fix) Delta
> `!isNan` f64/f32 P8 + VSX 3 (`xscmpudp` + `li` + `isel`) 3 (`fcmpu` + `li` + `isel`) —
> `!isNan` f64/f32 P9 3 (`xststdcdp` + `li` + `iseleq`) 3 (`xststdcdp` + `li` + `iseleq`) —
> `!isNan` f64/f32 P8 no-VSX 3 (`fcmpu` + `li` + `isel`) 3 (`fcmpu` + `li` + `isel`) —
1. we do not re_land the commit 7e1aba74, the implement has some problem(it cause the 32bit crash. The fix in the current commit is simple and clear. the title of the patch is "[improve performance on the isNan and !isNan function in case of -ffp-model=strict"](https://github.com/llvm/llvm-project/pull/215587#top)" not to compare with reland.
2. your compare
> Function Target Commit `7e1aba74` (reland) PR #215587 (fix) Delta
> `isNan` f64/f32 P8 + VSX 3 (`xscmpudp` + `li` + `iseleq`) 4 (`fcmpu` + 2×`li` + `isel`) +1
in current llvm implement , the SDValue generated by
```
the ISD::CondCode CC = (Test == fcNan) ? ISD::SETUO : ISD::SETO;
return DAG.getSelectCC(Dl, Op, Op, DAG.getConstant(1, Dl, ResultVT),
DAG.getConstant(0, Dl, ResultVT), CC);
```
do not convert to (`xscmpudp` + `li` + `iseleq`) , instead it convert 4 (`fcmpu` + 2×`li` + `isel`) for P8+VSX , it is common problem for the SDValue , we can have further patch to achieve it.
https://github.com/llvm/llvm-project/pull/215587
More information about the llvm-commits
mailing list