llvm.org GIT mirror llvm / 2d3c0b9
[X86] Make sure we don't combine (fneg (fma X, Y, Z)) to a target specific node when there are no FMA instructions. This would cause a 'cannot select' error at isel when we should have emitted a lib call and an xor. Fixes PR36553. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326393 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 2 years ago
2 changed file(s) with 21 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
3573635736 // If we're negating an FMA node, then we can adjust the
3573735737 // instruction to include the extra negation.
3573835738 unsigned NewOpcode = 0;
35739 if (Arg.hasOneUse()) {
35739 if (Arg.hasOneUse() && Subtarget.hasAnyFMA()) {
3574035740 switch (Arg.getOpcode()) {
3574135741 case ISD::FMA: NewOpcode = X86ISD::FNMSUB; break;
3574235742 case X86ISD::FMSUB: NewOpcode = X86ISD::FNMADD; break;
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s
2
3 ; Make sure we don't crash because we negated an fma when we didn't have any fma instructions.
4
5 define float @pr36553(float %a, float %b, float %c) nounwind {
6 ; CHECK-LABEL: pr36553:
7 ; CHECK: ## %bb.0: ## %entry
8 ; CHECK-NEXT: pushq %rax
9 ; CHECK-NEXT: callq _fmaf
10 ; CHECK-NEXT: xorps {{.*}}(%rip), %xmm0
11 ; CHECK-NEXT: popq %rax
12 ; CHECK-NEXT: retq
13 entry:
14 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c)
15 %sub = fsub float -0.000000e+00, %0
16 ret float %sub
17 }
18
19 declare float @llvm.fma.f32(float, float, float)