1 ; Test the lowering sequence for commutative operations. If there is a source 2 ; operand whose lifetime ends in an operation, it should be the first operand, 3 ; eliminating the need for a move to start the new lifetime. 4 5 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ 6 ; RUN: --target x8632 -i %s --args -O2 \ 7 ; RUN: | %if --need=target_X8632 --command FileCheck %s 8 9 ; RUN: %if --need=target_MIPS32 --need=allow_dump \ 10 ; RUN: --command %p2i --filetype=asm --assemble --disassemble --target \ 11 ; RUN: mips32 -i %s --args -O2 -allow-externally-defined-symbols \ 12 ; RUN: | %if --need=target_MIPS32 --need=allow_dump \ 13 ; RUN: --command FileCheck --check-prefix MIPS32 %s 14 15 define internal i32 @integerAddLeft(i32 %a, i32 %b) { 16 entry: 17 %tmp = add i32 %a, %b 18 %result = add i32 %a, %tmp 19 ret i32 %result 20 } 21 ; CHECK-LABEL: integerAddLeft 22 ; CHECK-NEXT: mov {{e..}},DWORD PTR 23 ; CHECK-NEXT: mov {{e..}},DWORD PTR 24 ; CHECK-NEXT: add {{e..}},{{e..}} 25 ; CHECK-NEXT: add {{e..}},{{e..}} 26 ; MIPS32-LABEL: integerAddLeft 27 ; MIPS32: move v0,a0 28 ; MIPS32: addu v0,v0,a1 29 ; MIPS32: addu a0,a0,v0 30 31 define internal i32 @integerAddRight(i32 %a, i32 %b) { 32 entry: 33 %tmp = add i32 %a, %b 34 %result = add i32 %b, %tmp 35 ret i32 %result 36 } 37 ; CHECK-LABEL: integerAddRight 38 ; CHECK-NEXT: mov {{e..}},DWORD PTR 39 ; CHECK-NEXT: mov {{e..}},DWORD PTR 40 ; CHECK-NEXT: add {{e..}},{{e..}} 41 ; CHECK-NEXT: add {{e..}},{{e..}} 42 ; MIPS32-LABEL: integerAddRight 43 ; MIPS32: move v0,a1 44 ; MIPS32: addu a0,a0,v0 45 ; MIPS32: addu a1,a1,a0 46 47 define internal i32 @integerMultiplyLeft(i32 %a, i32 %b) { 48 entry: 49 %tmp = mul i32 %a, %b 50 %result = mul i32 %a, %tmp 51 ret i32 %result 52 } 53 ; CHECK-LABEL: integerMultiplyLeft 54 ; CHECK-NEXT: mov {{e..}},DWORD PTR 55 ; CHECK-NEXT: mov {{e..}},DWORD PTR 56 ; CHECK-NEXT: imul {{e..}},{{e..}} 57 ; CHECK-NEXT: imul {{e..}},{{e..}} 58 ; MIPS32-LABEL: integerMultiplyLeft 59 ; MIPS32: move v0,a0 60 ; MIPS32: mul v0,v0,a1 61 ; MIPS32: mul a0,a0,v0 62 63 define internal i32 @integerMultiplyRight(i32 %a, i32 %b) { 64 entry: 65 %tmp = mul i32 %a, %b 66 %result = mul i32 %b, %tmp 67 ret i32 %result 68 } 69 ; CHECK-LABEL: integerMultiplyRight 70 ; CHECK-NEXT: mov {{e..}},DWORD PTR 71 ; CHECK-NEXT: mov {{e..}},DWORD PTR 72 ; CHECK-NEXT: imul {{e..}},{{e..}} 73 ; CHECK-NEXT: imul {{e..}},{{e..}} 74 ; MIPS32-LABEL: integerMultiplyRight 75 ; MIPS32: move v0,a1 76 ; MIPS32: mul a0,a0,v0 77 ; MIPS32: mul a1,a1,a0 78 79 define internal float @floatAddLeft(float %a, float %b) { 80 entry: 81 %tmp = fadd float %a, %b 82 %result = fadd float %a, %tmp 83 ret float %result 84 } 85 ; CHECK-LABEL: floatAddLeft 86 ; CHECK-NEXT: sub esp,0x1c 87 ; CHECK-NEXT: movss xmm0,DWORD PTR 88 ; CHECK-NEXT: movss xmm1,DWORD PTR 89 ; CHECK-NEXT: addss xmm1,xmm0 90 ; CHECK-NEXT: addss xmm0,xmm1 91 ; MIPS32-LABEL: floatAddLeft 92 ; MIPS32: mov.s $f0,$f12 93 ; MIPS32: add.s $f0,$f0,$f14 94 ; MIPS32: add.s $f12,$f12,$f0 95 96 define internal float @floatAddRight(float %a, float %b) { 97 entry: 98 %tmp = fadd float %a, %b 99 %result = fadd float %b, %tmp 100 ret float %result 101 } 102 ; CHECK-LABEL: floatAddRight 103 ; CHECK-NEXT: sub esp,0x1c 104 ; CHECK-NEXT: movss xmm0,DWORD PTR 105 ; CHECK-NEXT: movss xmm1,DWORD PTR 106 ; CHECK-NEXT: addss xmm0,xmm1 107 ; CHECK-NEXT: addss xmm1,xmm0 108 ; MIPS32-LABEL: floatAddRight 109 ; MIPS32: mov.s $f0,$f14 110 ; MIPS32: add.s $f12,$f12,$f0 111 ; MIPS32: add.s $f14,$f14,$f12 112 113 define internal float @floatMultiplyLeft(float %a, float %b) { 114 entry: 115 %tmp = fmul float %a, %b 116 %result = fmul float %a, %tmp 117 ret float %result 118 } 119 ; CHECK-LABEL: floatMultiplyLeft 120 ; CHECK-NEXT: sub esp,0x1c 121 ; CHECK-NEXT: movss xmm0,DWORD PTR 122 ; CHECK-NEXT: movss xmm1,DWORD PTR 123 ; CHECK-NEXT: mulss xmm1,xmm0 124 ; CHECK-NEXT: mulss xmm0,xmm1 125 ; MIPS32-LABEL: floatMultiplyLeft 126 ; MIPS32: mov.s $f0,$f12 127 ; MIPS32: mul.s $f0,$f0,$f14 128 ; MIPS32: mul.s $f12,$f12,$f0 129 130 define internal float @floatMultiplyRight(float %a, float %b) { 131 entry: 132 %tmp = fmul float %a, %b 133 %result = fmul float %b, %tmp 134 ret float %result 135 } 136 ; CHECK-LABEL: floatMultiplyRight 137 ; CHECK-NEXT: sub esp,0x1c 138 ; CHECK-NEXT: movss xmm0,DWORD PTR 139 ; CHECK-NEXT: movss xmm1,DWORD PTR 140 ; CHECK-NEXT: mulss xmm0,xmm1 141 ; CHECK-NEXT: mulss xmm1,xmm0 142 ; MIPS32-LABEL: floatMultiplyRight 143 ; MIPS32: mov.s $f0,$f14 144 ; MIPS32: mul.s $f12,$f12,$f0 145 ; MIPS32: mul.s $f14,$f14,$f12 146