Files
clang-p2996/polly/test/ScopInfo/unsigned_wrap_ule.ll
Michael Kruse 0865585eab [ScopInfo] Add support for wrap-around of integers in unsigned comparisons.
This is one possible solution to implement wrap-arounds for integers in
unsigned icmp operations. For example,

    store i32 -1, i32* %A_addr
    %0 = load i32, i32* %A_addr
    %1 = icmp ult i32 %0, 0

%1 should hold false, because under the assumption of unsigned integers,
-1 should wrap around to 2^32-1. However, previously. it was assumed
that the MSB (Most Significant Bit - aka the Sign bit) was never set for
integers in unsigned operations.

This patch modifies the buildConditionSets function in ScopInfo.cpp to
give better information about the integers in these unsigned
comparisons.

Contributed-by: Annanay Agarwal <cs14btech11001@iith.ac.in>

Differential Revision: https://reviews.llvm.org/D35464

llvm-svn: 308608
2017-07-20 12:37:02 +00:00

47 lines
891 B
LLVM

; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
;
; Unsigned wrap-around check.
;
; for (int i = -1; i < 65 ; i ++ )
; if ( (unsigned)i <= 63 )
; A[i] = 42;
define void @func(double* noalias nonnull %A) {
entry:
br label %for
for:
%j = phi i32 [-1, %entry], [%j.inc, %inc]
%j.cmp = icmp slt i32 %j, 65
br i1 %j.cmp, label %body, label %exit
body:
%inbounds = icmp ule i32 %j, 63
br i1 %inbounds, label %ifinbounds, label %ifoutbounds
ifinbounds:
%A_idx = getelementptr inbounds double, double* %A, i32 %j
store double 42.0, double* %A_idx
br label %inc
ifoutbounds:
br label %inc
inc:
%j.inc = add nuw nsw i32 %j, 1
br label %for
exit:
br label %return
return:
ret void
}
; CHECK: Region: %for---%return
; CHECK: Domain :=
; CHECK-NEXT: { Stmt_ifinbounds[i0] : 0 < i0 <= 64 };