Skip to content
  1. Dec 19, 2010
  2. Dec 18, 2010
  3. Dec 17, 2010
    • Owen Anderson's avatar
      Reapply r121905 (automatic synthesis of @llvm.sadd.with.overflow) with a fix... · 1294ea7d
      Owen Anderson authored
      Reapply r121905 (automatic synthesis of @llvm.sadd.with.overflow) with a fix for a bug that manifested itself
      on the DragonEgg self-host bot.  Unfortunately, the testcase is pretty messy and doesn't reduce well due to
      interactions with other parts of InstCombine.
      
      llvm-svn: 122072
      1294ea7d
    • Benjamin Kramer's avatar
      e5f49c4f
    • Chris Lattner's avatar
      improve switch formation to handle small range · d14b0f1d
      Chris Lattner authored
      comparisons formed by comparisons.  For example,
      this:
      
      void foo(unsigned x) {
        if (x == 0 || x == 1 || x == 3 || x == 4 || x == 6) 
          bar();
      }
      
      compiles into:
      
      _foo:                                   ## @foo
      ## BB#0:                                ## %entry
      	cmpl	$6, %edi
      	ja	LBB0_2
      ## BB#1:                                ## %entry
      	movl	%edi, %eax
      	movl	$91, %ecx
      	btq	%rax, %rcx
      	jb	LBB0_3
      
      instead of:
      
      _foo:                                   ## @foo
      ## BB#0:                                ## %entry
      	cmpl	$2, %edi
      	jb	LBB0_4
      ## BB#1:                                ## %switch.early.test
      	cmpl	$6, %edi
      	ja	LBB0_3
      ## BB#2:                                ## %switch.early.test
      	movl	%edi, %eax
      	movl	$88, %ecx
      	btq	%rax, %rcx
      	jb	LBB0_4
      
      This catches a bunch of cases in GCC, which look like this:
      
       %804 = load i32* @which_alternative, align 4, !tbaa !0
       %805 = icmp ult i32 %804, 2
       %806 = icmp eq i32 %804, 3
       %or.cond121 = or i1 %805, %806
       %807 = icmp eq i32 %804, 4
       %or.cond124 = or i1 %or.cond121, %807
       br i1 %or.cond124, label %.thread, label %808
      
      turning this into a range comparison.
      
      llvm-svn: 122045
      d14b0f1d
    • Dan Gohman's avatar
      Revert r64460. strtol and friends cannot be marked readonly, even with · 93dc2b80
      Dan Gohman authored
      a null endptr argument, because they may write to errno.
      
      This fixes a seflhost miscompile observed on Linux targets when TBAA
      was enabled.
      
      llvm-svn: 122014
      93dc2b80
  4. Dec 16, 2010
  5. Dec 15, 2010
  6. Dec 14, 2010
  7. Dec 13, 2010
    • Benjamin Kramer's avatar
    • Chris Lattner's avatar
      reinstate my patch: the miscompile was caused by an inverted branch in the · fb836f8c
      Chris Lattner authored
      'and' case.
      
      llvm-svn: 121695
      fb836f8c
    • Chris Lattner's avatar
      Completely disable the optimization I added in r121680 until · 79db357d
      Chris Lattner authored
      I can track down a miscompile.  This should bring the buildbots
      back to life
      
      llvm-svn: 121693
      79db357d
    • Chris Lattner's avatar
      Make simplifycfg reprocess newly formed "br (cond1 | cond2)" conditions · fbeb5584
      Chris Lattner authored
      when simplifying, allowing them to be eagerly turned into switches.  This
      is the last step required to get "Example 7" from this blog post:
      http://blog.regehr.org/archives/320
      
      On X86, we now generate this machine code, which (to my eye) seems better
      than the ICC generated code:
      
      _crud:                                  ## @crud
      ## BB#0:                                ## %entry
      	cmpb	$33, %dil
      	jb	LBB0_4
      ## BB#1:                                ## %switch.early.test
      	addb	$-34, %dil
      	cmpb	$58, %dil
      	ja	LBB0_3
      ## BB#2:                                ## %switch.early.test
      	movzbl	%dil, %eax
      	movabsq	$288230376537592865, %rcx ## imm = 0x400000017001421
      	btq	%rax, %rcx
      	jb	LBB0_4
      LBB0_3:                                 ## %lor.rhs
      	xorl	%eax, %eax
      	ret
      LBB0_4:                                 ## %lor.end
      	movl	$1, %eax
      	ret
      
      llvm-svn: 121690
      fbeb5584
    • Chris Lattner's avatar
      fix a bug in r121680 that upset the various buildbots. · cb570f87
      Chris Lattner authored
      llvm-svn: 121687
      cb570f87
    • Chris Lattner's avatar
      make these tests a bit less fragile · bc9e6d9d
      Chris Lattner authored
      llvm-svn: 121682
      bc9e6d9d
    • Chris Lattner's avatar
      enhance the "change or icmp's into switch" xform to handle one value in an · a442f24a
      Chris Lattner authored
      'or sequence' that it doesn't understand.  This allows us to optimize
      something insane like this:
      
      int crud (unsigned char c, unsigned x)
       {
         if(((((((((( (int) c <= 32 ||
                          (int) c == 46) || (int) c == 44)
                        || (int) c == 58) || (int) c == 59) || (int) c == 60)
                     || (int) c == 62) || (int) c == 34) || (int) c == 92)
                  || (int) c == 39) != 0)
           foo();
       }
      
      into:
      
      define i32 @crud(i8 zeroext %c, i32 %x) nounwind ssp noredzone {
      entry:
        %cmp = icmp ult i8 %c, 33
        br i1 %cmp, label %if.then, label %switch.early.test
      
      switch.early.test:                                ; preds = %entry
        switch i8 %c, label %if.end [
          i8 39, label %if.then
          i8 44, label %if.then
          i8 58, label %if.then
          i8 59, label %if.then
          i8 60, label %if.then
          i8 62, label %if.then
          i8 46, label %if.then
          i8 92, label %if.then
          i8 34, label %if.then
        ]
      
      by pulling the < comparison out ahead of the newly formed switch.
      
      llvm-svn: 121680
      a442f24a
    • Chris Lattner's avatar
      merge two tests · a737721d
      Chris Lattner authored
      llvm-svn: 121679
      a737721d
    • Chris Lattner's avatar
      Fix my previous patch to handle a degenerate case that the llvm-gcc · 62cc76e9
      Chris Lattner authored
      bootstrap buildbot tripped over.
      
      llvm-svn: 121674
      62cc76e9
    • Chris Lattner's avatar
      fix a fairly serious oversight with switch formation from · d9bacc08
      Chris Lattner authored
      or'd conditions.  Previously we'd compile something like this:
      
      int crud (unsigned char c) {
         return c == 62 || c == 34 || c == 92;
      }
      
      into:
      
        switch i8 %c, label %lor.rhs [
          i8 62, label %lor.end
          i8 34, label %lor.end
        ]
      
      lor.rhs:                                          ; preds = %entry
        %cmp8 = icmp eq i8 %c, 92
        br label %lor.end
      
      lor.end:                                          ; preds = %entry, %entry, %lor.rhs
        %0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
        %lor.ext = zext i1 %0 to i32
        ret i32 %lor.ext
      
      which failed to merge the compare-with-92 into the switch.  With this patch
      we simplify this all the way to:
      
        switch i8 %c, label %lor.rhs [
          i8 62, label %lor.end
          i8 34, label %lor.end
          i8 92, label %lor.end
        ]
      
      lor.rhs:                                          ; preds = %entry
        br label %lor.end
      
      lor.end:                                          ; preds = %entry, %entry, %entry, %lor.rhs
        %0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
        %lor.ext = zext i1 %0 to i32
        ret i32 %lor.ext
      
      which is much better for codegen's switch lowering stuff.  This kicks in 33 times
      on 176.gcc (for example) cutting 103 instructions off the generated code.
      
      llvm-svn: 121671
      d9bacc08
  8. Dec 11, 2010
  9. Dec 09, 2010
  10. Dec 07, 2010
Loading