llvm.org GIT mirror llvm / ecdbbbe
Update BitRecTy::convertValue to allow if expressions with bit values on both sides of the if git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215087 91177308-0d34-0410-b5e6-96231b3b80d8 Pete Cooper 5 years ago
2 changed file(s) with 12 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
118118 if (auto *BitsTy = dyn_cast(Ty))
119119 // Accept only bits<1> expression.
120120 return BitsTy->getNumBits() == 1 ? VI : nullptr;
121 // Ternary !if can be converted to bit, but only if both sides are
122 // convertible to a bit.
123 if (TernOpInit *TOI = dyn_cast(VI)) {
124 if (TOI->getOpcode() != TernOpInit::TernaryOp::IF)
125 return nullptr;
126 if (!TOI->getMHS()->convertInitializerTo(BitRecTy::get()) ||
127 !TOI->getRHS()->convertInitializerTo(BitRecTy::get()))
128 return nullptr;
129 return TOI;
130 }
121131 return nullptr;
122132 }
123133
44
55 class A {
66 int a = !if(b, 5, 6);
7 bit c = !if(b, 0, 1);
8 bits<1> d = !if(b, 0, 1);
79 }
810
911 def X : A<0>;