The RHS of an isImpliedCond call can be a pointer even if the LHS is not. This is similar to bfa2a81e.
Not going to include a testcase; an IR testcase would be extremely complicated and fragile.
Differential D114555
[ScalarEvolution] Add bailout to avoid zext of pointer. efriedma on Nov 24 2021, 11:22 AM. Authored by
Details The RHS of an isImpliedCond call can be a pointer even if the LHS is not. This is similar to bfa2a81e. Not going to include a testcase; an IR testcase would be extremely complicated and fragile.
Diff Detail
Event TimelineComment Actions FWIW, this fixes both the minimized test case from PR52594, and the full original test case from https://bugs.freebsd.org/260000. Comment Actions I'm wondering about:
Below a reduced version from PR52594, which doesn't look too bad IMO. Is there anything in particular you think makes this test very fragile> target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" define void @test(i8* %a, i8* %b, i64 %c) { entry: br label %loop.1.header loop.1.header: %iv.1 = phi i8* [ %a, %entry ], [ %iv.1.next, %loop.1.latch ] %cond = icmp eq i64 %c, 0 br i1 %cond, label %loop.1.latch, label %exit loop.1.latch: %iv.1.next = getelementptr inbounds i8, i8* %iv.1, i32 1 %ec = icmp eq i8* %iv.1.next, %b br i1 %ec, label %loop.2.ph, label %loop.1.header loop.2.ph: br label %loop.2 loop.2: %iv.2 = phi i8* [ %iv.1.next, %loop.2.ph ], [ %iv.2.next, %loop.2 ] %iv.2.int = ptrtoint i8* %iv.2 to i32 call void @wobble(i32 %iv.2.int) %ec.1 = icmp ult i8* %iv.2, %b %ec.1.trunc = and i1 %ec.1, 1 %iv.2.next = getelementptr inbounds i8, i8* %iv.2, i32 1 br i1 %ec.1.trunc, label %loop.2, label %exit exit: ret void } declare void @wobble(i32)
Comment Actions The testcase isn't that complicated in terms of the size of the IR, but it would be hard to ensure it continues to test the codepath in question. The actual crash involves many levels of recursive calls in SCEV, and we aren't expecting any useful information out of the isImpliedCond analysis in this case. I could include it anyway, I guess.
|
can this be moved up before if (!CmpInst::isSigned(FoundPred).... and the pointer check dropped from the condition above?