llvm.org GIT mirror llvm / 6578f1b
InstSimplify: [al]shr exact undef, %X -> undef Exact shifts always keep the non-zero bits of their input. This means it keeps it's undef bits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223923 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 4 years ago
2 changed file(s) with 20 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
13861386 return V;
13871387
13881388 // undef >>l X -> 0
1389 // undef >>l X -> undef (if it's exact)
13891390 if (match(Op0, m_Undef()))
1390 return Constant::getNullValue(Op0->getType());
1391 return isExact ? UndefValue::get(Op0->getType())
1392 : Constant::getNullValue(Op0->getType());
13911393
13921394 // (X << A) >> A -> X
13931395 Value *X;
14201422 return Op0;
14211423
14221424 // undef >>a X -> all ones
1425 // undef >>a X -> undef (if it's exact)
14231426 if (match(Op0, m_Undef()))
1424 return Constant::getAllOnesValue(Op0->getType());
1427 return isExact ? UndefValue::get(Op0->getType())
1428 : Constant::getAllOnesValue(Op0->getType());
14251429
14261430 // (X << A) >> A -> X
14271431 Value *X;
173173 %b = sdiv i32 %a, 0
174174 ret i32 %b
175175 }
176
177 ; CHECK-LABEL: @test22
178 ; CHECK: ret i32 undef
179 define i32 @test22(i32 %a) {
180 %b = ashr exact i32 undef, %a
181 ret i32 %b
182 }
183
184 ; CHECK-LABEL: @test23
185 ; CHECK: ret i32 undef
186 define i32 @test23(i32 %a) {
187 %b = lshr exact i32 undef, %a
188 ret i32 %b
189 }