[llvm-commits] Div->[USF]Div Patch, Attempt #2

Reid Spencer rspencer at reidspencer.com
Wed Oct 25 21:26:15 PDT 2006


Done.

On Wed, 2006-10-25 at 20:37 -0700, Chris Lattner wrote:
> 
> On Oct 25, 2006, at 12:15 PM, Reid Spencer wrote:
> 
> > Attached are two patch files to replace the DIV instruction with 3
> > instructions: SDiv, UDiv, FDiv. The first file patches llvm. The
> > second
> > file patches llvm-gcc4. 
> > 
> > 
> > This is the 2nd attempt to provide the patch.  All comments are
> > welcome.
> 
> llvm-gcc part first:
> 
> 
> Instead of adding a switch stmt to EmitBinOp, please change it to
> something like this:
> 
> 
> +++ gcc/llvm-convert.cpp (working copy)
> @@ -544,9 +544,15 @@
>    case PLUS_EXPR:      Result = EmitBinOp(exp, DestLoc,
> Instruction::Add);break;
>    case MINUS_EXPR:     Result = EmitBinOp(exp, DestLoc,
> Instruction::Sub);break;
>    case MULT_EXPR:      Result = EmitBinOp(exp, DestLoc,
> Instruction::Mul);break;
> -  case TRUNC_DIV_EXPR: Result = EmitBinOp(exp, DestLoc,
> Instruction::Div);break;
> -  case EXACT_DIV_EXPR: Result = EmitBinOp(exp, DestLoc,
> Instruction::Div);break;
> -  case RDIV_EXPR:      Result = EmitBinOp(exp, DestLoc,
> Instruction::Div);break;
> +  case TRUNC_DIV_EXPR: 
> +    if (TREE_UNSIGNED(TREE_TYPE(exp)))
> +      Result = EmitBinOp(exp, DestLoc, Instruction::UDiv);
> +    else
> +      Result = EmitBinOp(exp, DestLoc, Instruction::SDiv);
> +    break;
> 
> 
> EXACT_DIV_EXPR should always be UDiv, RDIV_EXPR is fine.
> 
> 
> -Chris
> 
> 
> 
> 




More information about the llvm-commits mailing list