mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Pull fptrunc's upwards through selects when one of the select's selectands was a constant. This has a number of benefits, including producing small immediates (easier to materialize, smaller constant pools) as well as being more likely to allow the fptrunc to fuse with a preceding instruction (truncating selects are unusual).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191929 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1229,6 +1229,19 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
|
||||
}
|
||||
}
|
||||
|
||||
// (fptrunc (select cond, R1, Cst)) -->
|
||||
// (select cond, (fptrunc R1), (fptrunc Cst))
|
||||
SelectInst *SI = dyn_cast<SelectInst>(CI.getOperand(0));
|
||||
if (SI &&
|
||||
(isa<ConstantFP>(SI->getOperand(1)) ||
|
||||
isa<ConstantFP>(SI->getOperand(2)))) {
|
||||
Value *LHSTrunc = Builder->CreateFPTrunc(SI->getOperand(1),
|
||||
CI.getType());
|
||||
Value *RHSTrunc = Builder->CreateFPTrunc(SI->getOperand(2),
|
||||
CI.getType());
|
||||
return SelectInst::Create(SI->getOperand(0), LHSTrunc, RHSTrunc);
|
||||
}
|
||||
|
||||
IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI.getOperand(0));
|
||||
if (II) {
|
||||
switch (II->getIntrinsicID()) {
|
||||
|
Reference in New Issue
Block a user