brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.2 KiB · 30f990f Raw
191 lines · plain
1; RUN: opt -passes=consthoist -S %s -o - | FileCheck %s --check-prefix=OPT2; RUN: opt -passes=consthoist -S -consthoist-min-num-to-rebase=1 %s -o - | FileCheck %s --check-prefix=OPT --check-prefix=OPT-13; RUN: opt -passes=consthoist -S -consthoist-min-num-to-rebase=2 %s -o - | FileCheck %s --check-prefix=OPT --check-prefix=OPT-24; RUN: opt -passes=consthoist -S -consthoist-min-num-to-rebase=3 %s -o - | FileCheck %s --check-prefix=OPT --check-prefix=OPT-35 6; RUN: llc -consthoist-min-num-to-rebase=2 %s -o - | FileCheck %s --check-prefix=LLC7 8target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"9target triple = "thumbv6m-none-unknown-musleabi"10 11; Test that constant 0 and 1 of i1 type is NOT hoisted due low12; materializing cost.13 14; OPT-LABEL: avalon15; OPT: bb1:16; OPT: store i1 true17; OPT: bb2:18; OPT: store i1 false19; OPT: bb3:20; OPT: store i1 false21; OPT: store i1 false22; OPT-NOT: add23 24; LLC-LABEL: avalon25; LLC-DAG: movs r{{[0-9]+}}, #026; LLC-DAG: movs r{{[0-9]+}}, #127; LLC-NOT: add28 29@global = local_unnamed_addr global i1 undef, align 130@global.0 = local_unnamed_addr global i1 undef, align 131 32define void @avalon() #0 {33bb:34  switch i8 undef, label %bb5 [35    i8 0, label %bb136    i8 -1, label %bb237    i8 1, label %bb338  ]39 40bb1:41  store i1 1, ptr @global, align 142  unreachable43 44bb2:45  store i1 0, ptr @global, align 146  unreachable47 48bb3:49  store i1 0, ptr @global.0, align 150  store i1 0, ptr @global, align 151  unreachable52 53bb5:54  ret void55}56 57; Test that for i8 type, constant -1 is not rebased since it's the only58; dependent of base constant -2.59; This test is also covered by r342898, see60; test/CodeGen/Thumb/consthoist-imm8-costs-1.ll61 62; OPT-2-LABEL: barney63; OPT-2: bb1:64; OPT-2: store i8 -165; OPT-2: bb2:66; OPT-2: store i8 -267; OPT-2: bb3:68; OPT-2: store i8 -269; OPT-2: store i8 -270; OPT-2-NOT: add71 72; LLC-LABEL: barney73; LLC-DAG: movs r{{[0-9]+}}, #25474; LLC-DAG: movs r{{[0-9]+}}, #25575; LLC-NOT: mvn76; LLC-NOT: add77 78@global.1 = local_unnamed_addr global i8 undef, align 179@global.2 = local_unnamed_addr global i8 undef, align 180 81define void @barney() #0 {82bb:83  switch i8 undef, label %bb5 [84    i8 0, label %bb185    i8 -1, label %bb286    i8 1, label %bb387  ]88 89bb1:                                              ; preds = %bb90  store i8 -1, ptr @global.1, align 191  unreachable92 93bb2:                                              ; preds = %bb94  store i8 -2, ptr @global.1, align 195  unreachable96 97bb3:                                              ; preds = %bb98  store i8 -2, ptr @global.2, align 199  store i8 -2, ptr @global.1, align 1100  unreachable101 102bb5:                                              ; preds = %bb103  ret void104}105 106; Test that for i16 type constant 65532 is not rebased if it's the only107; dependent of base constant 65531. Cost would be the same if rebased.108; If rebased, 3 two-byte instructions:109;   movs    r0, #4110;   mvns    r0, r0111;   adds    r0, r0, #1112; If NOT rebased, 1 two-byte instruction plus 1 four-byte CP entry:113;           ldr     r1, .LCPI2_3114;           ...115;   .LCPI2_3:116;           .long   65532117 118; OPT-LABEL: carla119 120; -consthoist-min-num-to-rebase=1, check that 65532 and single use of 65531121; in bb2 is rebased122; OPT-1: bb1:123; OPT-1: %[[C1:const[0-9]?]] = bitcast i16 -5 to i16124; OPT-1-NEXT: %const_mat = add i16 %[[C1]], 1125; OPT-1-NEXT: store i16 %const_mat, ptr @global.3, align 1126; OPT-1: bb2:127; OPT-1-NEXT: %[[C2:const[0-9]?]] = bitcast i16 -5 to i16128; OPT-1-NEXT: store i16 %[[C2]], ptr @global.3, align 1129; OPT-1: bb3:130; OPT-1-NEXT: %[[C3:const[0-9]?]] = bitcast i16 -5 to i16131; OPT-1-NEXT: store i16 %[[C3]], ptr @global.4, align 1132; OPT-1-NEXT: store i16 %[[C3]], ptr @global.3, align 1133 134; -consthoist-min-num-to-rebase=2, check that 65532 and single use of 65531135; in bb2 is not rebased136; OPT-2: bb1:137; OPT-2-NEXT: store i16 -4, ptr @global.3, align 1138; OPT-2: bb2:139; OPT-2-NEXT: store i16 -5, ptr @global.3, align 1140; OPT-2: bb3:141; OPT-2-NEXT:   %[[C4:const[0-9]?]] = bitcast i16 -5 to i16142; OPT-2-NEXT:   store i16 %[[C4]], ptr @global.4, align 1143; OPT-2-NEXT:   store i16 %[[C4]], ptr @global.3, align 1144; OPT-2-NOT: add145 146; -consthoist-min-num-to-rebase=3, check that dual uses of 65531 in bb3 are147; not rebase148; OPT-3: bb1:149; OPT-3-NEXT: store i16 -4, ptr @global.3, align 1150; OPT-3: bb2:151; OPT-3-NEXT: store i16 -5, ptr @global.3, align 1152; OPT-3: bb3:153; OPT-3-NEXT:   store i16 -5, ptr @global.4, align 1154; OPT-3-NEXT:   store i16 -5, ptr @global.3, align 1155; OPT-3-NOT: add156; OPT-3-NOT: bitcast157 158; LLC-LABEL: carla159; LLC-DAG: ldr r{{[0-9]+}}, .LCPI2_1160; LLC-DAG: ldr r{{[0-9]+}}, .LCPI2_3161; LLC-NOT: mvn162; LLC-NOT: add163 164@global.3 = local_unnamed_addr global i16 undef, align 2165@global.4 = local_unnamed_addr global i16 undef, align 2166 167define void @carla() {168bb:169  switch i8 undef, label %bb5 [170    i8 0, label %bb1171    i8 -1, label %bb2172    i8 1, label %bb3173  ]174 175bb1:                                              ; preds = %bb176  store i16 65532, ptr @global.3, align 1177  unreachable178 179bb2:                                              ; preds = %bb180  store i16 65531, ptr @global.3, align 1181  unreachable182 183bb3:                                              ; preds = %bb184  store i16 65531, ptr @global.4, align 1185  store i16 65531, ptr @global.3, align 1186  unreachable187 188bb5:                                              ; preds = %bb189  ret void190}191