1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00
llvm-mirror/test/Transforms/ConstraintElimination/decompose-with-temporary-indices.ll
Florian Hahn 3bee029727 [ConstraintElimination] Improve index handing during constraint building.
This patch improves the index management during constraint building.
Previously, the code rejected constraints which used values that were not
part of Value2Index, but after combining the coefficients of the new
indices were 0 (if ShouldAdd was 0).

In those cases, no new indices need to be added. Instead of adding to
Value2Index directly, add new indices to the NewIndices map. The caller
can then check if it needs to add any new indices.

This enables checking constraints like `a + x <= a + n` to `x <= n`,
even if there is no constraint for `a` directly.
2021-02-08 13:05:13 +00:00

74 lines
2.7 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -constraint-elimination -S %s | FileCheck %s
declare void @use(i1)
define void @test_uge_temporary_indices_decompose(i8 %start, i8 %n, i8 %idx) {
; CHECK-LABEL: @test_uge_temporary_indices_decompose(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CMP_PRE:%.*]] = icmp ult i8 [[IDX:%.*]], [[N:%.*]]
; CHECK-NEXT: [[START_ADD_IDX:%.*]] = add nuw nsw i8 [[START:%.*]], [[IDX]]
; CHECK-NEXT: [[START_ADD_N:%.*]] = add nuw nsw i8 [[START]], [[N]]
; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw nsw i8 [[START]], 1
; CHECK-NEXT: br i1 [[CMP_PRE]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: [[T_0:%.*]] = icmp ult i8 [[START_ADD_IDX]], [[START_ADD_N]]
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: [[F_0:%.*]] = icmp uge i8 [[START_ADD_IDX]], [[START_ADD_N]]
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_ADD_1]], [[START_ADD_N]]
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: [[C_2:%.*]] = icmp ult i8 [[START_ADD_IDX]], [[START_ADD_1]]
; CHECK-NEXT: call void @use(i1 [[C_2]])
; CHECK-NEXT: ret void
; CHECK: if.end:
; CHECK-NEXT: [[F_1:%.*]] = icmp ult i8 [[START_ADD_IDX]], [[START_ADD_N]]
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[T_1:%.*]] = icmp uge i8 [[START_ADD_IDX]], [[START_ADD_N]]
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: [[C_3:%.*]] = icmp ult i8 [[START_ADD_1]], [[START_ADD_N]]
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: [[C_4:%.*]] = icmp ult i8 [[START_ADD_IDX]], [[START_ADD_1]]
; CHECK-NEXT: call void @use(i1 [[C_4]])
; CHECK-NEXT: ret void
;
entry:
%cmp.pre = icmp ult i8 %idx, %n
%start.add.idx = add nuw nsw i8 %start, %idx
%start.add.n = add nuw nsw i8 %start, %n
%start.add.1 = add nuw nsw i8 %start, 1
br i1 %cmp.pre, label %if.then, label %if.end
if.then: ; preds = %entry
%t.0 = icmp ult i8 %start.add.idx, %start.add.n
call void @use(i1 %t.0)
%f.0 = icmp uge i8 %start.add.idx, %start.add.n
call void @use(i1 %f.0)
%c.1 = icmp ult i8 %start.add.1, %start.add.n
call void @use(i1 %c.1)
%c.2 = icmp ult i8 %start.add.idx, %start.add.1
call void @use(i1 %c.2)
ret void
if.end: ; preds = %entry
%f.1 = icmp ult i8 %start.add.idx, %start.add.n
call void @use(i1 %f.1)
%t.1 = icmp uge i8 %start.add.idx, %start.add.n
call void @use(i1 %t.1)
%c.3 = icmp ult i8 %start.add.1, %start.add.n
call void @use(i1 %c.3)
%c.4 = icmp ult i8 %start.add.idx, %start.add.1
call void @use(i1 %c.4)
ret void
}