mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Code that checks WillNotOverflowSignedAdd before creating an Add
can safely use the NSW bit on the Add. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85164 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7c44beaf93
commit
fe3595555a
@ -2420,8 +2420,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
ConstantExpr::getSExt(CI, I.getType()) == RHSC &&
|
||||
WillNotOverflowSignedAdd(LHSConv->getOperand(0), CI)) {
|
||||
// Insert the new, smaller add.
|
||||
Value *NewAdd = Builder->CreateAdd(LHSConv->getOperand(0),
|
||||
CI, "addconv");
|
||||
Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0),
|
||||
CI, "addconv");
|
||||
return new SExtInst(NewAdd, I.getType());
|
||||
}
|
||||
}
|
||||
@ -2436,8 +2436,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
WillNotOverflowSignedAdd(LHSConv->getOperand(0),
|
||||
RHSConv->getOperand(0))) {
|
||||
// Insert the new integer add.
|
||||
Value *NewAdd = Builder->CreateAdd(LHSConv->getOperand(0),
|
||||
RHSConv->getOperand(0), "addconv");
|
||||
Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0),
|
||||
RHSConv->getOperand(0), "addconv");
|
||||
return new SExtInst(NewAdd, I.getType());
|
||||
}
|
||||
}
|
||||
@ -2493,8 +2493,8 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
|
||||
ConstantExpr::getSIToFP(CI, I.getType()) == CFP &&
|
||||
WillNotOverflowSignedAdd(LHSConv->getOperand(0), CI)) {
|
||||
// Insert the new integer add.
|
||||
Value *NewAdd = Builder->CreateAdd(LHSConv->getOperand(0),
|
||||
CI, "addconv");
|
||||
Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0),
|
||||
CI, "addconv");
|
||||
return new SIToFPInst(NewAdd, I.getType());
|
||||
}
|
||||
}
|
||||
@ -2509,8 +2509,8 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
|
||||
WillNotOverflowSignedAdd(LHSConv->getOperand(0),
|
||||
RHSConv->getOperand(0))) {
|
||||
// Insert the new integer add.
|
||||
Value *NewAdd = Builder->CreateAdd(LHSConv->getOperand(0),
|
||||
RHSConv->getOperand(0), "addconv");
|
||||
Value *NewAdd = Builder->CreateNSWAdd(LHSConv->getOperand(0),
|
||||
RHSConv->getOperand(0), "addconv");
|
||||
return new SIToFPInst(NewAdd, I.getType());
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -instcombine -S | grep {add i32}
|
||||
; RUN: opt < %s -instcombine -S | grep {add nsw i32}
|
||||
; RUN: opt < %s -instcombine -S | grep sext | count 1
|
||||
|
||||
; Should only have one sext and the add should be i32 instead of i64.
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -instcombine -S | grep {add i32}
|
||||
; RUN: opt < %s -instcombine -S | grep {add nsw i32}
|
||||
|
||||
define double @x(i32 %a, i32 %b) nounwind {
|
||||
%m = lshr i32 %a, 24
|
||||
|
Loading…
Reference in New Issue
Block a user