In PR20354 ( http://llvm.org/bugs/show_bug.cgi?id=20354 ), we're miscompiling a vector fabs operation.
This patch corrects that case and allows optimization of vector fabs ops via sign bit twiddling rather than using FP instructions. It also changes the logic in visitFNEG to allow vector fneg ops to be optimized in a similar way.
The fabs and fneg cases are similar enough that we should probably refactor the code to reduce duplication, but I don't want to add that complication to this patch.
This patch breaks an existing ARM testcase in test/CodeGen/ARM/2009-10-21-InvalidFNeg.ll. That test was expecting use of VFPU/NEON, but now we don't even need to touch the FPU. I think that's universally better for any ARM target?
I've added testcases to the existing X86 tests for vec_fabs and vec_neg. Also added a FIXME to the existing tests in vec_fneg.ll because they don't have any checks.
I'm not sure what was the purpose of this test, but you can't just assume that it's ok. Can you share the resulting code?
Currently, it produces this:
Which I agree, doesn't look like a clear winner, but it might be a side effect of the original intention...