Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/MSP430/cmp-imm-high-bit.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

201 lines
5.0 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc -mtriple=msp430 < %s | FileCheck %s
; Regression tests for EmitCMP folding of LHS constants whose i16 high bit is
; set. These exercise the four EmitCMP branches that turn `c CMP rhs` into
; `rhs CMP' c+1`. The constant addition must use APInt arithmetic at the
; original bit width; computing it via getSExtValue() and then handing the
; resulting int64_t to getConstant(uint64_t, ..., MVT::i16) trips the
; isUIntN(16, val) assertion in the APInt constructor for any constant with
; bit 15 set.
define i16 @cmp_ule_high_bit(i16 %a) nounwind {
; CHECK-LABEL: cmp_ule_high_bit:
; CHECK: ; %bb.0:
; CHECK-NEXT: cmp #-32767, r12
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: bic r2, r12
; CHECK-NEXT: ret
%t = icmp ule i16 %a, 32768
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_ugt_high_bit(i16 %a) nounwind {
; CHECK-LABEL: cmp_ugt_high_bit:
; CHECK: ; %bb.0:
; CHECK-NEXT: cmp #-32767, r12
; CHECK-NEXT: mov r2, r12
; CHECK-NEXT: and #1, r12
; CHECK-NEXT: ret
%t = icmp ugt i16 %a, 32768
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_sle_neg_high_bit(i16 %a) nounwind {
; CHECK-LABEL: cmp_sle_neg_high_bit:
; CHECK: ; %bb.0:
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: cmp #-32766, r13
; CHECK-NEXT: jl .LBB2_2
; CHECK-NEXT: ; %bb.1:
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB2_2:
; CHECK-NEXT: ret
%t = icmp sle i16 %a, -32767
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_sgt_neg_high_bit(i16 %a) nounwind {
; CHECK-LABEL: cmp_sgt_neg_high_bit:
; CHECK: ; %bb.0:
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: cmp #-32766, r13
; CHECK-NEXT: jge .LBB3_2
; CHECK-NEXT: ; %bb.1:
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB3_2:
; CHECK-NEXT: ret
%t = icmp sgt i16 %a, -32767
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_ule_int_max(i16 %a) nounwind {
; CHECK-LABEL: cmp_ule_int_max:
; CHECK: ; %bb.0:
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: tst r13
; CHECK-NEXT: jge .LBB4_2
; CHECK-NEXT: ; %bb.1:
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB4_2:
; CHECK-NEXT: ret
%t = icmp ule i16 %a, 32767
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_ugt_int_max(i16 %a) nounwind {
; CHECK-LABEL: cmp_ugt_int_max:
; CHECK: ; %bb.0:
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: tst r13
; CHECK-NEXT: jl .LBB5_2
; CHECK-NEXT: ; %bb.1:
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB5_2:
; CHECK-NEXT: ret
%t = icmp ugt i16 %a, 32767
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_sle_int_max(i16 %a) nounwind {
; CHECK-LABEL: cmp_sle_int_max:
; CHECK: ; %bb.0:
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: ret
%t = icmp sle i16 %a, 32767
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_sgt_int_max(i16 %a) nounwind {
; CHECK-LABEL: cmp_sgt_int_max:
; CHECK: ; %bb.0:
; CHECK-NEXT: clr r12
; CHECK-NEXT: ret
%t = icmp sgt i16 %a, 32767
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_sle_int_min(i16 %a) nounwind {
; CHECK-LABEL: cmp_sle_int_min:
; CHECK: ; %bb.0:
; CHECK-NEXT: cmp #-32768, r12
; CHECK-NEXT: mov r2, r12
; CHECK-NEXT: rra r12
; CHECK-NEXT: and #1, r12
; CHECK-NEXT: ret
%t = icmp sle i16 %a, -32768
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_sgt_int_min(i16 %a) nounwind {
; CHECK-LABEL: cmp_sgt_int_min:
; CHECK: ; %bb.0:
; CHECK-NEXT: cmp #-32768, r12
; CHECK-NEXT: mov r2, r13
; CHECK-NEXT: rra r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: bic r13, r12
; CHECK-NEXT: ret
%t = icmp sgt i16 %a, -32768
%r = zext i1 %t to i16
ret i16 %r
}
define i16 @cmp_sgt_neg_one(i16 %a) nounwind {
; CHECK-LABEL: cmp_sgt_neg_one:
; CHECK: ; %bb.0:
; CHECK-NEXT: mov r12, r13
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: tst r13
; CHECK-NEXT: jge .LBB10_2
; CHECK-NEXT: ; %bb.1:
; CHECK-NEXT: clr r12
; CHECK-NEXT: .LBB10_2:
; CHECK-NEXT: ret
%t = icmp sgt i16 %a, -1
%r = zext i1 %t to i16
ret i16 %r
}
; The br_cc path goes through the same EmitCMP helper.
define i16 @br_ule_high_bit(i16 %a) nounwind {
; CHECK-LABEL: br_ule_high_bit:
; CHECK: ; %bb.0:
; CHECK-NEXT: cmp #-32767, r12
; CHECK-NEXT: jhs .LBB11_2
; CHECK-NEXT: ; %bb.1: ; %yes
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: ret
; CHECK-NEXT: .LBB11_2: ; %no
; CHECK-NEXT: clr r12
; CHECK-NEXT: ret
%t = icmp ule i16 %a, 32768
br i1 %t, label %yes, label %no
yes:
ret i16 1
no:
ret i16 0
}
define i16 @br_sle_neg_high_bit(i16 %a) nounwind {
; CHECK-LABEL: br_sle_neg_high_bit:
; CHECK: ; %bb.0:
; CHECK-NEXT: cmp #-32766, r12
; CHECK-NEXT: jge .LBB12_2
; CHECK-NEXT: ; %bb.1: ; %yes
; CHECK-NEXT: mov #1, r12
; CHECK-NEXT: ret
; CHECK-NEXT: .LBB12_2: ; %no
; CHECK-NEXT: clr r12
; CHECK-NEXT: ret
%t = icmp sle i16 %a, -32767
br i1 %t, label %yes, label %no
yes:
ret i16 1
no:
ret i16 0
}