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

Sanjay Patel spatel at rotateright.com
Tue Jul 29 08:46:49 PDT 2014


Hi Pete and Renato -

Thank you very much for the feedback. I won't be back at an LLVM dev machine until next week, so I can't generate the new code for the ARM test at the moment.

The cause of the bug for fabs in PR20354 is that we are incorrectly guarding against vector operands, so we produce a bit mask where only the *first* high bit of a vector was masked off: 0x7fffffffffffffff. We need to mask off each vector element's high bit: 0x7fffffff7fffffff. I'll try to make this clearer by adding some comments.

I think we can just fix the bug in FABS by changing the 'if' check in visitFABS to match what already exists in visitFNEG. Ie, this part of the check:
!N0.getOperand(0).getValueType().isVector()

would become:
 !VT.isVector()

Of course, this will not generate the optimal code for vectors, but it should avoid the miscompilation.

http://reviews.llvm.org/D4633






More information about the llvm-commits mailing list