File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -1830,10 +1830,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
1830
1830
bool IntMinIsPoison = cast<Constant>(II->getArgOperand (1 ))->isOneValue ();
1831
1831
1832
1832
// abs(-x) -> abs(x)
1833
- // TODO: Copy nsw if it was present on the neg?
1834
1833
Value *X;
1835
- if (match (IIOperand, m_Neg (m_Value (X))))
1834
+ if (match (IIOperand, m_Neg (m_Value (X)))) {
1835
+ if (cast<Instruction>(IIOperand)->hasNoSignedWrap () || IntMinIsPoison)
1836
+ replaceOperand (*II, 1 , Builder.getTrue ());
1836
1837
return replaceOperand (*II, 0 , X);
1838
+ }
1837
1839
if (match (IIOperand, m_c_Select (m_Neg (m_Value (X)), m_Deferred (X))))
1838
1840
return replaceOperand (*II, 0 , X);
1839
1841
Original file line number Diff line number Diff line change @@ -229,7 +229,7 @@ define i32 @abs_of_neg(i32 %x) {
229
229
230
230
define <4 x i32 > @abs_of_neg_vec (<4 x i32 > %x ) {
231
231
; CHECK-LABEL: @abs_of_neg_vec(
232
- ; CHECK-NEXT: [[B:%.*]] = call <4 x i32> @llvm.abs.v4i32(<4 x i32> [[X:%.*]], i1 false )
232
+ ; CHECK-NEXT: [[B:%.*]] = call <4 x i32> @llvm.abs.v4i32(<4 x i32> [[X:%.*]], i1 true )
233
233
; CHECK-NEXT: ret <4 x i32> [[B]]
234
234
;
235
235
%a = sub nsw <4 x i32 > zeroinitializer , %x
You can’t perform that action at this time.
0 commit comments