Files
TheRock/compiler/amd-llvm/llvm/test/Analysis/ValueTracking/knownbits-div.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

221 lines
6.0 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
define i1 @sdiv_neg_neg_high_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_neg_neg_high_bits(
; CHECK-NEXT: ret i1 false
;
%num = or i8 %x, 128
%denum = or i8 %y, 131
%div = sdiv i8 %num, %denum
%and = and i8 %div, 128
%r = icmp eq i8 %and, 128
ret i1 %r
}
define i1 @sdiv_pos_neg_high_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_pos_neg_high_bits(
; CHECK-NEXT: ret i1 false
;
%xx = and i8 %x, 127
%num = or i8 %xx, 49
%denum = or i8 %y, 241
%div = sdiv i8 %num, %denum
%and = and i8 %div, 128
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @sdiv_pos_neg_high_bits_fail_maybez(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_pos_neg_high_bits_fail_maybez(
; CHECK-NEXT: [[XX:%.*]] = and i8 [[X:%.*]], 127
; CHECK-NEXT: [[NUM:%.*]] = or i8 [[XX]], 49
; CHECK-NEXT: [[DENUM:%.*]] = or i8 [[Y:%.*]], -64
; CHECK-NEXT: [[DIV:%.*]] = sdiv i8 [[NUM]], [[DENUM]]
; CHECK-NEXT: [[AND:%.*]] = and i8 [[DIV]], -128
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%xx = and i8 %x, 127
%num = or i8 %xx, 49
%denum = or i8 %y, 192
%div = sdiv i8 %num, %denum
%and = and i8 %div, 128
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @sdiv_exact_pos_neg_high_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_exact_pos_neg_high_bits(
; CHECK-NEXT: ret i1 false
;
%xx = and i8 %x, 127
%num = or i8 %xx, 49
%denum = or i8 %y, 192
%div = sdiv exact i8 %num, %denum
%and = and i8 %div, 128
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @sdiv_neg_pos_high_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_neg_pos_high_bits(
; CHECK-NEXT: ret i1 false
;
%xx = and i8 %x, 159
%num = or i8 %xx, 129
%yy = and i8 %y, 15
%denum = or i8 %yy, 9
%div = sdiv i8 %num, %denum
%and = and i8 %div, 128
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @sdiv_neg_pos_high_bits_fail_maybez(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_neg_pos_high_bits_fail_maybez(
; CHECK-NEXT: [[NUM:%.*]] = or i8 [[X:%.*]], -128
; CHECK-NEXT: [[YY:%.*]] = and i8 [[Y:%.*]], 15
; CHECK-NEXT: [[DENUM:%.*]] = or i8 [[YY]], 9
; CHECK-NEXT: [[DIV:%.*]] = sdiv i8 [[NUM]], [[DENUM]]
; CHECK-NEXT: [[AND:%.*]] = and i8 [[DIV]], -128
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%num = or i8 %x, 128
%yy = and i8 %y, 15
%denum = or i8 %yy, 9
%div = sdiv i8 %num, %denum
%and = and i8 %div, 128
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @sdiv_exact_odd_odd(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_exact_odd_odd(
; CHECK-NEXT: ret i1 false
;
%num = or i8 %x, 1
%denum = or i8 %y, 1
%div = sdiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @sdiv_exact_even_odd(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_exact_even_odd(
; CHECK-NEXT: ret i1 false
;
%num = and i8 %x, -2
%denum = or i8 %y, 1
%div = sdiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 1
ret i1 %r
}
define i1 @sdiv_exact_even_even_fail_unknown(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_exact_even_even_fail_unknown(
; CHECK-NEXT: [[NUM:%.*]] = and i8 [[X:%.*]], -2
; CHECK-NEXT: [[DENUM:%.*]] = and i8 [[Y:%.*]], -2
; CHECK-NEXT: [[DIV:%.*]] = sdiv exact i8 [[NUM]], [[DENUM]]
; CHECK-NEXT: [[AND:%.*]] = and i8 [[DIV]], 1
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 1
; CHECK-NEXT: ret i1 [[R]]
;
%num = and i8 %x, -2
%denum = and i8 %y, -2
%div = sdiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 1
ret i1 %r
}
define i1 @sdiv_exact_even_even_fail_unknown2(i8 %x, i8 %y) {
; CHECK-LABEL: @sdiv_exact_even_even_fail_unknown2(
; CHECK-NEXT: [[NUM:%.*]] = and i8 [[X:%.*]], -2
; CHECK-NEXT: [[DENUM:%.*]] = and i8 [[Y:%.*]], -2
; CHECK-NEXT: [[DIV:%.*]] = sdiv exact i8 [[NUM]], [[DENUM]]
; CHECK-NEXT: [[AND:%.*]] = and i8 [[DIV]], 1
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%num = and i8 %x, -2
%denum = and i8 %y, -2
%div = sdiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @udiv_high_bits(i8 %x, i8 %y) {
; CHECK-LABEL: @udiv_high_bits(
; CHECK-NEXT: ret i1 false
;
%num = and i8 %x, 129
%denum = or i8 %y, 31
%div = udiv i8 %num, %denum
%and = and i8 %div, 8
%r = icmp eq i8 %and, 8
ret i1 %r
}
define i1 @udiv_exact_odd_odd(i8 %x, i8 %y) {
; CHECK-LABEL: @udiv_exact_odd_odd(
; CHECK-NEXT: ret i1 false
;
%num = or i8 %x, 1
%denum = or i8 %y, 1
%div = udiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 0
ret i1 %r
}
define i1 @udiv_exact_even_odd(i8 %x, i8 %y) {
; CHECK-LABEL: @udiv_exact_even_odd(
; CHECK-NEXT: ret i1 false
;
%num = and i8 %x, -2
%denum = or i8 %y, 1
%div = udiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 1
ret i1 %r
}
define i1 @udiv_exact_even_even_fail_unknown(i8 %x, i8 %y) {
; CHECK-LABEL: @udiv_exact_even_even_fail_unknown(
; CHECK-NEXT: [[NUM:%.*]] = and i8 [[X:%.*]], -2
; CHECK-NEXT: [[DENUM:%.*]] = and i8 [[Y:%.*]], -2
; CHECK-NEXT: [[DIV:%.*]] = udiv exact i8 [[NUM]], [[DENUM]]
; CHECK-NEXT: [[AND:%.*]] = and i8 [[DIV]], 1
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 1
; CHECK-NEXT: ret i1 [[R]]
;
%num = and i8 %x, -2
%denum = and i8 %y, -2
%div = udiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 1
ret i1 %r
}
define i1 @udiv_exact_even_even_fail_unknown2(i8 %x, i8 %y) {
; CHECK-LABEL: @udiv_exact_even_even_fail_unknown2(
; CHECK-NEXT: [[NUM:%.*]] = and i8 [[X:%.*]], -2
; CHECK-NEXT: [[DENUM:%.*]] = and i8 [[Y:%.*]], -2
; CHECK-NEXT: [[DIV:%.*]] = udiv exact i8 [[NUM]], [[DENUM]]
; CHECK-NEXT: [[AND:%.*]] = and i8 [[DIV]], 1
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%num = and i8 %x, -2
%denum = and i8 %y, -2
%div = udiv exact i8 %num, %denum
%and = and i8 %div, 1
%r = icmp eq i8 %and, 0
ret i1 %r
}