int64_t PosVal = std::max(Val1, Val2);
int64_t NegVal = std::min(Val1, Val2);
- if (!((Val1 > Val2 && isLTorLE(CC1)) || (Val1 < Val2 && isLTorLE(CC2))) &&
+ if (!((Val1 > Val2 && isLTorLE(CC1)) || (Val1 < Val2 && isLTorLE(CC2))) ||
!isPowerOf2_64(PosVal + 1))
return false;
ret i32 %saturateUp
}
+; The interval is [0, k] but k+1 is not a power of 2
+define i32 @no_unsigned_sat_incorrect_constant2(i32 %x) #0 {
+; CHECK-LABEL: no_unsigned_sat_incorrect_constant2:
+; CHECK-NOT: usat
+entry:
+ %0 = icmp sgt i32 %x, 0
+ %saturateLow = select i1 %0, i32 %x, i32 0
+ %1 = icmp slt i32 %saturateLow, 8388609
+ %saturateUp = select i1 %1, i32 %saturateLow, i32 8388609
+ ret i32 %saturateUp
+}
+
; The interval is not [0, k]
define i32 @no_unsigned_sat_incorrect_interval(i32 %x) #0 {
; CHECK-LABEL: no_unsigned_sat_incorrect_interval: