1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/CodeGen/AMDGPU/GlobalISel/prelegalizer-combiner-divrem.mir
Christudasan Devadasan aa8030a6bf GlobalISel: Try to combine G_[SU]DIV and G_[SU]REM
It is good to have a combined `divrem` instruction when the
`div` and `rem` are computed from identical input operands.
Some targets can lower them through a single expansion that
computes both division and remainder. It effectively reduces
the number of instructions than individually expanding them.

Reviewed By: arsenm, paquette

Differential Revision: https://reviews.llvm.org/D96013
2021-03-10 18:46:07 +05:30

524 lines
23 KiB
YAML

# 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, 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: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK: %div:_(<2 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %div(<2 x s32>), %ptr1(p1) :: (store 8, align 4, addrspace 1)
; CHECK: G_STORE %rem(<2 x s32>), %ptr2(p1) :: (store 8, 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 8, 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 8, 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: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK: %div:_(<4 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %div(<4 x s32>), %ptr1(p1) :: (store 16, align 4, addrspace 1)
; CHECK: G_STORE %rem(<4 x s32>), %ptr2(p1) :: (store 16, 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 16, 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 16, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %rem(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: G_STORE %div(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr2:_(p1) :: (store 4, 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: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK: %div:_(<2 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %rem(<2 x s32>), %ptr1(p1) :: (store 8, align 4, addrspace 1)
; CHECK: G_STORE %div(<2 x s32>), %ptr2(p1) :: (store 8, 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 8, 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 8, 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: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK: %div:_(<4 x s32>), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %rem(<4 x s32>), %ptr1(p1) :: (store 16, align 4, addrspace 1)
; CHECK: G_STORE %div(<4 x s32>), %ptr2(p1) :: (store 16, 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 16, 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 16, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %div:_(s32), %rem:_ = G_UDIVREM %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_UREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, 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: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK: %div:_(<2 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK: G_STORE %div(<2 x s32>), %ptr1(p1) :: (store 8, align 4, addrspace 1)
; CHECK: G_STORE %rem(<2 x s32>), %ptr2(p1) :: (store 8, 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 8, 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 8, 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: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK: %div:_(<4 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK: G_STORE %div(<4 x s32>), %ptr1(p1) :: (store 16, align 4, addrspace 1)
; CHECK: G_STORE %rem(<4 x s32>), %ptr2(p1) :: (store 16, 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 16, 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 16, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %div:_(s32), %rem:_ = G_UDIVREM %src1, %src2
; CHECK: G_STORE %rem(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: G_STORE %div(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%div:_(s32) = G_UDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr2:_(p1) :: (store 4, 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: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
; CHECK: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
; CHECK: %ptr1:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %ptr2:_(p1) = COPY $vgpr6_vgpr7
; CHECK: %div:_(<2 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK: G_STORE %rem(<2 x s32>), %ptr1(p1) :: (store 8, align 4, addrspace 1)
; CHECK: G_STORE %div(<2 x s32>), %ptr2(p1) :: (store 8, 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 8, 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 8, 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: %src1:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
; CHECK: %src2:_(<4 x s32>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
; CHECK: %ptr1:_(p1) = COPY $vgpr8_vgpr9
; CHECK: %ptr2:_(p1) = COPY $vgpr10_vgpr11
; CHECK: %div:_(<4 x s32>), %rem:_ = G_UDIVREM %src1, %src2
; CHECK: G_STORE %rem(<4 x s32>), %ptr1(p1) :: (store 16, align 4, addrspace 1)
; CHECK: G_STORE %div(<4 x s32>), %ptr2(p1) :: (store 16, 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 16, 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 16, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = G_IMPLICIT_DEF
; CHECK: %ptr2:_(p1) = G_IMPLICIT_DEF
; CHECK: %ptr3:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr4:_(p1) = COPY $vgpr4_vgpr5
; CHECK: G_STORE %src1(s32), %ptr1(p1) :: (volatile store 4 into `i32 addrspace(1)* undef`, addrspace 1)
; CHECK: G_STORE %src2(s32), %ptr2(p1) :: (volatile store 4 into `i32 addrspace(1)* undef`, addrspace 1)
; CHECK: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %div(s32), %ptr3(p1) :: (store 4, addrspace 1)
; CHECK: G_STORE %rem(s32), %ptr4(p1) :: (store 4, 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 4 into `i32 addrspace(1)* undef`, addrspace 1)
G_STORE %src2:_(s32), %ptr2:_(p1) :: (volatile store 4 into `i32 addrspace(1)* undef`, addrspace 1)
%div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div:_(s32), %ptr3:_(p1) :: (store 4, addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr4:_(p1) :: (store 4, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %ptr3:_(p1) = COPY $vgpr6_vgpr7
; CHECK: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, addrspace 1)
; CHECK: %div2:_(s32) = G_SDIV %src1, %src2
; CHECK: G_STORE %div2(s32), %ptr3(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, addrspace 1, align 4)
%div2:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
G_STORE %div2:_(s32), %ptr3:_(p1) :: (store 4, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %ptr3:_(p1) = COPY $vgpr6_vgpr7
; CHECK: %div:_(s32), %rem:_ = G_SDIVREM %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, addrspace 1)
; CHECK: %rem2:_(s32) = G_SREM %src1, %src2
; CHECK: G_STORE %rem2(s32), %ptr3(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, addrspace 1, align 4)
%rem2:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem2:_(s32), %ptr3:_(p1) :: (store 4, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %src3:_(s32) = COPY $vgpr2
; CHECK: %ptr1:_(p1) = COPY $vgpr3_vgpr4
; CHECK: %ptr2:_(p1) = COPY $vgpr5_vgpr6
; CHECK: %div:_(s32) = G_SDIV %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: %rem:_(s32) = G_SREM %src1, %src3
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src3:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %div:_(s32) = G_SDIV %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: %rem:_(s32) = G_SREM %src2, %src1
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_SREM %src2:_(s32), %src1:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %div:_(s32) = G_SDIV %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: %rem:_(s32) = G_UREM %src1, %src2
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_UREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, 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: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %div:_(s32) = G_UDIV %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: %rem:_(s32) = G_SREM %src1, %src2
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, 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 4, addrspace 1, align 4)
%rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
G_STORE %rem:_(s32), %ptr2:_(p1) :: (store 4, 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: successors: %bb.1(0x80000000)
; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
; CHECK: %src1:_(s32) = COPY $vgpr0
; CHECK: %src2:_(s32) = COPY $vgpr1
; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
; CHECK: %div:_(s32) = G_SDIV %src1, %src2
; CHECK: G_STORE %div(s32), %ptr1(p1) :: (store 4, addrspace 1)
; CHECK: S_BRANCH %bb.1
; CHECK: bb.1:
; CHECK: liveins: $vgpr4_vgpr5
; CHECK: %ptr2:_(p1) = COPY $vgpr4_vgpr5
; CHECK: %rem:_(s32) = G_SREM %src1, %src2
; CHECK: G_STORE %rem(s32), %ptr2(p1) :: (store 4, 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 4, 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 4, addrspace 1, align 4)
...