reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256
  257
  258
  259
  260
  261
  262
  263
  264
  265
  266
  267
  268
  269
  270
  271
  272
  273
  274
  275
  276
  277
  278
  279
  280
  281
  282
  283
  284
  285
  286
  287
  288
  289
  290
  291
  292
  293
  294
  295
  296
  297
  298
  299
  300
  301
  302
  303
  304
  305
  306
  307
  308
  309
# RUN: llc -O0 -run-pass=aarch64-prelegalizer-combiner -global-isel %s -o - | FileCheck %s
# RUN: llc -O0 -run-pass=aarch64-prelegalizer-combiner -global-isel %s -o - \
# RUN:   -debug-only=aarch64-prelegalizer-combiner,gi-combiner 2>&1 >/dev/null \
# RUN:   | FileCheck %s --check-prefix=CHECK-WORKLIST

# REQUIRES: asserts

--- |
  target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
  target triple = "aarch64--"

  define void @multiple_copies(i8* %addr) {
  entry:
    br i1 0, label %if, label %else
  if:
    br label %exit
  else:
    br label %exit
  exit:
    ret void
  }

  define void @sink_to_phi_trivially_dominating(i8* %addr) {
  entry:
    br i1 0, label %if, label %exit
  if:
    br label %exit
  exit:
    ret void
  }

  define void @sink_to_phi_nondominating(i8* %addr) {
  entry:
    br i1 0, label %if, label %else
  if:
    br label %exit
  else:
    br label %exit
  exit:
    ret void
  }

  define void @sink_to_phi_emptyblock(i8* %addr) {
  entry:
    br i1 0, label %if, label %else
  if:
    br label %exit
  else:
    br label %else2
  else2:
    br label %exit
  exit:
    ret void
  }

  define void @use_doesnt_def_anything(i8* %addr) {
  entry:
    ret void
  }

  define void @op0_isnt_a_reg(i8* %addr) {
  entry:
    ret void
  }
...

