# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-prelegalizer-combiner -verify-machineinstrs -o - %s | FileCheck %s
---
name: test_sdiv_srem
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_sdiv_srem
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_sdiv_srem_v2
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-LABEL: name: test_sdiv_srem_v2
; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK-NEXT: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK-NEXT: %div:_(<2 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(<2 x s32>), %ptr1(p1) :: (store (<2 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %rem(<2 x s32>), %ptr2(p1) :: (store (<2 x s32>), align 4, addrspace 1)
%src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
%src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
%ptr1:_(p1) = COPY $vgpr4_vgpr5
%ptr2:_(p1) = COPY $vgpr6_vgpr7
%div:_(<2 x s32>) = G_SDIV %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %div:_(<2 x s32>), %ptr1:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
%rem:_(<2 x s32>) = G_SREM %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %rem:_(<2 x s32>), %ptr2:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
...
---
name: test_sdiv_srem_v4
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-LABEL: name: test_sdiv_srem_v4
; CHECK: liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK-NEXT: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK-NEXT: %div:_(<4 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(<4 x s32>), %ptr1(p1) :: (store (<4 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %rem(<4 x s32>), %ptr2(p1) :: (store (<4 x s32>), align 4, addrspace 1)
%src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
%src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
%ptr1:_(p1) = COPY $vgpr8_vgpr9
%ptr2:_(p1) = COPY $vgpr10_vgpr11
%div:_(<4 x s32>) = G_SDIV %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %div:_(<4 x s32>), %ptr1:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
%rem:_(<4 x s32>) = G_SREM %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %rem:_(<4 x s32>), %ptr2:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
...
---
name: test_srem_sdiv
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_srem_sdiv
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: G_STORE %div(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_srem_sdiv_v2
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-LABEL: name: test_srem_sdiv_v2
; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK-NEXT: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK-NEXT: %div:_(<2 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(<2 x s32>), %ptr1(p1) :: (store (<2 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %div(<2 x s32>), %ptr2(p1) :: (store (<2 x s32>), align 4, addrspace 1)
%src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
%src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
%ptr1:_(p1) = COPY $vgpr4_vgpr5
%ptr2:_(p1) = COPY $vgpr6_vgpr7
%rem:_(<2 x s32>) = G_SREM %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %rem:_(<2 x s32>), %ptr1:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
%div:_(<2 x s32>) = G_SDIV %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %div:_(<2 x s32>), %ptr2:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
...
---
name: test_srem_sdiv_v4
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-LABEL: name: test_srem_sdiv_v4
; CHECK: liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK-NEXT: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK-NEXT: %div:_(<4 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(<4 x s32>), %ptr1(p1) :: (store (<4 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %div(<4 x s32>), %ptr2(p1) :: (store (<4 x s32>), align 4, addrspace 1)
%src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
%src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
%ptr1:_(p1) = COPY $vgpr8_vgpr9
%ptr2:_(p1) = COPY $vgpr10_vgpr11
%rem:_(<4 x s32>) = G_SREM %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %rem:_(<4 x s32>), %ptr1:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
%div:_(<4 x s32>) = G_SDIV %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %div:_(<4 x s32>), %ptr2:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
...
---
name: test_udiv_urem
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_udiv_urem
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %div:_(s32), %rem:_ = G_UDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%div:_(s32) = G_UDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_UREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_udiv_urem_v2
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-LABEL: name: test_udiv_urem_v2
; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK-NEXT: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK-NEXT: %div:_(<2 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(<2 x s32>), %ptr1(p1) :: (store (<2 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %rem(<2 x s32>), %ptr2(p1) :: (store (<2 x s32>), align 4, addrspace 1)
%src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
%src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
%ptr1:_(p1) = COPY $vgpr4_vgpr5
%ptr2:_(p1) = COPY $vgpr6_vgpr7
%div:_(<2 x s32>) = G_UDIV %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %div:_(<2 x s32>), %ptr1:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
%rem:_(<2 x s32>) = G_UREM %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %rem:_(<2 x s32>), %ptr2:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
...
---
name: test_udiv_urem_v4
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-LABEL: name: test_udiv_urem_v4
; CHECK: liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK-NEXT: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK-NEXT: %div:_(<4 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(<4 x s32>), %ptr1(p1) :: (store (<4 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %rem(<4 x s32>), %ptr2(p1) :: (store (<4 x s32>), align 4, addrspace 1)
%src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
%src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
%ptr1:_(p1) = COPY $vgpr8_vgpr9
%ptr2:_(p1) = COPY $vgpr10_vgpr11
%div:_(<4 x s32>) = G_UDIV %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %div:_(<4 x s32>), %ptr1:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
%rem:_(<4 x s32>) = G_UREM %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %rem:_(<4 x s32>), %ptr2:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
...
---
name: test_urem_udiv
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_urem_udiv
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %div:_(s32), %rem:_ = G_UDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: G_STORE %div(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%rem:_(s32) = G_UREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%div:_(s32) = G_UDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_urem_udiv_v2
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-LABEL: name: test_urem_udiv_v2
; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK-NEXT: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK-NEXT: %div:_(<2 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(<2 x s32>), %ptr1(p1) :: (store (<2 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %div(<2 x s32>), %ptr2(p1) :: (store (<2 x s32>), align 4, addrspace 1)
%src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
%src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
%ptr1:_(p1) = COPY $vgpr4_vgpr5
%ptr2:_(p1) = COPY $vgpr6_vgpr7
%rem:_(<2 x s32>) = G_UREM %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %rem:_(<2 x s32>), %ptr1:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
%div:_(<2 x s32>) = G_UDIV %src1:_(<2 x s32>), %src2:_(<2 x s32>)
G_STORE %div:_(<2 x s32>), %ptr2:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
...
---
name: test_urem_udiv_v4
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-LABEL: name: test_urem_udiv_v4
; CHECK: liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7, $vgpr8_vgpr9, $vgpr10_vgpr11
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK-NEXT: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK-NEXT: %div:_(<4 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(<4 x s32>), %ptr1(p1) :: (store (<4 x s32>), align 4, addrspace 1)
; CHECK-NEXT: G_STORE %div(<4 x s32>), %ptr2(p1) :: (store (<4 x s32>), align 4, addrspace 1)
%src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
%src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
%ptr1:_(p1) = COPY $vgpr8_vgpr9
%ptr2:_(p1) = COPY $vgpr10_vgpr11
%rem:_(<4 x s32>) = G_UREM %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %rem:_(<4 x s32>), %ptr1:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
%div:_(<4 x s32>) = G_UDIV %src1:_(<4 x s32>), %src2:_(<4 x s32>)
G_STORE %div:_(<4 x s32>), %ptr2:_(p1) :: (store (<4 x s32>), addrspace 1, align 4)
...
---
name: test_sdiv_srem_extra_use
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_sdiv_srem_extra_use
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = G_IMPLICIT_DEF
; CHECK-NEXT: %ptr2:_(p1) = G_IMPLICIT_DEF
; CHECK-NEXT: %ptr3:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr4:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: G_STORE %src1(s32), %ptr1(p1) :: (volatile store (s32) into `ptr addrspace(1) undef`, addrspace 1)
; CHECK-NEXT: G_STORE %src2(s32), %ptr2(p1) :: (volatile store (s32) into `ptr addrspace(1) undef`, addrspace 1)
; CHECK-NEXT: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr3(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: G_STORE %rem(s32), %ptr4(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = G_IMPLICIT_DEF
%ptr2:_(p1) = G_IMPLICIT_DEF
%ptr3:_(p1) = COPY $vgpr2_vgpr3
%ptr4:_(p1) = COPY $vgpr4_vgpr5
G_STORE %src1:_(s32), %ptr1:_(p1) :: (volatile store (s32) into `ptr addrspace(1) undef`, addrspace 1)
G_STORE %src2:_(s32), %ptr2:_(p1) :: (volatile store (s32) into `ptr addrspace(1) undef`, addrspace 1)
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr3:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr4:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_sdiv_srem_extra_sdiv
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; Combine the first sdiv/srem pair into sdivrem and retain the extra
; sdiv instruction.
; CHECK-LABEL: name: test_sdiv_srem_extra_sdiv
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %ptr3:_(p1) = COPY $vgpr6_vgpr7
; CHECK-NEXT: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: %div2:_(s32) = G_SDIV %src1, %src2
; CHECK-NEXT: G_STORE %div2(s32), %ptr3(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%ptr3:_(p1) = COPY $vgpr6_vgpr7
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
%div2:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div2:_(s32), %ptr3:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_sdiv_srem_extra_srem
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; Combine the first sdiv/srem pair into sdivrem and retain the extra
; srem instruction.
; CHECK-LABEL: name: test_sdiv_srem_extra_srem
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %ptr3:_(p1) = COPY $vgpr6_vgpr7
; CHECK-NEXT: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: %rem2:_(s32) = G_SREM %src1, %src2
; CHECK-NEXT: G_STORE %rem2(s32), %ptr3(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%ptr3:_(p1) = COPY $vgpr6_vgpr7
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
%rem2:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem2:_(s32), %ptr3:_(p1) :: (store (s32), addrspace 1, align 4)
...
# Some negative tests.
---
name: test_sdiv_srem_different_src_opnd2
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3_vgpr4, $vgpr5_vgpr6
; CHECK-LABEL: name: test_sdiv_srem_different_src_opnd2
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3_vgpr4, $vgpr5_vgpr6
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %src3:_(s32) = COPY $vgpr2
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr3_vgpr4
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr5_vgpr6
; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: %rem:_(s32) = G_SREM %src1, %src3
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%src3:_(s32) = COPY $vgpr2
%ptr1:_(p1) = COPY $vgpr3_vgpr4
%ptr2:_(p1) = COPY $vgpr5_vgpr6
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src3:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_sdiv_srem_src_opnds_swapped
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_sdiv_srem_src_opnds_swapped
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: %rem:_(s32) = G_SREM %src2, %src1
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_SREM %src2:_(s32), %src1:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_sdiv_urem
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_sdiv_urem
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: %rem:_(s32) = G_UREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_UREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_udiv_srem
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-LABEL: name: test_udiv_srem
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %div:_(s32) = G_UDIV %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: %rem:_(s32) = G_SREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%div:_(s32) = G_UDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...
---
name: test_sdiv_srem_different_blocks
tracksRegLiveness: true
body: |
; CHECK-LABEL: name: test_sdiv_srem_different_blocks
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.1(0x80000000)
; CHECK-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
; CHECK-NEXT: S_BRANCH %bb.1
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: liveins: $vgpr4_vgpr5
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK-NEXT: %rem:_(s32) = G_SREM %src1, %src2
; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
bb.0:
liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
%src1:_(s32) = COPY $vgpr0
%src2:_(s32) = COPY $vgpr1
%ptr1:_(p1) = COPY $vgpr2_vgpr3
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
S_BRANCH %bb.1
bb.1:
liveins: $vgpr4_vgpr5
%ptr2:_(p1) = COPY $vgpr4_vgpr5
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
...