[SCEV] Recognize @llvm.usub.sat as `%x - (umin %x, %y)`
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 21 Sep 2020 15:05:47 +0000 (18:05 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 21 Sep 2020 17:25:54 +0000 (20:25 +0300)
commitfedc9549d50d80f74169ecce4d0d0648a62249f0
tree7c09c86fc99d9e7aa7ce79f5b0327542d0e08028
parent0592de550f5c9ca9de44ed2c5c549f6a3b1c32b7
[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!
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/saturating-intrinsics.ll