xref: /illumos-gate/usr/src/tools/smatch/src/validation/optim/lsr-and1.c (revision 4e5ef1cee66fbfbbd2b3e56b81e2bb5700f4a59e)
1 // If (t >> S) is simplified into (x >> S)
2 // then the whole expression will be 0.
3 // The test is only interesting if the sub-expression
4 // (x & M) is referenced more than once
5 // (because otherwise other simplifications apply).
6 unsigned lsr_and1(unsigned x)
7 {
8 	unsigned t = (x & 0xfffff000);
9 	return ((t >> 12) ^ (x >> 12)) & t;
10 }
11 
12 /*
13  * check-name: lsr-and1
14  * check-command: test-linearize -Wno-decl $file
15  *
16  * check-output-ignore
17  * check-output-contains: ret\\..*\\$0$
18  */
19