[llvm] r355292 - [ValueTracking] do not try to peek through bitcasts in computeKnownBitsFromAssume()

Finkel, Hal J. via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 09:52:48 PST 2019


On 3/3/19 12:59 PM, Sanjay Patel via llvm-commits wrote:
> Author: spatel
> Date: Sun Mar  3 10:59:33 2019
> New Revision: 355292
>
> URL: http://llvm.org/viewvc/llvm-project?rev=355292&view=rev
> Log:
> [ValueTracking] do not try to peek through bitcasts in computeKnownBitsFromAssume()
>
> There are no tests for this case, and I'm not sure how it could ever work,


Thanks, Sanjay. I imagine that I wrote that code, but I also now can't
remember what I was thinking -- and it's not obvious to me now either
how it would work :-(

 -Hal

> so I'm just removing this option from the matcher. This should fix PR40940:
> https://bugs.llvm.org/show_bug.cgi?id=40940
>
> Modified:
>     llvm/trunk/lib/Analysis/ValueTracking.cpp
>     llvm/trunk/test/Transforms/InstCombine/assume.ll
>
> Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=355292&r1=355291&r2=355292&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
> +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Sun Mar  3 10:59:33 2019
> @@ -617,9 +617,7 @@ static void computeKnownBitsFromAssume(c
>        continue;
>  
>      Value *A, *B;
> -    auto m_V = m_CombineOr(m_Specific(V),
> -                           m_CombineOr(m_PtrToInt(m_Specific(V)),
> -                           m_BitCast(m_Specific(V))));
> +    auto m_V = m_CombineOr(m_Specific(V), m_PtrToInt(m_Specific(V)));
>  
>      CmpInst::Predicate Pred;
>      uint64_t C;
>
> Modified: llvm/trunk/test/Transforms/InstCombine/assume.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/assume.ll?rev=355292&r1=355291&r2=355292&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/assume.ll (original)
> +++ llvm/trunk/test/Transforms/InstCombine/assume.ll Sun Mar  3 10:59:33 2019
> @@ -320,6 +320,24 @@ define void @debug_interference(i8 %x) {
>    ret void
>  }
>  
> +; This would crash.
> +; Does it ever make sense to peek through a bitcast of the icmp operand?
> +
> +define i32 @PR40940(<4 x i8> %x) {
> +; CHECK-LABEL: @PR40940(
> +; CHECK-NEXT:    [[SHUF:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> <i32 1, i32 1, i32 2, i32 3>
> +; CHECK-NEXT:    [[T2:%.*]] = bitcast <4 x i8> [[SHUF]] to i32
> +; CHECK-NEXT:    [[T3:%.*]] = icmp ult i32 [[T2]], 65536
> +; CHECK-NEXT:    call void @llvm.assume(i1 [[T3]])
> +; CHECK-NEXT:    ret i32 [[T2]]
> +;
> +  %shuf = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 1, i32 1, i32 2, i32 3>
> +  %t2 = bitcast <4 x i8> %shuf to i32
> +  %t3 = icmp ult i32 %t2, 65536
> +  call void @llvm.assume(i1 %t3)
> +  ret i32 %t2
> +}
> +
>  declare void @llvm.dbg.value(metadata, metadata, metadata)
>  
>  !llvm.dbg.cu = !{!0}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list