[llvm-dev] [AssumeBundles] ValueTracking cannot use alignment assumptions?

Bozhenov, Nikolai via llvm-dev llvm-dev at lists.llvm.org
Wed Nov 18 19:42:20 PST 2020


Sure. Submitted https://bugs.llvm.org/show_bug.cgi?id=48224

-Nikolai


-----Original Message-----
From: Roman Lebedev <lebedev.ri at gmail.com> 
Sent: Wednesday, November 18, 2020 3:00 AM
To: Bozhenov, Nikolai <nikolai.bozhenov at intel.com>
Cc: llvm-dev at lists.llvm.org; tyker1 at outlook.com; johannes at jdoerfert.de; scui at ca.ibm.com; aqjune at gmail.com; nikita.ppv at gmail.com; Alexander.Richardson at cl.cam.ac.uk; efriedma at quicinc.com
Subject: Re: [AssumeBundles] ValueTracking cannot use alignment assumptions?

That sounds like a bug, yes.
Please file a bug? :)

Roman

On Wed, Nov 18, 2020 at 6:26 AM Bozhenov, Nikolai <nikolai.bozhenov at intel.com> wrote:
>
> Hello,
>
> As I can see, recently LLVM switched to using assume bundles to encode 
> alignment information: 
> https://reviews.llvm.org/rG78de7297abe2e8fa782682168989c70e3cb34a5c
>
> However, it seems that the ValueTracking cannot understand the new format. As an example, consider compilation of the following reproducer with clang-11 (old assume format) and clang-trunk (assume bundles):
>
>   #include <stdint.h>
>   int foo(int *p) {
>     __builtin_assume_aligned(p, 32);
>     return ((intptr_t) p) & 4;
>   }
>
> clang-11 (https://godbolt.org/z/xGh1e4) computes the returned value statically:
>
>   ret i32 0
>
> clang-trunk (https://godbolt.org/z/1jWe5j) fails to optimize the code:
>
>   %3 = ptrtoint i32* %0 to i64
>   %4 = trunc i64 %3 to i32
>   %5 = and i32 %4, 4
>   ret i32 %5
>
> As one can see, after switching to operand bundles, clang-trunk lost its ability to reason about low bits in aligned pointers.
>
> So, I wonder if there are any plans to teach ValueTracking how to use alignment information from assume bundles? And if not, should we revert to the old format for alignment assumptions until ValueTracking is improved?
>
> Thanks,
> Nikolai


More information about the llvm-dev mailing list