xref: /illumos-gate/usr/src/tools/smatch/src/validation/optim/shl-and1.c (revision fa4a3e77edc40df6d92e8da6fc4961d275e9896d)
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 shl_and1(unsigned x)
7 {
8 	unsigned t = (x & 0x000fffff);
9 	return ((t << 12) ^ (x << 12)) & t;
10 }
11 
12 /*
13  * check-name: shl-and1
14  * check-command: test-linearize -Wno-decl $file
15  *
16  * check-output-ignore
17  * check-output-contains: ret\\..*\\$0$
18  */
19