File tree 2 files changed +35
-0
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -1121,6 +1121,10 @@ Instruction *InstCombinerImpl::visitZExt(ZExtInst &Zext) {
1121
1121
Value *Src = Zext.getOperand (0 );
1122
1122
Type *SrcTy = Src->getType (), *DestTy = Zext.getType ();
1123
1123
1124
+ // zext nneg bool x -> 0
1125
+ if (SrcTy->isIntOrIntVectorTy (1 ) && Zext.hasNonNeg ())
1126
+ return replaceInstUsesWith (Zext, Constant::getNullValue (Zext.getType ()));
1127
+
1124
1128
// Try to extend the entire expression tree to the wide destination type.
1125
1129
unsigned BitsToClear;
1126
1130
if (shouldChangeType (SrcTy, DestTy) &&
Original file line number Diff line number Diff line change @@ -836,3 +836,34 @@ define i64 @zext_nneg_demanded_constant(i8 %a) nounwind {
836
836
%c = and i64 %b , 254
837
837
ret i64 %c
838
838
}
839
+
840
+ define i32 @zext_nneg_i1 (i1 %x ) {
841
+ ; CHECK-LABEL: @zext_nneg_i1(
842
+ ; CHECK-NEXT: entry:
843
+ ; CHECK-NEXT: ret i32 0
844
+ ;
845
+ entry:
846
+ %res = zext nneg i1 %x to i32
847
+ ret i32 %res
848
+ }
849
+
850
+ define <2 x i32 > @zext_nneg_i1_vec (<2 x i1 > %x ) {
851
+ ; CHECK-LABEL: @zext_nneg_i1_vec(
852
+ ; CHECK-NEXT: entry:
853
+ ; CHECK-NEXT: ret <2 x i32> zeroinitializer
854
+ ;
855
+ entry:
856
+ %res = zext nneg <2 x i1 > %x to <2 x i32 >
857
+ ret <2 x i32 > %res
858
+ }
859
+
860
+ define i32 @zext_nneg_i2 (i2 %x ) {
861
+ ; CHECK-LABEL: @zext_nneg_i2(
862
+ ; CHECK-NEXT: entry:
863
+ ; CHECK-NEXT: [[RES:%.*]] = zext nneg i2 [[X:%.*]] to i32
864
+ ; CHECK-NEXT: ret i32 [[RES]]
865
+ ;
866
+ entry:
867
+ %res = zext nneg i2 %x to i32
868
+ ret i32 %res
869
+ }
You can’t perform that action at this time.
0 commit comments