google / google/clspv

Incorrect transforms for -hack-scf

Open
#1,041 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
LLVM
Stars
729
Forks
110
Avg merge
17h 51m
Merged PRs (30d)
23

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.