[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic
Bevin Hansson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 9 00:07:07 PDT 2018
ebevhan added a comment.
Here is a module with the function right after expansion. This is generated for x86 and not our target so both this IR and the result will probably be slightly different than what I posted.
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define signext i16 @ac(i24 signext %a, i32 %n) #0 {
entry:
%a.addr = alloca i24, align 4
%n.addr = alloca i32, align 4
%s = alloca i24, align 4
%i = alloca i32, align 4
store i24 %a, i24* %a.addr, align 4
store i32 %n, i32* %n.addr, align 4
%0 = load i24, i24* %a.addr, align 4
%cmp = icmp slt i24 %0, 0
br i1 %cmp, label %cond.true, label %cond.false
cond.true: ; preds = %entry
br label %cond.end
cond.false: ; preds = %entry
%1 = load i24, i24* %a.addr, align 4
br label %cond.end
cond.end: ; preds = %cond.false, %cond.true
%cond = phi i24 [ 0, %cond.true ], [ %1, %cond.false ]
store i24 %cond, i24* %a.addr, align 4
store i24 0, i24* %s, align 4
store i32 0, i32* %i, align 4
br label %for.cond
for.cond: ; preds = %for.inc, %cond.end
%2 = load i32, i32* %i, align 4
%3 = load i32, i32* %n.addr, align 4
%cmp1 = icmp ult i32 %2, %3
br i1 %cmp1, label %for.body, label %for.end
for.body: ; preds = %for.cond
%4 = load i24, i24* %a.addr, align 4
%too_large = icmp sgt i24 %4, 32767
%too_small = icmp slt i24 %4, -32768
%5 = select i1 %too_small, i24 -32768, i24 %4
%6 = select i1 %too_large, i24 32767, i24 %5
%resize = trunc i24 %6 to i16
%resize2 = sext i16 %resize to i24
%7 = load i24, i24* %s, align 4
%add = add i24 %7, %resize2
store i24 %add, i24* %s, align 4
br label %for.inc
for.inc: ; preds = %for.body
%8 = load i32, i32* %i, align 4
%inc = add i32 %8, 1
store i32 %inc, i32* %i, align 4
br label %for.cond
for.end: ; preds = %for.cond
%9 = load i24, i24* %s, align 4
%too_large4 = icmp sgt i24 %9, 32767
%too_small5 = icmp slt i24 %9, -32768
%10 = select i1 %too_small5, i24 -32768, i24 %9
%11 = select i1 %too_large4, i24 32767, i24 %10
%resize3 = trunc i24 %11 to i16
ret i16 %resize3
}
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
Repository:
rL LLVM
https://reviews.llvm.org/D52286
More information about the llvm-commits
mailing list