ir: Fix shift overflow in AND(SHR, C) constant folding#148
Conversation
|
This seems right! How did you find the problem. |
|
I understood. Could you please modify the test. |
The redundancy rules for AND of a shifted value against a mask computed the shifted all ones value without masking the shift count, which is undefined behavior when the count reaches the type width. Mask the shift count per type width to match the existing SHR constant folding. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
|
Thanks for checking. I've been experimenting with a fuzzer that goes beyond the text parser and mutates the IR data structures directly. This was found by an early prototype run under a UBSan build. On the test, I initially chose Thanks! |
368198e to
3b6492d
Compare
|
@dstogov the test is rewritten with Thanks |
The redundancy rules for AND of a shifted value against a mask computed the shifted all ones value without masking the shift count, which is undefined behavior when the count reaches the type width.
Mask the shift count per type width to match the existing SHR constant folding.