[PATCH] [InstCombine] call SimplifyICmpInst with correct context

David Majnemer david.majnemer at gmail.com
Wed Jun 24 10:51:01 PDT 2015

It looks like `SimplifyICmpInst` calls `ComputeSignBit` with one of the `ICmpInst` operands.  `ComputeSignBit` uses `safeCxtI` to determine which value to use for the context: if a context isn't explicitly specified, the value being interrogated is used as the context.

ISTM that the issue is that the `ComputeSignBit` interface has no mechanism to say "I don't have a context".  One way of fixing this issue at the API boundary is to make the `CxtI` in ValueTracking an `Optional<const Instruction *>` and make `safeCxtI` unconditionally use the contents of the `Optional` if it is inhabited with a value, even if that value is `nullptr`.



More information about the llvm-commits mailing list