brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 2d1fbb4 Raw
203 lines · plain
1; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -machine-combiner-verify-pattern-order=true | FileCheck %s2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -stop-after machine-combiner -machine-combiner-verify-pattern-order=true -o - | FileCheck %s --check-prefix=DEAD3 4; Verify that integer multiplies are reassociated. The first multiply in 5; each test should be independent of the result of the preceding add (lea).6 7; TODO: This test does not actually test i16 machine instruction reassociation 8; because the operands are being promoted to i32 types.9 10define i16 @reassociate_muls_i16(i16 %x0, i16 %x1, i16 %x2, i16 %x3) {11; CHECK-LABEL: reassociate_muls_i16:12; CHECK:       # %bb.0:13; CHECK-NEXT:    # kill14; CHECK-NEXT:    # kill15; CHECK-NEXT:    leal   (%rdi,%rsi), %eax16; CHECK-NEXT:    imull  %ecx, %edx17; CHECK-NEXT:    imull  %edx, %eax18; CHECK-NEXT:    # kill19; CHECK-NEXT:    retq20  %t0 = add i16 %x0, %x121  %t1 = mul i16 %x2, %t022  %t2 = mul i16 %x3, %t123  ret i16 %t224}25 26define i32 @reassociate_muls_i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {27; CHECK-LABEL: reassociate_muls_i32:28; CHECK:       # %bb.0:29; CHECK-NEXT:    # kill30; CHECK-NEXT:    # kill31; CHECK-NEXT:    leal   (%rdi,%rsi), %eax32; CHECK-NEXT:    imull  %ecx, %edx33; CHECK-NEXT:    imull  %edx, %eax34; CHECK-NEXT:    retq35 36; DEAD:       ADD32rr37; DEAD-NEXT:  IMUL32rr{{.*}}implicit-def dead $eflags38; DEAD-NEXT:  IMUL32rr{{.*}}implicit-def dead $eflags39 40  %t0 = add i32 %x0, %x141  %t1 = mul i32 %x2, %t042  %t2 = mul i32 %x3, %t143  ret i32 %t244}45 46define i64 @reassociate_muls_i64(i64 %x0, i64 %x1, i64 %x2, i64 %x3) {47; CHECK-LABEL: reassociate_muls_i64:48; CHECK:       # %bb.0:49; CHECK-NEXT:    leaq   (%rdi,%rsi), %rax50; CHECK-NEXT:    imulq  %rcx, %rdx51; CHECK-NEXT:    imulq  %rdx, %rax52; CHECK-NEXT:    retq53  %t0 = add i64 %x0, %x154  %t1 = mul i64 %x2, %t055  %t2 = mul i64 %x3, %t156  ret i64 %t257}58 59; Verify that integer 'ands' are reassociated. The first 'and' in 60; each test should be independent of the result of the preceding sub.61 62define i8 @reassociate_ands_i8(i8 %x0, i8 %x1, i8 %x2, i8 %x3) {63; CHECK-LABEL: reassociate_ands_i8:64; CHECK:       # %bb.0:65; CHECK-NEXT:    movl  %edx, %eax66; CHECK-NEXT:    subb  %sil, %dil67; CHECK-NEXT:    andb  %cl, %al68; CHECK-NEXT:    andb  %dil, %al69; CHECK-NEXT:    # kill70; CHECK-NEXT:    retq71  %t0 = sub i8 %x0, %x172  %t1 = and i8 %x2, %t073  %t2 = and i8 %x3, %t174  ret i8 %t275}76 77; TODO: No way to test i16? These appear to always get promoted to i32.78 79define i32 @reassociate_ands_i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {80; CHECK-LABEL: reassociate_ands_i32:81; CHECK:       # %bb.0:82; CHECK-NEXT:    movl  %edx, %eax83; CHECK-NEXT:    subl  %esi, %edi84; CHECK-NEXT:    andl  %ecx, %eax85; CHECK-NEXT:    andl  %edi, %eax86; CHECK-NEXT:    retq87  %t0 = sub i32 %x0, %x188  %t1 = and i32 %x2, %t089  %t2 = and i32 %x3, %t190  ret i32 %t291}92 93define i64 @reassociate_ands_i64(i64 %x0, i64 %x1, i64 %x2, i64 %x3) {94; CHECK-LABEL: reassociate_ands_i64:95; CHECK:       # %bb.0:96; CHECK-NEXT:    movq  %rdx, %rax97; CHECK-NEXT:    subq  %rsi, %rdi98; CHECK-NEXT:    andq  %rcx, %rax99; CHECK-NEXT:    andq  %rdi, %rax100; CHECK-NEXT:    retq101  %t0 = sub i64 %x0, %x1102  %t1 = and i64 %x2, %t0103  %t2 = and i64 %x3, %t1104  ret i64 %t2105}106 107; Verify that integer 'ors' are reassociated. The first 'or' in 108; each test should be independent of the result of the preceding sub.109 110define i8 @reassociate_ors_i8(i8 %x0, i8 %x1, i8 %x2, i8 %x3) {111; CHECK-LABEL: reassociate_ors_i8:112; CHECK:       # %bb.0:113; CHECK-NEXT:    movl  %edx, %eax114; CHECK-NEXT:    subb  %sil, %dil115; CHECK-NEXT:    orb   %cl, %al116; CHECK-NEXT:    orb   %dil, %al117; CHECK-NEXT:    # kill118; CHECK-NEXT:    retq119  %t0 = sub i8 %x0, %x1120  %t1 = or i8 %x2, %t0121  %t2 = or i8 %x3, %t1122  ret i8 %t2123}124 125; TODO: No way to test i16? These appear to always get promoted to i32.126 127define i32 @reassociate_ors_i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {128; CHECK-LABEL: reassociate_ors_i32:129; CHECK:       # %bb.0:130; CHECK-NEXT:    movl  %edx, %eax131; CHECK-NEXT:    subl  %esi, %edi132; CHECK-NEXT:    orl   %ecx, %eax133; CHECK-NEXT:    orl   %edi, %eax134; CHECK-NEXT:    retq135  %t0 = sub i32 %x0, %x1136  %t1 = or i32 %x2, %t0137  %t2 = or i32 %x3, %t1138  ret i32 %t2139}140 141define i64 @reassociate_ors_i64(i64 %x0, i64 %x1, i64 %x2, i64 %x3) {142; CHECK-LABEL: reassociate_ors_i64:143; CHECK:       # %bb.0:144; CHECK-NEXT:    movq  %rdx, %rax145; CHECK-NEXT:    subq  %rsi, %rdi146; CHECK-NEXT:    orq   %rcx, %rax147; CHECK-NEXT:    orq   %rdi, %rax148; CHECK-NEXT:    retq149  %t0 = sub i64 %x0, %x1150  %t1 = or i64 %x2, %t0151  %t2 = or i64 %x3, %t1152  ret i64 %t2153}154 155; Verify that integer 'xors' are reassociated. The first 'xor' in156; each test should be independent of the result of the preceding sub.157 158define i8 @reassociate_xors_i8(i8 %x0, i8 %x1, i8 %x2, i8 %x3) {159; CHECK-LABEL: reassociate_xors_i8:160; CHECK:       # %bb.0:161; CHECK-NEXT:    movl  %edx, %eax162; CHECK-NEXT:    subb  %sil, %dil163; CHECK-NEXT:    xorb  %cl, %al164; CHECK-NEXT:    xorb  %dil, %al165; CHECK-NEXT:    # kill166; CHECK-NEXT:    retq167  %t0 = sub i8 %x0, %x1168  %t1 = xor i8 %x2, %t0169  %t2 = xor i8 %x3, %t1170  ret i8 %t2171}172 173; TODO: No way to test i16? These appear to always get promoted to i32.174 175define i32 @reassociate_xors_i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {176; CHECK-LABEL: reassociate_xors_i32:177; CHECK:       # %bb.0:178; CHECK-NEXT:    movl  %edx, %eax179; CHECK-NEXT:    subl  %esi, %edi180; CHECK-NEXT:    xorl  %ecx, %eax181; CHECK-NEXT:    xorl  %edi, %eax182; CHECK-NEXT:    retq183  %t0 = sub i32 %x0, %x1184  %t1 = xor i32 %x2, %t0185  %t2 = xor i32 %x3, %t1186  ret i32 %t2187}188 189define i64 @reassociate_xors_i64(i64 %x0, i64 %x1, i64 %x2, i64 %x3) {190; CHECK-LABEL: reassociate_xors_i64:191; CHECK:       # %bb.0:192; CHECK-NEXT:    movq  %rdx, %rax193; CHECK-NEXT:    subq  %rsi, %rdi194; CHECK-NEXT:    xorq  %rcx, %rax195; CHECK-NEXT:    xorq  %rdi, %rax196; CHECK-NEXT:    retq197  %t0 = sub i64 %x0, %x1198  %t1 = xor i64 %x2, %t0199  %t2 = xor i64 %x3, %t1200  ret i64 %t2201}202 203