File tree 2 files changed +7
-4
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -934,6 +934,11 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
934
934
}
935
935
}
936
936
937
+ if (DestWidth == 1 &&
938
+ (Trunc.hasNoUnsignedWrap () || Trunc.hasNoSignedWrap ()) &&
939
+ isKnownNonZero (Src, SQ.getWithInstruction (&Trunc)))
940
+ return replaceInstUsesWith (Trunc, ConstantInt::getTrue (DestTy));
941
+
937
942
bool Changed = false ;
938
943
if (!Trunc.hasNoSignedWrap () &&
939
944
ComputeMaxSignificantBits (Src, /* Depth=*/ 0 , &Trunc) <= DestWidth) {
Original file line number Diff line number Diff line change @@ -1129,8 +1129,7 @@ define i1 @trunc_nuw_i1_non_zero(i8 %1) {
1129
1129
; CHECK-LABEL: @trunc_nuw_i1_non_zero(
1130
1130
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
1131
1131
; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
1132
- ; CHECK-NEXT: [[RET:%.*]] = trunc nuw i8 [[TMP0]] to i1
1133
- ; CHECK-NEXT: ret i1 [[RET]]
1132
+ ; CHECK-NEXT: ret i1 true
1134
1133
;
1135
1134
%3 = icmp ne i8 %1 , 0
1136
1135
tail call void @llvm.assume (i1 %3 )
@@ -1177,8 +1176,7 @@ define i1 @trunc_nsw_i1_non_zero(i8 %1) {
1177
1176
; CHECK-LABEL: @trunc_nsw_i1_non_zero(
1178
1177
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
1179
1178
; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP2]])
1180
- ; CHECK-NEXT: [[RET:%.*]] = trunc nsw i8 [[TMP0]] to i1
1181
- ; CHECK-NEXT: ret i1 [[RET]]
1179
+ ; CHECK-NEXT: ret i1 true
1182
1180
;
1183
1181
%3 = icmp ne i8 %1 , 0
1184
1182
tail call void @llvm.assume (i1 %3 )
You can’t perform that action at this time.
0 commit comments