[LLVMbugs] [Bug 13672] New: fold (gep i32* %p, 1) & 3 to %p & 3

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 22 18:58:56 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13672

             Bug #: 13672
           Summary: fold (gep i32* %p, 1) & 3 to %p & 3
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


LLVM does not fold away the second 'and' here (which is redundant because
%tmp15 == %tmp5 + 4):

target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.S = type { i32, i32 }

define i1 @_Z1fP1S(%struct.S* %p) nounwind uwtable {
bb:
  %tmp5 = ptrtoint %struct.S* %p to i64
  %tmp6 = and i64 %tmp5, 3
  %tmp7 = icmp eq i64 %tmp6, 0
  br i1 %tmp7, label %ok, label %fail

ok:                                               ; preds = %bb
  %tmp11 = getelementptr inbounds %struct.S* %p, i64 0, i32 1
  %tmp15 = ptrtoint i32* %tmp11 to i64
  %tmp16 = and i64 %tmp15, 3
  %tmp17 = icmp eq i64 %tmp16, 0
  br i1 %tmp17, label %ok.2, label %fail

ok.2:                                             ; preds = %ok
  ret i1 true

fail:                                             ; preds = %ok, %bb
  tail call void @llvm.trap()
  unreachable
}

declare void @llvm.trap() noreturn nounwind

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list