When matching FNEG patterns for the MachineCombiner we need to check for
opcodes first, before trying to extract a register from an operand.
Otherwise handling of instructions with non-register operands causes the
compiler to crash.
Details
Diff Detail
Event Timeline
Suggest using llvm/utils/update_llc_test_checks.py to write the CHECKs, so they're easier to update later.
Otherwise LGTM.
The change looks good to me but the test needs tightening up.
inline-asm-empty-template.ll Is too generic of a file name, and it's not actually a template. This should be specifically referencing fneg.
llvm/test/CodeGen/AArch64/inline-asm-empty-template.ll | ||
---|---|---|
6 ↗ | (On Diff #552180) | This test should be renamed to something that reflects what this is actually testing instead of just @a. @emit_fneg_with_non_register_operand or something along those lines. At a glance you can't really tell why this test exists out of context with the changes. |
17 ↗ | (On Diff #552180) | This line should be explicitly checked, or else the test is too flimsy. I can replace this line with %fneg = fadd double %1, %1 which doesn't test your change at all and this test still passes. ; CHECK: fneg d1, d0 |
It may be simpler for the test to be an mir test if it testing the MachineCombiner. It should be less susceptible to bitrot if any of the proceeding optimizations before it change.
Thanks, I've added a mir test that checks for fneg and gave it the name Matt suggested.