1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner %s -o - -verify-machineinstrs | FileCheck %s
4 # Check that we insert the divrem at the place of the G_UDIV, not the G_UREM.
6 name: divrem_use_before_def
8 tracksRegLiveness: true
12 ; CHECK-LABEL: name: divrem_use_before_def
14 ; CHECK: successors: %bb.2(0x40000000), %bb.1(0x40000000)
16 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
17 ; CHECK: [[DEF:%[0-9]+]]:_(s1) = G_IMPLICIT_DEF
18 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
19 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
20 ; CHECK: G_BRCOND [[DEF]](s1), %bb.2
23 ; CHECK: successors: %bb.2(0x80000000)
24 ; CHECK: [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
25 ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[C]](s64)
26 ; CHECK: [[UDIVREM:%[0-9]+]]:_(s32), [[UDIVREM1:%[0-9]+]]:_ = G_UDIVREM [[DEF1]], [[TRUNC]]
27 ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[UDIVREM]](s32)
28 ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
29 ; CHECK: [[FREEZE:%[0-9]+]]:_(s64) = G_FREEZE [[C2]]
30 ; CHECK: [[UDIV:%[0-9]+]]:_(s64) = G_UDIV [[FREEZE]], [[C]]
31 ; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C1]](s64)
32 ; CHECK: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[SHL]], [[UDIV]]
33 ; CHECK: G_STORE [[ADD]](s64), [[COPY]](p0) :: (store (s64))
39 %1:_(s1) = G_IMPLICIT_DEF
40 %2:_(s64) = G_IMPLICIT_DEF
41 %4:_(s64) = G_CONSTANT i64 0
42 %12:_(s64) = G_CONSTANT i64 32
43 G_BRCOND %1(s1), %bb.3
47 %3:_(s32) = G_TRUNC %2(s64)
48 %5:_(s32) = G_TRUNC %4(s64)
49 %6:_(s32) = G_UDIV %3, %5
50 %7:_(s64) = G_ZEXT %6(s32)
51 %8:_(s32) = COPY %3(s32)
52 %9:_(s32) = COPY %5(s32)
53 %10:_(s32) = G_UREM %8, %9
54 %11:_(s64) = G_ZEXT %10(s32)
55 %13:_(s64) = nuw G_SHL %11, %12(s64)
56 %14:_(s64) = G_OR %2, %13
57 %15:_(s64) = G_FREEZE %14
58 %16:_(s64) = G_UDIV %15, %4
59 %17:_(s64) = G_SHL %7, %12(s64)
60 %18:_(s64) = G_ADD %17, %16
61 G_STORE %18(s64), %0(p0) :: (store (s64))