@@ -40,15 +40,25 @@ IRTempVariable getIRTempVariable(Locatable ast, TempVariableTag tag) {
4040 result .getTag ( ) = tag
4141}
4242
43- /** Gets an operand of `binOp `. */
44- private Expr getAnOperand ( BinaryOperation binOp ) { result = binOp .getAnOperand ( ) }
43+ /** Gets an operand of `op `. */
44+ private Expr getAnOperand ( Operation op ) { result = op .getAnOperand ( ) }
4545
4646/**
47- * Gets the number of nested operands of `binOp `. For example,
47+ * Gets the number of nested operands of `op `. For example,
4848 * `getNumberOfNestedBinaryOperands((1 + 2) + 3))` is `3`.
4949 */
50- private int getNumberOfNestedBinaryOperands ( BinaryOperation binOp ) {
51- result = count ( getAnOperand * ( binOp ) )
50+ private int getNumberOfNestedBinaryOperands ( Operation op ) { result = count ( getAnOperand * ( op ) ) }
51+
52+ /**
53+ * Holds if `op` should not be translated to a `ConstantInstruction` as part of
54+ * IR generation, even if the value of `op` is constant.
55+ */
56+ private predicate ignoreConstantValue ( Operation op ) {
57+ op instanceof BitwiseAndExpr
58+ or
59+ op instanceof BitwiseOrExpr
60+ or
61+ op instanceof BitwiseXorExpr
5262}
5363
5464/**
@@ -58,14 +68,14 @@ private int getNumberOfNestedBinaryOperands(BinaryOperation binOp) {
5868 */
5969predicate isIRConstant ( Expr expr ) {
6070 exists ( expr .getValue ( ) ) and
61- // We avoid constant folding binary operations since it's often useful to
71+ // We avoid constant folding certain operations since it's often useful to
6272 // mark one of those as a source in dataflow, and if the operation is
6373 // constant folded it's not possible to mark its operands as a source (or
6474 // sink).
6575 // But to avoid creating an outrageous amount of IR from very large
6676 // constant expressions we fall back to constant folding if the operation
6777 // has more than 50 operands (i.e., 1 + 2 + 3 + 4 + ... + 50)
68- if expr instanceof BinaryOperation then getNumberOfNestedBinaryOperands ( expr ) > 50 else any ( )
78+ if ignoreConstantValue ( expr ) then getNumberOfNestedBinaryOperands ( expr ) > 50 else any ( )
6979}
7080
7181// Pulled out for performance. See
0 commit comments