[ConstantExpr] Adding folding tests

Hey everyone,

I’d like to add some new constant foldings to ConstantExpr – in particular ConstantExpr::get(…) and friends. But, I’m having trouble finding the correct place for adding IR tests in the /test directory.

Any suggestions?


Hi Cameron,

Ah, I should have mentioned that. So Matt and I looked into this, but that directory appears to be testing the constant folding in InstructionSimplify (and one or two other opt passes). That’s a different set of folds.

Looking closer now, hooking up this instruction (namely FNeg) in InstCombine to call ConstantExpr to do the folds is probably the best option. There’s prior art for this in test/Analysis/ConstantFolding/min-max.ll. Does anyone see problems with that plan?

Matt was correct from the start. InstructionSimplify ends up calling ConstantExpr to fold the constants. So the new folds are being exercised there.

Sorry for the noise! :slight_smile: