brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 859f54e Raw
102 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s3 4define double @exact(double %x) {5; Exact division by a constant converted to multiplication.6; CHECK-LABEL: exact:7; CHECK:       # %bb.0:8; CHECK-NEXT:    mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm09; CHECK-NEXT:    retq10  %div = fdiv double %x, 2.011  ret double %div12}13 14define double @inexact(double %x) {15; Inexact division by a constant converted to multiplication.16; CHECK-LABEL: inexact:17; CHECK:       # %bb.0:18; CHECK-NEXT:    mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm019; CHECK-NEXT:    retq20  %div = fdiv arcp double %x, 0x41DFFFFFFFC0000021  ret double %div22}23 24define double @funky(double %x) {25; No conversion to multiplication if too funky.26; CHECK-LABEL: funky:27; CHECK:       # %bb.0:28; CHECK-NEXT:    xorpd %xmm1, %xmm129; CHECK-NEXT:    divsd %xmm1, %xmm030; CHECK-NEXT:    retq31  %div = fdiv double %x, 0.032  ret double %div33}34 35define double @denormal1(double %x) {36; Don't generate multiplication by a denormal.37; CHECK-LABEL: denormal1:38; CHECK:       # %bb.0:39; CHECK-NEXT:    divsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm040; CHECK-NEXT:    retq41  %div = fdiv double %x, 0x7FD000000000000142  ret double %div43}44 45define double @denormal2(double %x) {46; Don't generate multiplication by a denormal.47; CHECK-LABEL: denormal2:48; CHECK:       # %bb.0:49; CHECK-NEXT:    divsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm050; CHECK-NEXT:    retq51  %div = fdiv double %x, 0x7FEFFFFFFFFFFFFF52  ret double %div53}54 55; Deleting the negates does not require unsafe-fp-math.56 57define float @double_negative(float %x, float %y) {58; CHECK-LABEL: double_negative:59; CHECK:       # %bb.0:60; CHECK-NEXT:    divss %xmm1, %xmm061; CHECK-NEXT:    retq62  %neg1 = fsub float -0.0, %x63  %neg2 = fsub float -0.0, %y64  %div = fdiv float %neg1, %neg265  ret float %div66}67 68define <4 x float> @double_negative_vector(<4 x float> %x, <4 x float> %y) {69; CHECK-LABEL: double_negative_vector:70; CHECK:       # %bb.0:71; CHECK-NEXT:    divps %xmm1, %xmm072; CHECK-NEXT:    retq73  %neg1 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %x74  %neg2 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %y75  %div = fdiv <4 x float> %neg1, %neg276  ret <4 x float> %div77}78 79; This test used to fail, depending on how llc was built (e.g. using80; clang/gcc), due to order of argument evaluation not being well defined. We81; ended up hitting llvm_unreachable in getNegatedExpression when building with82; gcc. Just make sure that we get a deterministic result.83define float @fdiv_fneg_combine(float %a0, float %a1, float %a2) {84; CHECK-LABEL: fdiv_fneg_combine:85; CHECK:       # %bb.0:86; CHECK-NEXT:    movaps %xmm0, %xmm387; CHECK-NEXT:    subss %xmm1, %xmm388; CHECK-NEXT:    subss %xmm0, %xmm189; CHECK-NEXT:    mulss %xmm2, %xmm190; CHECK-NEXT:    subss %xmm2, %xmm391; CHECK-NEXT:    divss %xmm3, %xmm192; CHECK-NEXT:    movaps %xmm1, %xmm093; CHECK-NEXT:    retq94  %sub1 = fsub fast float %a0, %a195  %mul2 = fmul fast float %sub1, %a296  %neg = fneg fast float %a097  %add3 = fadd fast float %a1, %neg98  %sub4 = fadd fast float %add3, %a299  %div5 = fdiv fast float %mul2, %sub4100  ret float %div5101}102