Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/InstCombine/icmp-fsh.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

183 lines
5.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
declare i8 @llvm.fshl.i8(i8, i8, i8)
declare i8 @llvm.fshr.i8(i8, i8, i8)
declare <2 x i5> @llvm.fshl.v2i5(<2 x i5>, <2 x i5>, <2 x i5>)
declare void @use(i8)
define i1 @rotl_eq_0(i8 %x, i8 %y) {
; CHECK-LABEL: @rotl_eq_0(
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %y)
%r = icmp eq i8 %rot, 0
ret i1 %r
}
; Extra use is ok.
define i1 @rotl_ne_0(i8 %x, i8 %y) {
; CHECK-LABEL: @rotl_ne_0(
; CHECK-NEXT: [[ROT:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
; CHECK-NEXT: call void @use(i8 [[ROT]])
; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[X]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %y)
call void @use(i8 %rot)
%r = icmp ne i8 %rot, 0
ret i1 %r
}
define i1 @rotl_eq_n1(i8 %x, i8 %y) {
; CHECK-LABEL: @rotl_eq_n1(
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X:%.*]], -1
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %y)
%r = icmp eq i8 %rot, -1
ret i1 %r
}
; Vectors work too.
define <2 x i1> @rotl_ne_n1(<2 x i5> %x, <2 x i5> %y) {
; CHECK-LABEL: @rotl_ne_n1(
; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i5> [[X:%.*]], splat (i5 -1)
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%rot = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5>%x, <2 x i5> %x, <2 x i5> %y)
%r = icmp ne <2 x i5> %rot, <i5 -1, i5 -1>
ret <2 x i1> %r
}
define <2 x i1> @rotl_ne_n1_poison(<2 x i5> %x, <2 x i5> %y) {
; CHECK-LABEL: @rotl_ne_n1_poison(
; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i5> [[X:%.*]], <i5 -1, i5 poison>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%rot = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5>%x, <2 x i5> %x, <2 x i5> %y)
%r = icmp ne <2 x i5> %rot, <i5 -1, i5 poison>
ret <2 x i1> %r
}
define <2 x i1> @rotl_eq_0_poison(<2 x i5> %x, <2 x i5> %y) {
; CHECK-LABEL: @rotl_eq_0_poison(
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i5> [[X:%.*]], <i5 0, i5 poison>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%rot = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5>%x, <2 x i5> %x, <2 x i5> %y)
%r = icmp eq <2 x i5> %rot, <i5 0, i5 poison>
ret <2 x i1> %r
}
; negative test - wrong constant value
define <2 x i1> @rotl_eq_1_poison(<2 x i5> %x, <2 x i5> %y) {
; CHECK-LABEL: @rotl_eq_1_poison(
; CHECK-NEXT: [[ROT:%.*]] = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5> [[X:%.*]], <2 x i5> [[X]], <2 x i5> [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i5> [[ROT]], <i5 poison, i5 1>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%rot = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5>%x, <2 x i5> %x, <2 x i5> %y)
%r = icmp eq <2 x i5> %rot, <i5 poison, i5 1>
ret <2 x i1> %r
}
; negative test - wrong predicate
define <2 x i1> @rotl_sgt_0_poison(<2 x i5> %x, <2 x i5> %y) {
; CHECK-LABEL: @rotl_sgt_0_poison(
; CHECK-NEXT: [[ROT:%.*]] = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5> [[X:%.*]], <2 x i5> [[X]], <2 x i5> [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = icmp sgt <2 x i5> [[ROT]], <i5 0, i5 poison>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%rot = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5>%x, <2 x i5> %x, <2 x i5> %y)
%r = icmp sgt <2 x i5> %rot, <i5 0, i5 poison>
ret <2 x i1> %r
}
define i1 @rotr_eq_0(i8 %x, i8 %y) {
; CHECK-LABEL: @rotr_eq_0(
; CHECK-NEXT: [[ROT:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
; CHECK-NEXT: call void @use(i8 [[ROT]])
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %y)
call void @use(i8 %rot)
%r = icmp eq i8 %rot, 0
ret i1 %r
}
define i1 @rotr_ne_0(i8 %x, i8 %y) {
; CHECK-LABEL: @rotr_ne_0(
; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %y)
%r = icmp ne i8 %rot, 0
ret i1 %r
}
define i1 @rotr_eq_n1(i8 %x, i8 %y) {
; CHECK-LABEL: @rotr_eq_n1(
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X:%.*]], -1
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %y)
%r = icmp eq i8 %rot, -1
ret i1 %r
}
define i1 @rotr_ne_n1(i8 %x, i8 %y) {
; CHECK-LABEL: @rotr_ne_n1(
; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[X:%.*]], -1
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %y)
%r = icmp ne i8 %rot, -1
ret i1 %r
}
; negative test - wrong constant value
define i1 @rotr_ne_1(i8 %x, i8 %y) {
; CHECK-LABEL: @rotr_ne_1(
; CHECK-NEXT: [[ROT:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[ROT]], 1
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %y)
%r = icmp ne i8 %rot, 1
ret i1 %r
}
; negative test - wrong predicate
define i1 @rotr_sgt_n1(i8 %x, i8 %y) {
; CHECK-LABEL: @rotr_sgt_n1(
; CHECK-NEXT: [[ROT:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[ROT]], -1
; CHECK-NEXT: ret i1 [[R]]
;
%rot = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %y)
%r = icmp sgt i8 %rot, -1
ret i1 %r
}
; negative test - must be a rotate, not general funnel shift
define i1 @fshr_sgt_n1(i8 %x, i8 %y, i8 %z) {
; CHECK-LABEL: @fshr_sgt_n1(
; CHECK-NEXT: [[FSH:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 [[Z:%.*]])
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[FSH]], -1
; CHECK-NEXT: ret i1 [[R]]
;
%fsh = tail call i8 @llvm.fshr.i8(i8 %x, i8 %y, i8 %z)
%r = icmp eq i8 %fsh, -1
ret i1 %r
}