clspv
clspv copied to clipboard
Incorrect transforms for -hack-scf
Recently uncovered this testing abs_diff. The transformations in the pass are not safe if overflow occurs. For example signed greater than (a > b) is implemented as:
%sub = sub i32 %a, %b
%sub1 = sub i32 %sub, 1
%and = and i32 %sub1, 0x80000000
%eq = OpIEqual i32 %and, 0
Here is a problematic 8-bit case:
a = 0x7f
b = 0x8f
%sub = 0xf0
%sub1 = 0xef
%and = 0x80
%eq = false
The transform needs to handle more cases in case of potential wrapping.