llvm.org GIT mirror llvm / 1297775
InstSimplify: div %X, 0 -> undef We already optimized rem %X, 0 to undef, we should do the same for div. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223919 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 4 years ago
2 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
10091009 // X / undef -> undef
10101010 if (match(Op1, m_Undef()))
10111011 return Op1;
1012
1013 // X / 0 -> undef, we don't need to preserve faults!
1014 if (match(Op1, m_Zero()))
1015 return UndefValue::get(Op1->getType());
10121016
10131017 // undef / X -> 0
10141018 if (match(Op0, m_Undef()))
159159 %b = shl <4 x i8> %a,
160160 ret <4 x i8> %b
161161 }
162
163 ; CHECK-LABEL: @test20
164 ; CHECK: ret i32 undef
165 define i32 @test20(i32 %a) {
166 %b = udiv i32 %a, 0
167 ret i32 %b
168 }
169
170 ; CHECK-LABEL: @test21
171 ; CHECK: ret i32 undef
172 define i32 @test21(i32 %a) {
173 %b = sdiv i32 %a, 0
174 ret i32 %b
175 }