The previous patch https://reviews.llvm.org/D23313 does not cover AVX-512F, KNL set.
FNEG(x) operation is lowered to (bitcast (vpxor (bitcast x), (bitcast constfp(0x80000000))).
It happens because FP XOR is not supported for 512-bit data types on KNL and we use integer XOR instead.
I added pattern match for integer XOR.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
../lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
30304 ↗ | (On Diff #70291) | has -> have |
30359–30361 ↗ | (On Diff #70291) | Can this be an assert? |
30385–30422 ↗ | (On Diff #70291) | This would be clearer/smaller if we switched just the opcode selection and sank the common 'getBitcast(getNode())' after the switch: auto NewOpcode; switch (Arg.getOpcode()) { case X86ISD::FMADD: NewOpcode = X86ISD::FNMSUB; break; case X86ISD::FMSUB: NewOpcode = X86ISD::FNMADD; break; ... } return DAG.getBitcast(OrigVT, DAG.getNode(NewOpcode, DL, VT, Arg.getNode()->ops()); If you do that refactoring on the original code as an NFC patch, I think it will make the diff on this part of this patch just one line of code. |
../lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
30307 ↗ | (On Diff #70304) | This interface feels awkward. The normal pattern is: Ie, if there's no negated value, it will return the empty SDValue(), and the caller can use that as a bool value if it wants to. |
30359–30361 ↗ | (On Diff #70304) | This question was missed? |
../lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
30307 ↗ | (On Diff #70304) | Thanks! I was looking for a proper interface. You suggestion is better than all APIs that I tried till now. I still think that my first solution with late FNEG lowering was simpler. We handle too many different patterns for XOR/FXOR. |
30359–30361 ↗ | (On Diff #70291) | It will fail on compilation in release mode: |
LGTM - see inline comments for some nits.
../lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
30303 ↗ | (On Diff #70371) | Fp -> FP |
30307 ↗ | (On Diff #70371) | static? |
30877 ↗ | (On Diff #70371) | formatting: SDValue &V |
30878–30879 ↗ | (On Diff #70371) | combine to one line? if (SDValue Negval = isFNEG...) |