xref: /illumos-gate/usr/src/tools/smatch/src/validation/optim/shl-and1.c (revision d48be21240dfd051b689384ce2b23479d757f2d8)
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