brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 4836da2 Raw
95 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s3 4declare double @sin(double %f)5 6; When the subs are strict, they can't be removed because of signed zero.7 8define double @strict(double %e) nounwind {9; CHECK-LABEL: strict:10; CHECK:       # %bb.0:11; CHECK-NEXT:    pushq %rax12; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm113; CHECK-NEXT:    vsubsd %xmm0, %xmm1, %xmm014; CHECK-NEXT:    callq sin@PLT15; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm116; CHECK-NEXT:    vsubsd %xmm0, %xmm1, %xmm017; CHECK-NEXT:    popq %rax18; CHECK-NEXT:    retq19  %f = fsub double 0.0, %e20  %g = call double @sin(double %f) readonly21  %h = fsub double 0.0, %g22  ret double %h23}24 25; 'fast' implies no-signed-zeros, so the negates fold away.26; The 'sin' does not need any fast-math-flags for this transform.27 28define double @fast(double %e) nounwind {29; CHECK-LABEL: fast:30; CHECK:       # %bb.0:31; CHECK-NEXT:    jmp sin@PLT # TAILCALL32  %f = fsub fast double 0.0, %e33  %g = call double @sin(double %f) readonly34  %h = fsub fast double 0.0, %g35  ret double %h36}37 38; No-signed-zeros is all that we need for this transform.39 40define double @nsz(double %e) nounwind {41; CHECK-LABEL: nsz:42; CHECK:       # %bb.0:43; CHECK-NEXT:    jmp sin@PLT # TAILCALL44  %f = fsub nsz double 0.0, %e45  %g = call double @sin(double %f) readonly46  %h = fsub nsz double 0.0, %g47  ret double %h48}49 50; The 1st negate is strict, so we can't kill that sub, but the 2nd disappears.51 52define double @semi_strict1(double %e) nounwind {53; CHECK-LABEL: semi_strict1:54; CHECK:       # %bb.0:55; CHECK-NEXT:    pushq %rax56; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm157; CHECK-NEXT:    vsubsd %xmm0, %xmm1, %xmm058; CHECK-NEXT:    callq sin@PLT59; CHECK-NEXT:    vxorpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm060; CHECK-NEXT:    popq %rax61; CHECK-NEXT:    retq62  %f = fsub double 0.0, %e63  %g = call double @sin(double %f) readonly64  %h = fsub nsz double 0.0, %g65  ret double %h66}67 68; The 2nd negate is strict, so we can't kill it. It becomes an add of zero instead.69 70define double @semi_strict2(double %e) nounwind {71; CHECK-LABEL: semi_strict2:72; CHECK:       # %bb.0:73; CHECK-NEXT:    pushq %rax74; CHECK-NEXT:    callq sin@PLT75; CHECK-NEXT:    vxorpd %xmm1, %xmm1, %xmm176; CHECK-NEXT:    vaddsd %xmm1, %xmm0, %xmm077; CHECK-NEXT:    popq %rax78; CHECK-NEXT:    retq79  %f = fsub nsz double 0.0, %e80  %g = call double @sin(double %f) readonly81  %h = fsub double 0.0, %g82  ret double %h83}84 85define double @nsz_flag(double %e) nounwind {86; CHECK-LABEL: nsz_flag:87; CHECK:       # %bb.0:88; CHECK-NEXT:    jmp sin@PLT # TAILCALL89  %f = fsub nsz double 0.0, %e90  %g = call nsz double @sin(double %f) readonly91  %h = fsub nsz double 0.0, %g92  ret double %h93}94 95