Fix the handling of !if result, avoiding null results for non 'int'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106201 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bruno Cardoso Lopes 2010-06-17 01:50:39 +00:00
parent c73993b678
commit 477bf62048

View File

@ -981,8 +981,9 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
}
case IF: {
IntInit *LHSi =
dynamic_cast<IntInit*>(LHS->convertInitializerTo(new IntRecTy()));
IntInit *LHSi = dynamic_cast<IntInit*>(LHS);
if (Init *I = LHS->convertInitializerTo(new IntRecTy()))
LHSi = dynamic_cast<IntInit*>(I);
if (LHSi) {
if (LHSi->getValue()) {
return MHS;
@ -1001,8 +1002,9 @@ Init *TernOpInit::resolveReferences(Record &R, const RecordVal *RV) {
Init *lhs = LHS->resolveReferences(R, RV);
if (Opc == IF && lhs != LHS) {
IntInit *Value =
dynamic_cast<IntInit*>(LHS->convertInitializerTo(new IntRecTy()));
IntInit *Value = dynamic_cast<IntInit*>(lhs);
if (Init *I = lhs->convertInitializerTo(new IntRecTy()))
Value = dynamic_cast<IntInit*>(I);
if (Value != 0) {
// Short-circuit
if (Value->getValue()) {