[llvm-bugs] [Bug 25763] New: Vector constant folding of comparisons does not follow the vector boolean format

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 7 05:59:09 PST 2015


            Bug ID: 25763
           Summary: Vector constant folding of comparisons does not follow
                    the vector boolean format
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: silviu.baranga at arm.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

r253504 introduced constant folding for vector setcc operations:

r253504 | rksimon | 2015-11-18 21:17:19 +0000 (Wed, 18 Nov 2015) | 7 lines

[DAGCombiner] Vector constant folding for comparisons

This patch adds support for vector constant folding of integer/float

This requires FoldConstantVectorArithmetic to support scalar constant operands
(in this case ISD::CONDCASE). In future we should be able to support other
scalar constant types as necessary (and possibly start calling
FoldConstantVectorArithmetic for all node creations)

Differential Revision: http://reviews.llvm.org/D14683

This folds vector comparisons by using scalar logic per-lane. However, boolean
output format can differ between scalar and vector operations (it can be either
one or negative one for true). On targets where there is a difference between
the scalar and vector boolean formats, this will cause a miscompile.


target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-gnu"

declare <8 x i8> @llvm.ctlz.v8i8(<8 x i8>, i1)

define <8 x i16> @dotests_458() {
  %vclz_v.i = call <8 x i8> @llvm.ctlz.v8i8(<8 x i8> <i8 127, i8 38, i8 -1, i8
-128, i8 127, i8 0, i8 0, i8 0>, i1 false) #6
  %vsra_n = lshr <8 x i8> %vclz_v.i, <i8 5, i8 5, i8 5, i8 5, i8 5, i8 5, i8 5,
i8 5>
  %name_6 = or <8 x i8> %vsra_n, <i8 127, i8 -128, i8 -1, i8 67, i8 84, i8 127,
i8 -1, i8 0>
  %cmp.i603 = icmp slt <8 x i8> %name_6, <i8 -57, i8 -128, i8 127, i8 -128, i8
-1, i8 0, i8 -1, i8 -1>
  %vmovl.i4.i = sext <8 x i1> %cmp.i603 to <8 x i16>
  ret <8 x i16> %vmovl.i4.i

Compiled with:
llc -O3 test.ll -o -


    .file    "test.ll"
    .section    .rodata.cst8,"aM", at progbits,8
    .align    3
    .byte    0                       // 0x0
    .byte    0                       // 0x0
    .byte    1                       // 0x1 ; This should be 0xff!
    .byte    0                       // 0x0
    .byte    0                       // 0x0
    .byte    0                       // 0x0
    .byte    0                       // 0x0
    .byte    0                       // 0x0
    .globl    dotests_458
    .align    2
    .type    dotests_458, at function
dotests_458:                            // @dotests_458
// BB#0:                                // %entry
    adrp    x8, .LCPI0_0
    ldr    d0, [x8, :lo12:.LCPI0_0]
    sshll    v0.8h, v0.8b, #0
    .size    dotests_458, .Lfunc_end0-dotests_458

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151207/182065d6/attachment.html>

More information about the llvm-bugs mailing list