[llvm-commits] Div->[USF]Div Patch, Attempt #2
Chris Lattner
clattner at apple.com
Wed Oct 25 20:37:04 PDT 2006
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20061025/d507821c/attachment.html>
More information about the llvm-commits
mailing list