1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -enable-unsafe-fp-math -mtriple=x86_64-apple-darwin -mcpu=corei7-avx | FileCheck %s
6 ; Expression "x + x*x" was mistakenly transformed into "x * 3.0f".
8 define float @test1(float %x) {
11 ; CHECK-NEXT: vmulss %xmm0, %xmm0, %xmm1
12 ; CHECK-NEXT: vaddss %xmm0, %xmm1, %xmm0
14 %t1 = fmul fast float %x, %x
15 %t2 = fadd fast float %t1, %x
19 ; (x + x) + x => x * 3.0
20 define float @test2(float %x) {
23 ; CHECK-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0
25 %t1 = fadd fast float %x, %x
26 %t2 = fadd fast float %t1, %x
30 ; x + (x + x) => x * 3.0
31 define float @test3(float %x) {
34 ; CHECK-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0
36 %t1 = fadd fast float %x, %x
37 %t2 = fadd fast float %x, %t1
41 ; (y + x) + x != x * 3.0
42 define float @test4(float %x, float %y) {
45 ; CHECK-NEXT: vaddss %xmm1, %xmm0, %xmm1
46 ; CHECK-NEXT: vaddss %xmm0, %xmm1, %xmm0
48 %t1 = fadd fast float %x, %y
49 %t2 = fadd fast float %t1, %x
54 ; "x + x + x => 3.0 * x" should be disabled after legalization because
55 ; Instruction-Selection doesn't know how to handle "3.0"
57 define float @test5(<4 x float> %x) {
60 ; CHECK-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0
62 %splat = shufflevector <4 x float> %x, <4 x float> undef, <4 x i32> zeroinitializer
63 %v1 = extractelement <4 x float> %splat, i32 1
64 %v0 = extractelement <4 x float> %splat, i32 0
65 %add1 = fadd float %v0, %v1
66 %v2 = extractelement <4 x float> %splat, i32 2
67 %add2 = fadd float %v2, %add1