[llvm-commits] [llvm] r124487 - in /llvm/trunk: include/llvm/Analysis/InstructionSimplify.h lib/Analysis/InstructionSimplify.cpp lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstCombine/2008-11-20-DivMulRem.ll test/Transfor

Duncan Sands baldrick at free.fr
Fri Jan 28 11:00:21 PST 2011


Hi Frits,

>> +    BinaryOperator *Mul = dyn_cast<BinaryOperator>(Op0);
>
> This can be a regular cast<>  since you just matched Op0 agains m_Mul().

yup, fixed.

> This could also handle the "X = A / Z and Y<  Z" case, especially for
> constant integers Y and Z.

Yes, but since I never saw this in practice I'm not very motivated to do it.

>>   Instruction *InstCombiner::visitFDiv(BinaryOperator&I) {
>> -  return commonDivTransforms(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;
>>   }
>
> This looks like it belongs in the SimplifyInstruction infrastructure.

Yup, and there's plenty of other stuff in instcombine that could be moved to
instsimplify.  I actually added this as an open project on the web page as I
could do with some help with this.

Ciao, Duncan.



More information about the llvm-commits mailing list