No need to offset the shift value when the offset is 0

This commit is contained in:
Sam Harwell 2012-11-27 08:36:04 -06:00
parent 7c5ec45054
commit ad242a0c7a
1 changed files with 10 additions and 1 deletions

View File

@ -463,7 +463,16 @@ testShiftInRange(shiftAmount) ::= <<
// produces smaller bytecode only when bits.ttypes contains more than two items
bitsetBitfieldComparison(s, bits) ::= <%
(<testShiftInRange({<s.varName> - <bits.shift>})> && ((1L \<\< (<s.varName> - <bits.shift>)) & (<bits.ttypes:{ttype | (1L \<\< (<ttype> - <bits.shift>))}; separator=" | ">)) != 0)
(<testShiftInRange({<offsetShift(s.varName, bits.shift)>})> && ((1L \<\< <offsetShift(s.varName, bits.shift)>) & (<bits.ttypes:{ttype | (1L \<\< <offsetShift(ttype, bits.shift)>)}; separator=" | ">)) != 0)
%>
isZero ::= [
"0":true,
default:false
]
offsetShift(shiftAmount, offset) ::= <%
<if(!isZero.(offset))>(<shiftAmount> - <offset>)<else><shiftAmount><endif>
%>
// produces more efficient bytecode when bits.ttypes contains at most two items