[LLVMbugs] [Bug 19964] New: optimization of (x>>8)==0 breaks other comparisons with x

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 5 17:49:46 PDT 2014


            Bug ID: 19964
           Summary: optimization of (x>>8)==0 breaks other comparisons
                    with x
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define zeroext i1 @between(i32 %bf.load, i32 %n) {
  %bf.lshr = lshr i32 %bf.load, 16
  %cmp2 = icmp eq i32 %bf.lshr, 0
  %cmp5 = icmp uge i32 %bf.lshr, %n
  %.cmp5 = or i1 %cmp2, %cmp5
  ret i1 %.cmp5

We codegen this wrong in x86 by lowering the "lshr" into an "andl" for the
comparison against zero, but also use that masked value to compare against %n.

nlewycky at ducttape:~$ llvm/Debug+Asserts/bin/llc x2.ll -o -
        .file   "x2.ll"
        .globl  between
        .align  16, 0x90
        .type   between, at function
between:                                # @between
# BB#0:                                 # %entry
        andl    $-65536, %edi           # imm = 0xFFFFFFFFFFFF0000
        sete    %cl
        cmpl    %esi, %edi  ;; nope! either %edi needs to be shifted right or
%esi needs to be shifted left
        setae   %al
        orb     %cl, %al
        .size   between, .Ltmp0-between

        .section        ".note.GNU-stack","", at progbits

We produce correct code with llc -O0.

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/20140606/7c61b552/attachment.html>

More information about the llvm-bugs mailing list