[llvm] [HashRecognize] Rewrite arePHIsIntertwined (PR #144878)
Piotr Fusik via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 08:51:43 PDT 2025
pfusik wrote:
Thank you for your last paragraph.
My concern is that we could miscompile this specially crafted code:
```
%evil.xor = xor i8 %data, %crc.trunc
%zero = some value that is known to be zero
%evil.mul = mul i8, %evil.xor, %zero
%xor.data.crc = xor i8 %evil.mul, %crc.trunc
%and.data.crc = and i8 %xor.data.crc, 1
%data.next = lshr i8 %data, 1
%check.sb = icmp eq i8 %and.data.crc, 0
%crc.lshr = lshr i16 %crc, 1
%xor = xor i16 %crc.lshr, -24575
%crc.next = select i1 %check.sb, i16 %crc.lshr, i16 %xor
```
`isConditionalOnXorOfPHIs` will match `%evil.xor`, CRC computation appears correct because of `%xor.data.crc`, the loop doesn't use `%data` for CRC computation yet we incorrectly report LHSAux.
https://github.com/llvm/llvm-project/pull/144878
More information about the llvm-commits
mailing list