[PATCH] fix for PR20354 - Miscompile of fabs due to vectorization

Sanjay Patel spatel at rotateright.com
Tue Jul 22 15:07:34 PDT 2014

Hi rengolin, chandlerc, nadav,

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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4633.11787.patch
Type: text/x-patch
Size: 7067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140722/c9948bf6/attachment.bin>

More information about the llvm-commits mailing list