forked from OSchip/llvm-project
[InstCombine] fix undef propagation for vector urem transform (PR44186)
As described here: https://bugs.llvm.org/show_bug.cgi?id=44186 The match() code safely allows undef values, but we can't safely propagate a vector constant that contains an undef to the new compare instruction.
This commit is contained in:
parent
d8d5106225
commit
af4e59949c
|
@ -1368,8 +1368,10 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) {
|
|||
}
|
||||
|
||||
// 1 urem X -> zext(X != 1)
|
||||
if (match(Op0, m_One()))
|
||||
return CastInst::CreateZExtOrBitCast(Builder.CreateICmpNE(Op1, Op0), Ty);
|
||||
if (match(Op0, m_One())) {
|
||||
Value *Cmp = Builder.CreateICmpNE(Op1, ConstantInt::get(Ty, 1));
|
||||
return CastInst::CreateZExtOrBitCast(Cmp, Ty);
|
||||
}
|
||||
|
||||
// X urem C -> X < C ? X : X - C, where C >= signbit.
|
||||
if (match(Op1, m_Negative())) {
|
||||
|
|
|
@ -39,7 +39,7 @@ define <4 x i32> @test_v4i32_one(<4 x i32> %a0) {
|
|||
|
||||
define <4 x i32> @test_v4i32_one_undef(<4 x i32> %a0) {
|
||||
; CHECK-LABEL: @test_v4i32_one_undef(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <4 x i32> [[A0:%.*]], <i32 1, i32 1, i32 1, i32 undef>
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <4 x i32> [[A0:%.*]], <i32 1, i32 1, i32 1, i32 1>
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = zext <4 x i1> [[TMP1]] to <4 x i32>
|
||||
; CHECK-NEXT: ret <4 x i32> [[TMP2]]
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue