[PATCH] Do not transform PHI to select if doing so would be unsafe

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Jun 3 06:19:11 PDT 2013


On 2 June 2013 04:08, David Majnemer <david.majnemer at gmail.com> wrote:
> PR16069 is an interesting case where an incoming value to a PHI is a trap
> value while also being a 'ConstantExpr'.
>
> We do not consider this case when performing the 'HoistThenElseCodeToIf'
> optimization.
>
> The attached patch will make our modifications more conservative if we
> detect that we cannot transform the PHI to a select.

The change to isValueEqualityComparison is just a cleanup, right? If
so, please commit that first as an independent patch.

The comment
  // If we get here, we can hoist at least one instruction

is now out of date.

Why do you need the isa<ConstantExpr>? Can't the check be just

     if (!isSafeToSpeculativelyExecute(BB1V) ||
!isSafeToSpeculativelyExecute(BB2V))
       return Changed;

LGTM with those changes.

Cheers,
Rafael



More information about the llvm-commits mailing list