[PATCH] x86 NaCl: Emit LAHF/SAHF instead of PUSHF/POPF

JF Bastien jfb at chromium.org
Fri Dec 19 12:10:47 PST 2014


I did a bit of benchmarking <https://github.com/jfbastien/benchmark-x86-flags>, the results on an Intel Haswell E5-2690 CPU at 2.9GHz are:

| Time per call (ms) | Runtime (ms) | Benchmark              |
| 0.000012514                | 6257         | sete.i386              |
| 0.000012810                | 6405         | sete.i386-fast         |
| 0.000010456                | 5228         | sete.x86-64            |
| 0.000010496                | 5248         | sete.x86-64-fast       |
| 0.000012906                | 6453         | lahf-sahf.i386         |
| 0.000013236                | 6618         | lahf-sahf.i386-fast    |
| 0.000010580                | 5290         | lahf-sahf.x86-64       |
| 0.000010304                | 5152         | lahf-sahf.x86-64-fast  |
| 0.000028056                | 14028        | pushf-popf.i386        |
| 0.000027160                | 13580        | pushf-popf.i386-fast   |
| 0.000023810                | 11905        | pushf-popf.x86-64      |
| 0.000026468                | 13234        | pushf-popf.x86-64-fast |

Clearly `PUSHF`/`POPF` are suboptimal, I'll therefore delete that code and only keep the NaCl code (and make it non-NaCl specific). I'll update the tests to show the differences in register allocation. It doesn't really seems to be worth teaching LLVM about individual flags, at least not for this purpose.

There also seems to be a bug in x86-64 when generating code for `test_feed_cmov`.


http://reviews.llvm.org/D6629

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list