File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -828,9 +828,10 @@ static Instruction *foldNoWrapAdd(BinaryOperator &Add,
828
828
829
829
// More general combining of constants in the wide type.
830
830
// (sext (X +nsw NarrowC)) + C --> (sext X) + (sext(NarrowC) + C)
831
+ // or (zext nneg (X +nsw NarrowC)) + C --> (sext X) + (sext(NarrowC) + C)
831
832
Constant *NarrowC;
832
- if (match (Op0,
833
- m_OneUse ( m_SExt ( m_NSWAddLike (m_Value (X), m_Constant (NarrowC)))))) {
833
+ if (match (Op0, m_OneUse ( m_SExtLike (
834
+ m_NSWAddLike (m_Value (X), m_Constant (NarrowC)))))) {
834
835
Value *WideC = Builder.CreateSExt (NarrowC, Ty);
835
836
Value *NewC = Builder.CreateAdd (WideC, Op1C);
836
837
Value *WideX = Builder.CreateSExt (X, Ty);
@@ -844,7 +845,6 @@ static Instruction *foldNoWrapAdd(BinaryOperator &Add,
844
845
Value *WideX = Builder.CreateZExt (X, Ty);
845
846
return BinaryOperator::CreateAdd (WideX, NewC);
846
847
}
847
-
848
848
return nullptr ;
849
849
}
850
850
Original file line number Diff line number Diff line change @@ -4093,9 +4093,8 @@ define i32 @fold_zext_addition_fail2(i8 %x) {
4093
4093
4094
4094
define i32 @fold_zext_nneg_add_const (i8 %x ) {
4095
4095
; CHECK-LABEL: @fold_zext_nneg_add_const(
4096
- ; CHECK-NEXT: [[XX:%.*]] = add nsw i8 [[X:%.*]], 123
4097
- ; CHECK-NEXT: [[ZE:%.*]] = zext nneg i8 [[XX]] to i32
4098
- ; CHECK-NEXT: [[R:%.*]] = add nsw i32 [[ZE]], -25
4096
+ ; CHECK-NEXT: [[TMP1:%.*]] = sext i8 [[X:%.*]] to i32
4097
+ ; CHECK-NEXT: [[R:%.*]] = add nsw i32 [[TMP1]], 98
4099
4098
; CHECK-NEXT: ret i32 [[R]]
4100
4099
;
4101
4100
%xx = add nsw i8 %x , 123
You can’t perform that action at this time.
0 commit comments