forked from OSchip/llvm-project
[SCEV] Recognize @llvm.usub.sat as `%x - (umin %x, %y)`
---------------------------------------- define i32 @src(i32 %x, i32 %y) { %0: %r = usub_sat i32 %x, %y ret i32 %r } => define i32 @tgt(i32 %x, i32 %y) { %0: %t0 = umin i32 %x, %y %r = sub nuw i32 %x, %t0 ret i32 %r } Transformation seems to be correct!
This commit is contained in:
parent
0592de550f
commit
fedc9549d5
|
@ -6359,6 +6359,12 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
|
|||
case Intrinsic::smin:
|
||||
return getSMinExpr(getSCEV(II->getArgOperand(0)),
|
||||
getSCEV(II->getArgOperand(1)));
|
||||
case Intrinsic::usub_sat: {
|
||||
const SCEV *X = getSCEV(II->getArgOperand(0));
|
||||
const SCEV *Y = getSCEV(II->getArgOperand(1));
|
||||
const SCEV *ClampedY = getUMinExpr(X, Y);
|
||||
return getMinusSCEV(X, ClampedY, SCEV::FlagNUW);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ define i32 @usub_sat(i32 %x, i32 %y) {
|
|||
; CHECK-LABEL: 'usub_sat'
|
||||
; CHECK-NEXT: Classifying expressions for: @usub_sat
|
||||
; CHECK-NEXT: %z = call i32 @llvm.usub.sat.i32(i32 %x, i32 %y)
|
||||
; CHECK-NEXT: --> %z U: full-set S: full-set
|
||||
; CHECK-NEXT: --> ((-1 * (%x umin %y)) + %x) U: full-set S: full-set
|
||||
; CHECK-NEXT: Determining loop execution counts for: @usub_sat
|
||||
;
|
||||
%z = call i32 @llvm.usub.sat.i32(i32 %x, i32 %y)
|
||||
|
|
Loading…
Reference in New Issue