[llvm-commits] [llvm] r124534 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/InstructionSimplify.cpp lib/Transforms/InstCombine/InstCombine.h lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstSimplify/fdiv.ll

Duncan Sands baldrick at free.fr
Sat Jan 29 09:06:35 PST 2011


Hi Frits,

> +static Value *SimplifyFDivInst(Value *Op0, Value *Op1, const TargetData *TD,
> +                               const DominatorTree *DT, unsigned MaxRecurse) {

since none of TD, DT or MaxRecurse are used, some compilers will issue warnings.
The fix is to not to give these parameters names.

> -Instruction *InstCombiner::visitFDiv(BinaryOperator&I) {
> -  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
> -
> -  // undef / X ->  undef    (the undef could be a snan).
> -  if (isa<UndefValue>(Op0))
> -    return ReplaceInstUsesWith(I, Op0);
> -
> -  // X / undef ->  undef
> -  if (isa<UndefValue>(Op1))
> -    return ReplaceInstUsesWith(I, Op1);
> -
> -  return 0;
> -}

You should have FDiv call SimplifyFDiv.  Currently instcombine doesn't
automagically call SimplifyInstruction on everything (because it leads
to regressions) so you have to do it in each place where you want it.
For example, I expect your testcases to fail when using -instcombine

Ciao, Duncan.



More information about the llvm-commits mailing list