@@ -43,6 +43,23 @@ newtype TValueNumber =
4343 } or
4444 TUniqueValueNumber ( IRFunction irFunc , Instruction instr ) { uniqueValueNumber ( instr , irFunc ) }
4545
46+ /**
47+ * A `ConvertInstruction` which converts data of type `T` to data of type `U`
48+ * where `T` and `U` only differ in specifiers. For example, if `T` is `int`
49+ * and `U` is `const T` this is a conversion from a non-const integer to a
50+ * const integer.
51+ *
52+ * Generally, the value number of a converted value is different from the value
53+ * number of an unconverted value, but for conversions which only modify
54+ * specifiers leaves the resulting value bitwise identical to the old value.
55+ */
56+ class SpecifierPreservingConvertInstruction extends ConvertInstruction {
57+ SpecifierPreservingConvertInstruction ( ) {
58+ pragma [ only_bind_out ] ( this .getResultType ( ) .getUnspecifiedType ( ) ) =
59+ pragma [ only_bind_out ] ( this .getUnary ( ) .getResultType ( ) .getUnspecifiedType ( ) )
60+ }
61+ }
62+
4663/**
4764 * A `CopyInstruction` whose source operand's value is congruent to the definition of that source
4865 * operand.
@@ -216,6 +233,7 @@ private predicate unaryValueNumber(
216233 not instr instanceof InheritanceConversionInstruction and
217234 not instr instanceof CopyInstruction and
218235 not instr instanceof FieldAddressInstruction and
236+ not instr instanceof SpecifierPreservingConvertInstruction and
219237 instr .getOpcode ( ) = opcode and
220238 tvalueNumber ( instr .getUnary ( ) ) = operand
221239}
@@ -351,6 +369,10 @@ private TValueNumber nonUniqueValueNumber(Instruction instr) {
351369 or
352370 // The value number of a copy is just the value number of its source value.
353371 result = tvalueNumber ( instr .( CongruentCopyInstruction ) .getSourceValue ( ) )
372+ or
373+ // The value number of a specifier-preserving conversion is just the value
374+ // number of the unconverted value.
375+ result = tvalueNumber ( instr .( SpecifierPreservingConvertInstruction ) .getUnary ( ) )
354376 )
355377 )
356378}
0 commit comments