1 ; RUN: llc < %s -enable-unsafe-fp-math -mtriple=x86_64-apple-darwin -mcpu=corei7-avx | FileCheck %s
5 ; Expression "x + x*x" was mistakenly transformed into "x * 3.0f".
7 define float @test1(float %x) {
8 %t1 = fmul fast float %x, %x
9 %t2 = fadd fast float %t1, %x
15 ; (x + x) + x => x * 3.0
16 define float @test2(float %x) {
17 %t1 = fadd fast float %x, %x
18 %t2 = fadd fast float %t1, %x
20 ; CHECK: .long 1077936128
22 ; CHECK: vmulss LCPI1_0(%rip), %xmm0, %xmm0
25 ; x + (x + x) => x * 3.0
26 define float @test3(float %x) {
27 %t1 = fadd fast float %x, %x
28 %t2 = fadd fast float %t1, %x
30 ; CHECK: .long 1077936128
32 ; CHECK: vmulss LCPI2_0(%rip), %xmm0, %xmm0
35 ; (y + x) + x != x * 3.0
36 define float @test4(float %x, float %y) {
37 %t1 = fadd fast float %x, %y
38 %t2 = fadd fast float %t1, %x
45 ; "x + x + x => 3.0 * x" should be disabled after legalization because
46 ; Instruction-Selection doesn't know how to handle "3.0"
48 define float @test5() {
49 %mul.i.i151 = fmul <4 x float> zeroinitializer, zeroinitializer
50 %vecext.i8.i152 = extractelement <4 x float> %mul.i.i151, i32 1
51 %vecext1.i9.i153 = extractelement <4 x float> %mul.i.i151, i32 0
52 %add.i10.i154 = fadd float %vecext1.i9.i153, %vecext.i8.i152
53 %vecext.i7.i155 = extractelement <4 x float> %mul.i.i151, i32 2
54 %add.i.i156 = fadd float %vecext.i7.i155, %add.i10.i154