rjmccall added inline comments.

================
Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3075
+                        ConvertType(DstType), ScalarConversionOpts());
+}
+
----------------
...I wrote out what this function should look like, and Phabricator just threw 
it away.  Let me try to write it out again.

This function is performing normal, unpromoted emission and then promoting the 
result.  That is not correct; it should be recognizing the expressions that 
support promoted emission and then requested promoted emission for them.  It 
should only fall back on unpromoted emission for the expressions that don't 
support promoted emission.  This necessarily means that you'll need to do a 
reduced version of the expression switch-out that the normal emitter does, like 
so:

```
Value *ScalarExprEmitter::EmitPromoted(const Expr *E, QualType PromotionType) {
  if (auto BO = dyn_cast<BinaryOperator>(E)) {
    switch (BO->getOpcode()) {
#define HANDLE_BINOP(OP) \
    case BO_##OP: return EmitBin##OP(EmitBinOps(E, PromotionType));
    HANDLE_BINOP(Add)
    HANDLE_BINOP(Sub)
    HANDLE_BINOP(Mul)
    HANDLE_BINOP(Div)
#undef HANDLE_BINOP
    default: break;
    }
  } else if (...) { // <- recognize other expressions that support promoted 
emission here
  }

  // fallback path
  auto result = Visit(E);
  if (result) result = CGF.Builder.CreateFPExt(result, 
ConvertType(E->getType()));
  return result;
}
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113107/new/

https://reviews.llvm.org/D113107

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to