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) {
934934 }
935935 }
936936
937+ if (DestWidth == 1 && Trunc.hasNoUnsignedWrap () &&
938+ isKnownNonZero (Src, SQ.getWithInstruction (&Trunc)))
939+ return replaceInstUsesWith (Trunc, ConstantInt::getTrue (DestTy));
940+
937941 bool Changed = false ;
938942 if (!Trunc.hasNoSignedWrap () &&
939943 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) {
11291129; CHECK-LABEL: @trunc_nuw_i1_non_zero(
11301130; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i8 [[TMP0:%.*]], 0
11311131; 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
11341133;
11351134 %3 = icmp ne i8 %1 , 0
11361135 tail call void @llvm.assume (i1 %3 )
You can’t perform that action at this time.
0 commit comments