Files
clang-p2996/llvm/test/Transforms/ConstraintElimination/i128.ll
Florian Hahn 0a781d98fb [ConstraintElimination] Add initial signed support.
This patch adds initial support for signed conditions. To do so,
ConstraintElimination maintains two separate systems, one with facts
from signed and one for unsigned conditions.

To start with this means information from signed and unsigned conditions
is kept completely separate. When it is safe to do so, information from
signed conditions may be also transferred to the unsigned system and
vice versa. That's left for follow-ups.

In the initial version, de-composition of signed values just handles
constants and otherwise just uses the value, without trying to
decompose the operation. Again this can be extended in follow-up
changes.

The main benefit of this limited signed support is proving >=s 0
pre-conditions added in D118799. But even this initial version also
fixes PR53273.

Depends on D118799.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D118806
2022-02-04 14:02:48 +00:00

72 lines
2.3 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
declare void @use(i1)
define void @test_unsigned_too_large(i128 %x) {
; CHECK-LABEL: @test_unsigned_too_large(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i128 [[X:%.*]], 12345678901234123123123
; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[C_2:%.*]] = icmp ult i128 [[X]], -12345678901234123123123
; CHECK-NEXT: call void @use(i1 [[C_2]])
; CHECK-NEXT: [[C_3:%.*]] = icmp uge i128 [[X]], -12345678901234123123123
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: [[C_4:%.*]] = icmp uge i128 [[X]], -12345678901234123123123
; CHECK-NEXT: call void @use(i1 [[C_4]])
; CHECK-NEXT: ret void
; CHECK: bb2:
; CHECK-NEXT: ret void
;
entry:
%c.1 = icmp ule i128 %x, 12345678901234123123123
br i1 %c.1, label %bb1, label %bb2
bb1:
%c.2 = icmp ult i128 %x, -12345678901234123123123
call void @use(i1 %c.2)
%c.3 = icmp uge i128 %x, -12345678901234123123123
call void @use(i1 %c.3)
%c.4 = icmp uge i128 %x, -12345678901234123123123
call void @use(i1 %c.4)
ret void
bb2:
ret void
}
define void @test_signed_too_large(i128 %x) {
; CHECK-LABEL: @test_signed_too_large(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[C_1:%.*]] = icmp sle i128 [[X:%.*]], 12345678901234123123123
; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[C_2:%.*]] = icmp slt i128 [[X]], -12345678901234123123123
; CHECK-NEXT: call void @use(i1 [[C_2]])
; CHECK-NEXT: [[C_3:%.*]] = icmp sge i128 [[X]], -12345678901234123123123
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: [[C_4:%.*]] = icmp sge i128 [[X]], -12345678901234123123123
; CHECK-NEXT: call void @use(i1 [[C_4]])
; CHECK-NEXT: ret void
; CHECK: bb2:
; CHECK-NEXT: ret void
;
entry:
%c.1 = icmp sle i128 %x, 12345678901234123123123
br i1 %c.1, label %bb1, label %bb2
bb1:
%c.2 = icmp slt i128 %x, -12345678901234123123123
call void @use(i1 %c.2)
%c.3 = icmp sge i128 %x, -12345678901234123123123
call void @use(i1 %c.3)
%c.4 = icmp sge i128 %x, -12345678901234123123123
call void @use(i1 %c.4)
ret void
bb2:
ret void
}