---
name:            multiple_copies
# CHECK-LABEL: name: multiple_copies
tracksRegLiveness: true
body: |
  bb.0.entry:
    liveins: $x0, $w1
    successors: %bb.1(0x40000000), %bb.2(0x40000000); %bb.1(50.00%), %bb.2(50.00%)
    ; CHECK: [[T0:%[0-9]+]]:_(s32) = G_SEXTLOAD
    %0:_(p0) = COPY $x0
    %1:_(s32) = COPY $w1
    %2:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
    %3:_(s32) = G_SEXT %2
    %4:_(s32) = G_CONSTANT i32 1
    %5:_(s1) = G_ICMP intpred(ne), %1:_(s32), %4:_
    G_BRCOND %5:_(s1), %bb.1
    G_BR %bb.2.else
  bb.1.if:
  ; CHECK: bb.1.if:
    successors: %bb.3(0x80000000)
    %10:_(s8) = G_CONSTANT i8 1
    ; CHECK: [[T1:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    %6:_(s8) = G_ADD %2, %10
    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_ADD [[T1]], {{.*}}
    G_BR %bb.3.exit
  bb.2.else:
  ; CHECK: bb.2.else:
    successors: %bb.3(0x80000000)
    %11:_(s8) = G_CONSTANT i8 1
    ; CHECK: [[T3:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    %7:_(s8) = G_SUB %2, %11
    ; CHECK: [[T4:%[0-9]+]]:_(s8) = G_SUB [[T3]], {{.*}}
    G_BR %bb.3.exit
  bb.3.exit:
  ; CHECK: bb.3.exit:
    %8:_(s8) = G_PHI %6:_(s8), %bb.1, %7:_(s8), %bb.2
    ; CHECK: [[T5:%[0-9]+]]:_(s8) = G_PHI [[T2]](s8), %bb.1, [[T4]](s8)
    %9:_(s32) = G_ZEXT %8
    ; CHECK: [[T6:%[0-9]+]]:_(s32) = G_ZEXT [[T5]](s8)
    ; CHECK: $w0 = COPY [[T0]](s32)
    ; CHECK: $w1 = COPY [[T6]](s32)
    $w0 = COPY %3
    $w1 = COPY %9

# Check that we report the correct modifications to the observer. This acts as
# a test of the debug output and a test.
#
# CHECK-WORKLIST-LABEL: Generic MI Combiner for: multiple_copies
# CHECK-WORKLIST:       Try combining [[IN0:%[0-9]+]]:_(s8) = G_LOAD [[IN1:%[0-9]+]]:_(p0) :: (load 1 from %ir.addr)
# CHECK-WORKLIST:       Preferred use is: [[IN2:%[0-9]+]]:_(s32) = G_SEXT [[IN0]]:_(s8)
# CHECK-WORKLIST-DAG:   Changing: [[IN0]]:_(s8) = G_LOAD [[IN1]]:_(p0) :: (load 1 from %ir.addr)
# CHECK-WORKLIST-DAG:   Changing: [[IN3:%[0-9]+]]:_(s8) = G_ADD [[IN0]]:_, [[IN4:%[0-9]+]]:_
# CHECK-WORKLIST-DAG:   Changed: [[IN3]]:_(s8) = G_ADD [[NEW1:%[0-9]+]]:_, [[IN4]]:_
# CHECK-WORKLIST-DAG:   Changing: [[IN5:%[0-9]+]]:_(s8) = G_SUB [[IN0]]:_, [[IN6:%[0-9]+]]:_
# CHECK-WORKLIST-DAG:   Changed: [[IN5]]:_(s8) = G_SUB [[NEW2:%[0-9]+]]:_, [[IN6]]:_
# CHECK-WORKLIST-DAG:   Erasing: [[IN2]]:_(s32) = G_SEXT [[IN0]]:_(s8)
# CHECK-WORKLIST-DAG:   Changed: [[IN2]]:_(s32) = G_SEXTLOAD [[IN1]]:_(p0) :: (load 1 from %ir.addr)
# CHECK-WORKLIST-DAG:   Created: [[NEW1]]:_(s8) = G_TRUNC [[IN2]]:_(s32)
# CHECK-WORKLIST-DAG:   Created: [[NEW2]]:_(s8) = G_TRUNC [[IN2]]:_(s32)
# CHECK-WORKLIST:       Try combining
...

---
name:            sink_to_phi_trivially_dominating
# CHECK-LABEL: name: sink_to_phi_trivially_dominating
# This test currently tests that we don't sink if we would sink to a phi. This
# is needed to avoid inserting into the middle of the leading G_PHI instructions
# of a BB
tracksRegLiveness: true
body: |
  bb.0.entry:
    liveins: $x0, $w1
    successors: %bb.1(0x40000000), %bb.2(0x40000000); %bb.1(50.00%), %bb.2(50.00%)
    ; CHECK: [[T0:%[0-9]+]]:_(s32) = G_SEXTLOAD
    %0:_(p0) = COPY $x0
    %1:_(s32) = COPY $w1
    %2:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
    ; CHECK: [[T4:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    %3:_(s32) = G_SEXT %2
    %4:_(s32) = G_CONSTANT i32 1
    %5:_(s1) = G_ICMP intpred(ne), %1:_(s32), %4:_
    G_BRCOND %5:_(s1), %bb.1
    G_BR %bb.2.exit
  bb.1.if:
  ; CHECK: bb.1.if:
    successors: %bb.2(0x80000000)
    %10:_(s8) = G_CONSTANT i8 1
    ; CHECK: [[T1:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    %6:_(s8) = G_ADD %2, %10
    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_ADD [[T1]], {{.*}}
    G_BR %bb.2.exit
  bb.2.exit:
  ; CHECK: bb.2.exit:
    %8:_(s8) = G_PHI %6:_(s8), %bb.1, %2:_(s8), %bb.0
    ; CHECK: [[T5:%[0-9]+]]:_(s8) = G_PHI [[T2]](s8), %bb.1, [[T4]](s8)
    %9:_(s32) = G_ZEXT %8
    ; CHECK: [[T6:%[0-9]+]]:_(s32) = G_ZEXT [[T5]](s8)
    ; CHECK: $w0 = COPY [[T0]](s32)
    ; CHECK: $w1 = COPY [[T6]](s32)
    $w0 = COPY %3
    $w1 = COPY %9
...

---
name:            sink_to_phi_nondominating
# CHECK-LABEL: name: sink_to_phi_nondominating
tracksRegLiveness: true
body: |
  bb.0.entry:
    liveins: $x0, $w1
    successors: %bb.1(0x40000000), %bb.2(0x40000000); %bb.1(50.00%), %bb.2(50.00%)
    ; CHECK: [[T0:%[0-9]+]]:_(s32) = G_SEXTLOAD
    %0:_(p0) = COPY $x0
    %1:_(s32) = COPY $w1
    %2:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
    %3:_(s32) = G_CONSTANT i32 1
    %4:_(s1) = G_ICMP intpred(ne), %1:_(s32), %3:_
    G_BRCOND %4:_(s1), %bb.1
    G_BR %bb.2.else
  bb.1.if:
  ; CHECK: bb.1.if:
    successors: %bb.3(0x80000000)
    %5:_(s8) = G_CONSTANT i8 1
    ; CHECK: [[T1:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    %6:_(s8) = G_ADD %2, %5
    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_ADD [[T1]], {{.*}}
    G_BR %bb.3.exit
  bb.2.else:
  ; CHECK: bb.2.else:
    successors: %bb.3(0x80000000)
    %7:_(s8) = G_CONSTANT i8 1
    ; CHECK: [[T3:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    %8:_(s8) = G_SUB %2, %7
    ; CHECK: [[T4:%[0-9]+]]:_(s8) = G_SUB [[T3]], {{.*}}
    G_BR %bb.3.exit
  bb.3.exit:
  ; CHECK: bb.3.exit:
    %9:_(s8) = G_PHI %6:_(s8), %bb.1, %8:_(s8), %bb.2
    ; CHECK: [[T5:%[0-9]+]]:_(s8) = G_PHI [[T2]](s8), %bb.1, [[T4]](s8)
    %10:_(s32) = G_SEXT %2
    %11:_(s32) = G_ZEXT %9
    ; CHECK: [[T6:%[0-9]+]]:_(s32) = G_ZEXT [[T5]](s8)
    ; CHECK: $w0 = COPY [[T0]](s32)
    ; CHECK: $w1 = COPY [[T6]](s32)
    $w0 = COPY %10
    $w1 = COPY %11
# CHECK-WORKLIST-LABEL: Generic MI Combiner for: sink_to_phi_nondominating
# CHECK-WORKLIST:       Try combining [[IN0:%[0-9]+]]:_(s8) = G_LOAD [[IN1:%[0-9]+]]:_(p0) :: (load 1 from %ir.addr)
# CHECK-WORKLIST:       Preferred use is: [[IN2:%[0-9]+]]:_(s32) = G_SEXT [[IN0]]:_(s8)
# CHECK-WORKLIST-DAG:   Changing: [[IN0]]:_(s8) = G_LOAD [[IN1]]:_(p0) :: (load 1 from %ir.addr)
# CHECK-WORKLIST-DAG:   Creating: G_TRUNC
# CHECK-WORKLIST-DAG:   Changing: [[IN3:%[0-9]+]]:_(s8) = G_ADD [[IN0]]:_, [[IN4:%[0-9]+]]:_
# CHECK-WORKLIST-DAG:   Changed: [[IN3]]:_(s8) = G_ADD [[OUT1:%[0-9]+]]:_, [[IN4]]:_
# CHECK-WORKLIST-DAG:   Creating: G_TRUNC
# CHECK-WORKLIST-DAG:   Changing: [[IN5:%[0-9]+]]:_(s8) = G_SUB [[IN0]]:_, [[IN6:%[0-9]+]]:_
# CHECK-WORKLIST-DAG:   Changed: [[IN5]]:_(s8) = G_SUB [[OUT2:%[0-9]+]]:_, [[IN6]]:_
# CHECK-WORKLIST-DAG:   Erasing: [[IN2]]:_(s32) = G_SEXT [[IN0]]:_(s8)
# CHECK-WORKLIST-DAG:   Changed: [[IN2]]:_(s32) = G_SEXTLOAD [[IN1]]:_(p0) :: (load 1 from %ir.addr)
# CHECK-WORKLIST-DAG:   Created: [[OUT1]]:_(s8) = G_TRUNC [[IN2]]:_(s32)
# CHECK-WORKLIST-DAG:   Created: [[OUT2]]:_(s8) = G_TRUNC [[IN2]]:_(s32)
# CHECK-WORKLIST:       Try combining
...

---
name:            sink_to_phi_emptyblock
# CHECK-LABEL: name: sink_to_phi_emptyblock
tracksRegLiveness: true
body: |
  bb.0.entry:
    liveins: $x0, $w1
    successors: %bb.1(0x40000000), %bb.2(0x40000000); %bb.1(50.00%), %bb.2(50.00%)
    ; CHECK: [[T0:%[0-9]+]]:_(s32) = G_SEXTLOAD
    %0:_(p0) = COPY $x0
    %1:_(s32) = COPY $w1
    %2:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
    %3:_(s32) = G_SEXT %2
    %4:_(s32) = G_CONSTANT i32 1
    %5:_(s1) = G_ICMP intpred(ne), %1:_(s32), %4:_
    G_BRCOND %5:_(s1), %bb.1
    G_BR %bb.2.else
  bb.1.if:
  ; CHECK: bb.1.if:
    successors: %bb.4(0x80000000)
    %10:_(s8) = G_CONSTANT i8 1
    ; CHECK: [[T1:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    %6:_(s8) = G_ADD %2, %10
    ; CHECK: [[T2:%[0-9]+]]:_(s8) = G_ADD [[T1]], {{.*}}
    G_BR %bb.4.exit
  bb.2.else:
  ; CHECK: bb.2.else:
    successors: %bb.3(0x80000000)
    G_BR %bb.3.else2
  bb.3.else2:
  ; CHECK: bb.3.else2:
    successors: %bb.4(0x80000000)
    ; CHECK: [[T4:%[0-9]+]]:_(s8) = G_TRUNC [[T0]](s32)
    ; Fallthrough
  bb.4.exit:
  ; CHECK: bb.4.exit:
    %8:_(s8) = G_PHI %6:_(s8), %bb.1, %2:_(s8), %bb.3
    ; CHECK: [[T5:%[0-9]+]]:_(s8) = G_PHI [[T2]](s8), %bb.1, [[T4]](s8)
    %9:_(s32) = G_ZEXT %8
    ; CHECK: [[T6:%[0-9]+]]:_(s32) = G_ZEXT [[T5]](s8)
    ; CHECK: $w0 = COPY [[T0]](s32)
    ; CHECK: $w1 = COPY [[T6]](s32)
    $w0 = COPY %3
    $w1 = COPY %9
...

---
name:            use_doesnt_def_anything
# CHECK-LABEL: name: use_doesnt_def_anything
# Check that we don't crash when inspecting a use that doesn't define anything.
# The real issue which was that the combine rule was looking through
# non-truncates as if they were truncates and attempting to obtain the result
# register. It would usually go on to make the right overall decision anyway but
# would sometimes crash on things like (SOME_INTRINSIC imm). This test covers
# the case that it would recover from.
tracksRegLiveness: true
body: |
  bb.0.entry:
    liveins: $x0, $w1
    %0:_(p0) = COPY $x0
    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
    ; CHECK: %1:_(s8) = G_LOAD %0(p0) :: (load 1 from %ir.addr)
    G_STORE %1(s8), %0(p0) :: (store 1 into %ir.addr)
    ; CHECK: G_STORE %1(s8), %0(p0) :: (store 1 into %ir.addr)
...

---
name:            op0_isnt_a_reg
# CHECK-LABEL: name: op0_isnt_a_reg
# This test covers the variant of use_doesnt_def_anything that would crash.
tracksRegLiveness: true
body: |
  bb.0.entry:
    liveins: $x0, $w1
    %0:_(p0) = COPY $x0
    %1:_(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
    ; CHECK: %1:_(s8) = G_LOAD %0(p0) :: (load 1 from %ir.addr)
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.aarch64.hint), %1(s8)
    ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.aarch64.hint), %1(s8)
...