This is an archive of the discontinued LLVM Phabricator instance.

Fix incorrect selection of AVX512 sqrt when OptForSize is on
ClosedPublic

Authored by dim on Feb 18 2016, 2:11 PM.

Details

Summary

When optimizing for size, sqrt calls can be incorrectly selected as
AVX512 VSQRT instructions. This is because X86InstrAVX512.td has a
Requires<[OptForSize]> in its avx512_sqrt_scalar multiclass
definition. Even if the target does not support AVX512, the class can
apparently still be chosen, leading to an incorrect selection of
vsqrtss.

In PR26625, this lead to an assertion: Reg >= X86::FP0 && Reg <=
X86::FP6 && "Expected FP register!", because the vsqrtss instruction
requires an XMM register, which is not available on i686 CPUs.

Diff Detail

Event Timeline

dim updated this revision to Diff 48401.Feb 18 2016, 2:11 PM
dim retitled this revision from to Fix incorrect selection of AVX512 sqrt when OptForSize is on.
dim updated this object.
dim added reviewers: mehdi_amini, grosbach, resistor.
dim added a subscriber: llvm-commits.
emaste added a subscriber: emaste.Feb 19 2016, 9:45 AM
spatel added a subscriber: spatel.Feb 19 2016, 10:39 AM

I asked about this problem:
http://lists.llvm.org/pipermail/llvm-dev/2014-September/076904.html

...but didn't do anything about it. :(
PredicateControl still exists in MIPS.td if someone wants to extend that...or solve the problem in TableGen directly.

mehdi_amini accepted this revision.Feb 19 2016, 11:25 AM
mehdi_amini edited edge metadata.

LGTM

This revision is now accepted and ready to land.Feb 19 2016, 11:25 AM
dim closed this revision.Feb 19 2016, 12:18 PM