================ @@ -2621,9 +2621,25 @@ EmitAsmStores(CodeGenFunction &CGF, const AsmStmt &S, if ((i < ResultRegIsFlagReg.size()) && ResultRegIsFlagReg[i]) { // Target must guarantee the Value `Tmp` here is lowered to a boolean // value. - llvm::Constant *Two = llvm::ConstantInt::get(Tmp->getType(), 2); + // Lowering 'Tmp' as - 'icmp ult %Tmp , CCUpperBound'. On some targets + // CCUpperBound is not binary. CCUpperBound is 4 for SystemZ, + // interval [0, 4). With this range known, llvm.assume intrinsic guides + // optimizer to generate more optimized IR in most of the cases as + // observed for select_cc on SystemZ unit tests for flag output operands. + // For some cases for br_cc, generated IR was weird. e.g. switch table + // for simple simple comparison terms for br_cc. + StringRef Name; + if (const GCCAsmStmt *GAS = dyn_cast<GCCAsmStmt>(&S)) + Name = GAS->getOutputName(i); + TargetInfo::ConstraintInfo Info(S.getOutputConstraint(i), Name); + bool IsValid = CGF.getTarget().validateOutputConstraint(Info); + (void)IsValid; + assert(IsValid && "Failed to parse flag output operand constraint"); ---------------- uweigand wrote:
All this parsing was done in the caller of this routine (`EmitAsmStmt`) already - we shouldn't do that again here. I think instead of passing the `ResultRegIsFlagReg` array down into this routine, the caller should already compute the appropriate bounds and pass an array of those bounds into this function. This might even allow us to remove the hard-coded `llvm::StringRef(OutputConstraint).starts_with("{@cc")` test in `EmitAsmStmt` and defer to the target the decision which output operands may be assumed to fall within a certain range of values. https://github.com/llvm/llvm-project/pull/125970 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits