[PATCH] D43762: [IPSCCP] Use constant range information for comparisons of parameters.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 13 05:31:52 PDT 2018



On 12/07/2018 03:12, Eric Christopher wrote:
> I've gone ahead and reverted this for now in r336877. Happy to help if 
> we need anything more here.
> 
> -eric
> 

Thanks for the small reproducer and for reverting this!

It looks like this has exposed an existing problem in IPSCCP, where we 
mark the result of a call as forced false in ResolvedUndefsIn because 
the condition of a branch is unknown yet. Later we merge in the known 
return value, which makes the return value overdefined.

But the return value for the function will be marked as constant and get 
replaced with undef, causing the problem. In the example below, testf 
gets changed to `return i1 undef, but %call does not get replaced by 
true in @bar. I'll address this separately first.


define void @bar() {
entry:
   br label %if.then
if.then:                                          ; preds = %entry, %if.then
   %foo = phi i32 [ 0, %entry], [ %next, %if.then]
   %next = add i32 %foo, 1
   %call = call i1 @testf()
   br i1 %call, label %if.end, label %if.then

if.end:                                           ; preds = %if.then, %entry
   ret void
}

define internal i1 @testf() {
   br i1 undef, label %if.then1, label %if.end3

if.then1:                                         ; preds = %if.end
   br label %if.end3

if.end3:                                          ; preds = %if.then1, 
%if.end
   ret i1 true
}


More information about the llvm-commits mailing list