blob: 72d5a4ed6bda83f2629129c93473fc59e4687313 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
; Fold icmp samesign of a sext vs a constant not representable in the source
; type. Poison from a sign mismatch may be refined to the matching-sign result.
; https://github.com/llvm/llvm-project/issues/216058
define i1 @samesign_ule_sext_i16_smax(i16 %x) {
; CHECK-LABEL: @samesign_ule_sext_i16_smax(
; CHECK-NEXT: ret i1 true
;
%e = sext i16 %x to i32
%c = icmp samesign ule i32 %e, 2147483647
ret i1 %c
}
define i1 @samesign_ult_sext_i16_smax(i16 %x) {
; CHECK-LABEL: @samesign_ult_sext_i16_smax(
; CHECK-NEXT: ret i1 true
;
%e = sext i16 %x to i32
%c = icmp samesign ult i32 %e, 2147483647
ret i1 %c
}
define i1 @samesign_uge_sext_i16_smin(i16 %x) {
; CHECK-LABEL: @samesign_uge_sext_i16_smin(
; CHECK-NEXT: ret i1 true
;
%e = sext i16 %x to i32
%c = icmp samesign uge i32 %e, -2147483648
ret i1 %c
}
define i1 @samesign_ugt_sext_i16_smin(i16 %x) {
; CHECK-LABEL: @samesign_ugt_sext_i16_smin(
; CHECK-NEXT: ret i1 true
;
%e = sext i16 %x to i32
%c = icmp samesign ugt i32 %e, -2147483648
ret i1 %c
}
define i1 @samesign_uge_sext_i16_smax(i16 %x) {
; CHECK-LABEL: @samesign_uge_sext_i16_smax(
; CHECK-NEXT: ret i1 false
;
%e = sext i16 %x to i32
%c = icmp samesign uge i32 %e, 2147483647
ret i1 %c
}
define i1 @samesign_ule_sext_i16_smin(i16 %x) {
; CHECK-LABEL: @samesign_ule_sext_i16_smin(
; CHECK-NEXT: ret i1 false
;
%e = sext i16 %x to i32
%c = icmp samesign ule i32 %e, -2147483648
ret i1 %c
}
; Without samesign the unsigned compare still depends on the sign of X.
define i1 @ule_sext_i16_smax(i16 %x) {
; CHECK-LABEL: @ule_sext_i16_smax(
; CHECK-NEXT: [[E:%.*]] = sext i16 [[X:%.*]] to i32
; CHECK-NEXT: [[C:%.*]] = icmp ule i32 [[E]], 2147483647
; CHECK-NEXT: ret i1 [[C]]
;
%e = sext i16 %x to i32
%c = icmp ule i32 %e, 2147483647
ret i1 %c
}