File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -934,6 +934,10 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
934
934
}
935
935
}
936
936
937
+ if (DestWidth == 1 && Trunc.hasNoUnsignedWrap () &&
938
+ isKnownNonZero (Src, SQ.getWithInstruction (&Trunc)))
939
+ return replaceInstUsesWith (Trunc, ConstantInt::getTrue (DestTy));
940
+
937
941
bool Changed = false ;
938
942
if (!Trunc.hasNoSignedWrap () &&
939
943
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 )
You can’t perform that action at this time.
0 commit comments