Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/Hexagon/gen-pred-andn-orn.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

130 lines
3.4 KiB
LLVM

; RUN: llc -mtriple=hexagon -O2 < %s | FileCheck %s
; Test coverage for HexagonGenPredicate: exercise various predicate
; conversion paths including A4_andn/C2_andn, A4_orn/C2_orn,
; C2_cmpeqi==0 to C2_not, C4_cmpneqi==0 to COPY, and deeper
; predicate chains using various comparison types.
; CHECK-LABEL: test_pred_andn:
; CHECK: cmp
define i32 @test_pred_andn(i32 %a, i32 %b, i32 %c) {
entry:
%cmp1 = icmp sgt i32 %a, 0
%cmp2 = icmp sgt i32 %b, 0
%not2 = xor i1 %cmp2, true
%and = and i1 %cmp1, %not2
%sel = select i1 %and, i32 %a, i32 %c
ret i32 %sel
}
; CHECK-LABEL: test_pred_orn:
; CHECK: cmp
define i32 @test_pred_orn(i32 %a, i32 %b, i32 %c) {
entry:
%cmp1 = icmp sgt i32 %a, 0
%cmp2 = icmp sgt i32 %b, 0
%not2 = xor i1 %cmp2, true
%or = or i1 %cmp1, %not2
%sel = select i1 %or, i32 %a, i32 %c
ret i32 %sel
}
; Exercise a more complex predicate chain involving and_and (C4_and_and)
; and or_or (C4_or_or).
; CHECK-LABEL: test_pred_chain:
; CHECK: cmp
define i32 @test_pred_chain(i32 %a, i32 %b, i32 %c, i32 %d) {
entry:
%cmp1 = icmp sgt i32 %a, 0
%cmp2 = icmp sgt i32 %b, 0
%cmp3 = icmp sgt i32 %c, 0
%and12 = and i1 %cmp1, %cmp2
%and123 = and i1 %and12, %cmp3
%sel = select i1 %and123, i32 %d, i32 0
ret i32 %sel
}
; Predicate comparison against 0: exercise C2_cmpeqi path.
; CHECK-LABEL: test_pred_cmp0:
; CHECK: cmp
define i32 @test_pred_cmp0(i32 %a, i32 %b) {
entry:
%cmp = icmp eq i32 %a, 0
%ext = zext i1 %cmp to i32
%and = and i32 %ext, %b
ret i32 %and
}
; Test cmpeq with 0 feeding into predicate logic (triggers C2_cmpeqi
; == 0 conversion path).
; CHECK-LABEL: test_cmpeq_zero:
; CHECK: cmp
define i32 @test_cmpeq_zero(i32 %a, i32 %b, i32 %x, i32 %y) {
entry:
%c1 = icmp eq i32 %a, 0
%c2 = icmp sgt i32 %b, 0
%and = and i1 %c1, %c2
%sel = select i1 %and, i32 %x, i32 %y
ret i32 %sel
}
; Test ne with 0 feeding into predicate logic (triggers C4_cmpneqi
; == 0 conversion path).
; CHECK-LABEL: test_cmpne_zero:
; CHECK: cmp
define i32 @test_cmpne_zero(i32 %a, i32 %b, i32 %x, i32 %y) {
entry:
%c1 = icmp ne i32 %a, 0
%c2 = icmp sgt i32 %b, 0
%and = and i1 %c1, %c2
%sel = select i1 %and, i32 %x, i32 %y
ret i32 %sel
}
; Test deeper predicate chain with multiple comparison types:
; signed ge and signed le (exercises C2_cmpgei / C4_cmpltei paths).
; CHECK-LABEL: test_deep_pred_chain:
; CHECK: cmp
define i32 @test_deep_pred_chain(i32 %a, i32 %b, i32 %c, i32 %d, i32 %x, i32 %y) {
entry:
%c1 = icmp sge i32 %a, 10
%c2 = icmp sle i32 %b, 20
%c3 = icmp uge i32 %c, 5
%c4 = icmp sgt i32 %d, 0
%and1 = and i1 %c1, %c2
%and2 = and i1 %c3, %c4
%or = or i1 %and1, %and2
%sel = select i1 %or, i32 %x, i32 %y
ret i32 %sel
}
; Test predicate OR-NOT chain (exercises C2_orn path in GenPredicate).
; CHECK-LABEL: test_pred_orn_chain:
; CHECK: cmp
define i32 @test_pred_orn_chain(i32 %a, i32 %b, i32 %c, i32 %x, i32 %y) {
entry:
%c1 = icmp sgt i32 %a, 0
%c2 = icmp sgt i32 %b, 0
%c3 = icmp eq i32 %c, 0
%not = xor i1 %c2, true
%or = or i1 %c1, %not
%and = and i1 %or, %c3
%sel = select i1 %and, i32 %x, i32 %y
ret i32 %sel
}
; Test byte comparisons to exercise A4_cmpb* in isScalarCmp.
; CHECK-LABEL: test_byte_cmp:
; CHECK: cmp
define i32 @test_byte_cmp(i32 %a, i32 %b, i32 %x, i32 %y) {
entry:
%a8 = and i32 %a, 255
%b8 = and i32 %b, 255
%c1 = icmp eq i32 %a8, %b8
%c2 = icmp ugt i32 %a8, 10
%and = and i1 %c1, %c2
%sel = select i1 %and, i32 %x, i32 %y
ret i32 %sel
}